Ocean
|
This class implements a 2D triangle with Cartesian coordinates. More...
Public Member Functions | |
TriangleT2 ()=default | |
Creates a new 2D triangle object with default parameters. More... | |
TriangleT2 (const VectorT2< T > &point0, const VectorT2< T > &point1, const VectorT2< T > &point2) | |
Creates a new 2D triangle object by three corner positions. More... | |
const VectorT2< T > & | point0 () const |
Returns the first triangle corner. More... | |
const VectorT2< T > & | point1 () const |
Returns the second triangle corner. More... | |
const VectorT2< T > & | point2 () const |
Returns the third triangle corner. More... | |
T | sqrDistance01 () const |
Returns the square distance between point0 and point1. More... | |
T | sqrDistance02 () const |
Returns the square distance between point0 and point2. More... | |
T | sqrDistance12 () const |
Returns the square distance between point1 and point2. More... | |
T | left () const |
Returns the most left position of this triangle. More... | |
T | top () const |
Returns the most top position of this triangle. More... | |
T | right () const |
Returns the most right position of this triangle. More... | |
T | bottom () const |
Returns the most bottom position of this triangle. More... | |
T | area () const |
Returns the area of this triangle. More... | |
T | area2 () const |
Returns the square area of this triangle. More... | |
void | cosines (T &cosine0, T &cosine1, T &cosine2) const |
Calculates the three angle cosine values of the three triangle corners. More... | |
void | angles (T &angle0, T &angle1, T &angle2) const |
Calculates the three angles of the three triangle corners. More... | |
T | minAngle () const |
Returns the minimal angle of this triangle. More... | |
bool | allCosineBelow (const T cosValue) const |
Returns whether all cosine values of the three triangle corners are below or equal to a given threshold. More... | |
T | maxSqrLength () const |
Returns the maximal square side length of this triangle. More... | |
T | maxLength () const |
Returns the maximal side length of this triangle. More... | |
T | minSqrLength () const |
Returns the minimal square side length of this triangle. More... | |
T | minLength () const |
Returns the minimal side length of this triangle. More... | |
bool | isInside (const VectorT2< T > &point) const |
Returns whether a given point lies inside this triangle. More... | |
bool | isCounterClockwise (const bool yAxisDownwards=true) const |
Returns whether this triangles is defined in a counter clockwise manner. More... | |
VectorT2< T > | barycentric2cartesian (const VectorT3< T > &barycentric) const |
Returns the 2D Cartesian coordinate of a given barycentric coordinate defined in relation to this triangle. More... | |
VectorT3< T > | cartesian2barycentric (const VectorT2< T > &cartesian) const |
Returns the barycentric coordinate of a given 2D Cartesian coordinate defined in relation to this triangle. More... | |
VectorT3< T > | barycentricCircumcenter () const |
Returns the circumcenter for this triangle in barycentric coordinates. More... | |
VectorT2< T > | cartesianCircumcenter () const |
Returns the circumcenter for this triangle in Cartesian coordinates. More... | |
VectorT3< T > | barycentricIncenter () const |
Returns the incenter for this triangle in barycentric coordinates. More... | |
VectorT2< T > | cartesianIncenter () const |
Returns the incenter for this triangle in Cartesian coordinates. More... | |
bool | intersects (const TriangleT2< T > &triangle) const |
Returns whether this triangle has an intersection with a second triangle. More... | |
TriangleT2< T > | padded (const T padWidth) const |
Pad a given 2D triangle along each edge by a fixed value. More... | |
bool | isValid () const |
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point values). More... | |
const VectorT2< T > & | operator[] (const unsigned int index) const |
Returns individual triangle corners. More... | |
TriangleT2< T > | operator+ (const VectorT2< T > &offset) const |
Shifts the triangle by a given 2D vector (by adding the vector to all three corners of the triangle). More... | |
TriangleT2< T > & | operator+= (const VectorT2< T > &offset) |
Shifts the triangle by a given 2D vector (by adding the vector to all three corners of the triangle). More... | |
TriangleT2< T > | operator- (const VectorT2< T > &offset) const |
Shifts the triangle by a given 2D vector (by subtracting the vector from all three corners of the triangle). More... | |
TriangleT2< T > & | operator-= (const VectorT2< T > &offset) |
Shifts the triangle by a given 2D vector (by subtracting the vector from all three corners of the triangle). More... | |
Static Public Member Functions | |
static bool | isInside (const std::vector< TriangleT2< T >> &triangles, const VectorT2< T > &point) |
Returns whether a given point lies inside at least one of the given triangles. More... | |
static T | analyzePoints (const VectorT2< T > &point0, const VectorT2< T > &point1, const VectorT2< T > &point2, const bool yAxisDownwards) |
Analyses the layout of three 2D points forming either a triangle or a line. More... | |
Static Public Member Functions inherited from Ocean::TriangleT< T > | |
static bool | isBarycentricInside (const VectorT3< T > &barycentricPoint) |
Returns whether a given point, specified as barycentric coordinate, lies inside a triangle. More... | |
static bool | isValidBarycentric (const VectorT3< T > &barycentric, const T &epsilon=NumericT< T >::eps()) |
Returns whether the a barycentric coordinate is valid. More... | |
Private Attributes | |
VectorT2< T > | points_ [3] = {VectorT2<T>(T(0), T(0)), VectorT2<T>(T(0), T(0)), VectorT2<T>(T(0), T(0))} |
The corner positions. More... | |
T | barycentricFactor_ = T(0) |
Convert factor for barycentric coordinates. More... | |
This class implements a 2D triangle with Cartesian coordinates.
T | Data type used to represent coordinates |
|
default |
Creates a new 2D triangle object with default parameters.
|
inline |
Creates a new 2D triangle object by three corner positions.
point0 | First corner position |
point1 | Second corner position |
point2 | Third corner position |
bool Ocean::TriangleT2< T >::allCosineBelow | ( | const T | cosValue | ) | const |
Returns whether all cosine values of the three triangle corners are below or equal to a given threshold.
Thus, to test whether the minimal corner angle is equal to PI/8, then allCosineBelow(cos(PI/8)) has to be checked.
cosValue | Cosine threshold value |
|
static |
Analyses the layout of three 2D points forming either a triangle or a line.
The result of the function depends on the coordinate system in which the points are defined:
First coordinate system, Second coordinate system ------> x-axis ^ | | y-axis | | | y-axis | V ------> x-axis
point0 | The first point to be analyzed |
point1 | The first point to be analyzed |
point2 | The first point to be analyzed |
yAxisDownwards | True, if the y-axis points downwards and x-axis points to the right; False, if the y-axis points upwards and the x-axis points to the right |
|
inline |
Calculates the three angles of the three triangle corners.
Beware: Make sure that this triangle is valid before!
angle0 | Resulting angle corresponding to point0 in radian |
angle1 | Resulting angle corresponding to point1 in radian |
angle2 | Resulting angle corresponding to point2 in radian |
|
inline |
|
inline |
|
inline |
Returns the 2D Cartesian coordinate of a given barycentric coordinate defined in relation to this triangle.
barycentric | The Barycentric coordinate to convert to a Cartesian coordinate |
VectorT3< T > Ocean::TriangleT2< T >::barycentricCircumcenter |
Returns the circumcenter for this triangle in barycentric coordinates.
VectorT3< T > Ocean::TriangleT2< T >::barycentricIncenter |
Returns the incenter for this triangle in barycentric coordinates.
|
inline |
Returns the most bottom position of this triangle.
|
inline |
Returns the barycentric coordinate of a given 2D Cartesian coordinate defined in relation to this triangle.
cartesian | The Cartesian coordinate to convert to a barycentric coordinate |
|
inline |
Returns the circumcenter for this triangle in Cartesian coordinates.
|
inline |
Returns the incenter for this triangle in Cartesian coordinates.
void Ocean::TriangleT2< T >::cosines | ( | T & | cosine0, |
T & | cosine1, | ||
T & | cosine2 | ||
) | const |
Calculates the three angle cosine values of the three triangle corners.
Beware: Make sure that this triangle is valid before!
cosine0 | Resulting angle corresponding to point0 |
cosine1 | Resulting angle corresponding to point1 |
cosine2 | Resulting angle corresponding to point2 |
bool Ocean::TriangleT2< T >::intersects | ( | const TriangleT2< T > & | triangle | ) | const |
Returns whether this triangle has an intersection with a second triangle.
triangle | The second triangle to test |
|
inline |
Returns whether this triangles is defined in a counter clockwise manner.
The result of the function depends on the coordinate system in which the points are defined:
First coordinate system, Second coordinate system ------> x-axis ^ | | y-axis | | | y-axis | V ------> x-axis
yAxisDownwards | True, if the y-axis points downwards and x-axis points to the right; False, if the y-axis points upwards and the x-axis points to the right |
|
inlinestatic |
Returns whether a given point lies inside at least one of the given triangles.
triangles | The triangles that are tested |
point | The point to be checked |
|
inline |
Returns whether a given point lies inside this triangle.
point | The point to be checked |
|
inline |
Returns whether this triangle can provide valid barycentric coordinates (for 64 bit floating point values).
For 32 bit floating point values we simply check whether all three corners of the triangle are different.
|
inline |
Returns the most left position of this triangle.
|
inline |
Returns the maximal side length of this triangle.
|
inline |
Returns the maximal square side length of this triangle.
|
inline |
Returns the minimal angle of this triangle.
Beware: Make sure that this triangle is valid before!
|
inline |
Returns the minimal side length of this triangle.
|
inline |
Returns the minimal square side length of this triangle.
|
inline |
Shifts the triangle by a given 2D vector (by adding the vector to all three corners of the triangle).
offset | The offset vector to shift the triangle |
|
inline |
Shifts the triangle by a given 2D vector (by adding the vector to all three corners of the triangle).
offset | The offset vector to shift the triangle |
|
inline |
Shifts the triangle by a given 2D vector (by subtracting the vector from all three corners of the triangle).
offset | The offset vector to shift the triangle |
|
inline |
Shifts the triangle by a given 2D vector (by subtracting the vector from all three corners of the triangle).
offset | The offset vector to shift the triangle |
|
inline |
Returns individual triangle corners.
index | Index of the corner that is requested, with range [0, 2] |
TriangleT2< T > Ocean::TriangleT2< T >::padded | ( | const T | padWidth | ) | const |
Pad a given 2D triangle along each edge by a fixed value.
For a positive pad width, each side of the resulting triangle is shifted away from the triangle circumcenter along the perpendicular.
padWidth | Absolute amount to shift the triangle edges out from the triangle circumcenter, with range (-infinity, infinity); note that, in the case where the padding is negative with an absolute value smaller than the shortest distance from the circumcenter to an edge, then the triangle will flip its orientation |
|
inline |
Returns the first triangle corner.
|
inline |
Returns the second triangle corner.
|
inline |
Returns the third triangle corner.
|
inline |
Returns the most right position of this triangle.
|
inline |
Returns the square distance between point0 and point1.
|
inline |
Returns the square distance between point0 and point2.
|
inline |
Returns the square distance between point1 and point2.
|
inline |
Returns the most top position of this triangle.
|
private |
Convert factor for barycentric coordinates.
|
private |
The corner positions.