8 #ifndef META_OCEAN_CV_ADVANCED_PIXEL_TRIANGLE_H
9 #define META_OCEAN_CV_ADVANCED_PIXEL_TRIANGLE_H
32 template <
typename T>
class PixelTriangleT;
117 inline T
left()
const;
123 inline T
top()
const;
129 inline T
right()
const;
147 explicit inline operator bool()
const;
201 template <
typename T>
207 template <
typename T>
210 trianglePoints[0] = point0;
211 trianglePoints[1] = point1;
212 trianglePoints[2] = point2;
215 template <
typename T>
218 ocean_assert(triangle.
isValid());
219 ocean_assert(width >= 1u && height >= 1u);
226 template <
typename T>
229 return trianglePoints[0];
232 template <
typename T>
235 return trianglePoints[1];
238 template <
typename T>
241 return trianglePoints[2];
244 template <
typename T>
247 ocean_assert(isValid());
248 return min(trianglePoints[0].x(), min(trianglePoints[1].x(), trianglePoints[2].x()));
251 template <
typename T>
254 ocean_assert(isValid());
255 return min(trianglePoints[0].y(), min(trianglePoints[1].y(), trianglePoints[2].y()));
258 template <
typename T>
261 ocean_assert(isValid());
262 return max(trianglePoints[0].x(), max(trianglePoints[1].x(), trianglePoints[2].x()));
265 template <
typename T>
268 ocean_assert(isValid());
269 return max(trianglePoints[0].y(), max(trianglePoints[1].y(), trianglePoints[2].y()));
272 template <
typename T>
275 return trianglePoints[0].isValid() && trianglePoints[1].isValid() && trianglePoints[2].isValid();
278 template <
typename T>
284 template <
typename T>
287 ocean_assert(isValid() && offset.
isValid());
288 return PixelTriangleT<T>(trianglePoints[0] + offset, trianglePoints[1] + offset, trianglePoints[2] + offset);
291 template <
typename T>
294 ocean_assert(isValid() && offset.
isValid());
296 trianglePoints[0] += offset;
297 trianglePoints[1] += offset;
298 trianglePoints[2] += offset;
303 template <
typename T>
306 ocean_assert(isValid() && offset.
isValid());
307 return PixelTriangleT<T>(trianglePoints[0] - offset, trianglePoints[1] - offset, trianglePoints[2] - offset);
310 template <
typename T>
313 ocean_assert(isValid() && offset.
isValid());
315 trianglePoints[0] -= offset;
316 trianglePoints[1] -= offset;
317 trianglePoints[2] -= offset;
322 template <
typename T>
325 ocean_assert(index <= 2u);
326 return trianglePoints[index];
329 template <
typename T>
332 ocean_assert(index <= 2u);
333 return trianglePoints[index];
This class implements a 2D triangle with pixel precision.
Definition: PixelTriangle.h:70
T right() const
Returns the most right (including) position of this triangle.
Definition: PixelTriangle.h:259
const PixelPositionT< T > & point1() const
Returns the second corner point of this triangle.
Definition: PixelTriangle.h:233
PixelTriangleT()
Creates an invalid triangle.
Definition: PixelTriangle.h:202
T bottom() const
Returns the most bottom (including) position of this triangle.
Definition: PixelTriangle.h:266
const PixelPositionT< T > & point0() const
Returns the first corner point of this triangle.
Definition: PixelTriangle.h:227
const PixelPositionT< T > & point2() const
Returns the third corner point of this triangle.
Definition: PixelTriangle.h:239
T top() const
Returns the most top (including) position of this triangle.
Definition: PixelTriangle.h:252
const PixelPositionT< T > & operator[](const unsigned int index) const
Returns individual triangle corners.
Definition: PixelTriangle.h:323
bool isValid() const
Returns whether this triangle holds three valid corner points.
Definition: PixelTriangle.h:273
PixelTriangleT< T > & operator+=(const CV::PixelPositionT< T > &offset)
Shifts the corners of this triangle by a given offset (by adding the offset to each corner).
Definition: PixelTriangle.h:292
PixelTriangleT< T > operator+(const CV::PixelPositionT< T > &offset) const
Shifts the corners of the triangle by a given offset (by adding the offset to each corner) and return...
Definition: PixelTriangle.h:285
T left() const
Returns the most left (including) position of this triangle.
Definition: PixelTriangle.h:245
PixelTriangleT< T > & operator-=(const CV::PixelPositionT< T > &offset)
Shifts the corners of this triangle by a given offset (by subtracting the offset from each corner).
Definition: PixelTriangle.h:311
PixelPositionT< T > trianglePoints[3]
Three triangle corners.
Definition: PixelTriangle.h:198
PixelTriangleT< T > operator-(const CV::PixelPositionT< T > &offset) const
Shifts the corners of the triangle by a given offset (by subtracting the offset from each corner) and...
Definition: PixelTriangle.h:304
This class implements a 2D pixel position with pixel precision.
Definition: PixelPosition.h:65
bool isValid() const
Returns whether this pixel position object holds two valid parameters.
static constexpr int32_t round32(const T value)
Returns the rounded 32 bit integer value of a given value.
Definition: Numeric.h:2064
This class implements a 2D triangle with Cartesian coordinates.
Definition: Triangle2.h:81
const VectorT2< T > & point2() const
Returns the third triangle corner.
Definition: Triangle2.h:415
const VectorT2< T > & point0() const
Returns the first triangle corner.
Definition: Triangle2.h:403
const VectorT2< T > & point1() const
Returns the second triangle corner.
Definition: Triangle2.h:409
bool isValid() const
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point va...
Definition: Triangle2.h:806
T minmax(const T &lowerBoundary, const T &value, const T &upperBoundary)
This function fits a given parameter into a specified value range.
Definition: base/Utilities.h:903
PixelPositionT< unsigned int > PixelPosition
Definition of the default PixelPosition object with a data type allowing only positive coordinate val...
Definition: PixelPosition.h:27
std::vector< PixelTriangle > PixelTriangles
Definition of a vector holding pixel triangles (with positive coordinate values).
Definition: PixelTriangle.h:53
std::vector< PixelTriangleI > PixelTrianglesI
Definition of a vector holding pixel triangles (with positive and negative coordinate values).
Definition: PixelTriangle.h:60
PixelTriangleT< unsigned int > PixelTriangle
Definition of the default PixelTriangle object with a data type allowing only positive coordinate val...
Definition: PixelTriangle.h:32
PixelTriangleT< int > PixelTriangleI
Definition of a PixelTriangle object with a data type allowing positive and negative coordinate value...
Definition: PixelTriangle.h:46
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15