2D Triangles
This page has been automatically translated using the Google Translate API services. We are working on improving texts. Thank you for your understanding and patience.
Functions
Tri2D | tri2d (...) |
Tri2D | tri2d_v (...) |
void | tri2d_transform (...) |
real | tri2d_area (...) |
bool_t | tri2d_ccw (...) |
V2D | tri2d_centroid (...) |
Triangles are widely used in computational geometry, especially when performing certain calculations on polygons or surfaces. They are also the basis of most graphical APIs, so on many occasions we will need to approximate objects using triangles. The centroid is the equilibrium point found at the intersection of the medians (Figure 1).
- Use tri2df to compose a triangle.
- Use tri2d_transformf to apply a transformation.
- Use tri2d_centroidf to get the center of mass.
- Use tri2d_areaf to calculate the area.
tri2d ()
Triangle from its coordinates.
Tri2Df tri2df(const real32_t x0, const real32_t y0, const real32_t x1, const real32_t y1, const real32_t x2, const real32_t y2); Tri2Dd tri2dd(const real64_t x0, const real64_t y0, const real64_t x1, const real64_t y1, const real64_t x2, const real64_t y2); Tri2D Tri2D(const real x0, const real y0, const real x1, const real y1, const real x2, const real y2);
x0 | X coordinate of the first point. |
y0 | Y coordinate of the first point. |
x1 | X coordinate of the second point. |
y1 | Y coordinate of the second point. |
x2 | X coordinate of the third point. |
y2 | Y coordinate of the third point. |
Return
The triangle.
tri2d_v ()
Triangle from three points.
Tri2Df tri2d_vf(const V2Df *p0, const V2Df *p1, const V2Df *p2); Tri2Dd tri2d_vd(const V2Dd *p0, const V2Dd *p1, const V2Dd *p2); Tri2D Tri2D::v(const V2D *p0, const V2D *p1, const V2D *p2);
p0 | First point. |
p1 | Second point. |
p2 | Third point. |
Return
The triangle.
tri2d_transform ()
Apply a transformation to the triangle.
void tri2d_transformf(Tri2Df *tri, const T2Df *t2d); void tri2d_transformd(Tri2Dd *tri, const T2Dd *t2d); void Tri2D::transform(Tri2D *tri, const T2D *t2d);
tri | The triangle. |
t2d | Affine transformation. |
tri2d_area ()
Gets the area of the triangle.
real32_t tri2d_areaf(const Tri2Df *tri); real64_t tri2d_aread(const Tri2Dd *tri); real Tri2D::area(const Tri2D *tri);
tri | The triangle. |
Return
The area.
tri2d_ccw ()
Obtains the order of the travel of the points of the triangle.
bool_t tri2d_ccwf(const Tri2Df *tri); bool_t tri2d_ccwd(const Tri2Dd *tri); bool_t Tri2D::ccw(const Tri2D *tri);
tri | The triangle. |
Return
TRUE
counter-clockwise sense. FALSE
clockwise.
Remarks
See CW and CCW angles.
tri2d_centroid ()
Gets the centroid (center of mass) of the triangle.
V2Df tri2d_centroidf(const Tri2Df *tri); V2Dd tri2d_centroidd(const Tri2Dd *tri); V2D Tri2D::centroid(const Tri2D *tri);
tri | The triangle. |
Return
Center of mass.