Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cTriangle3f Class Reference

#include <cTriangle3.h>

Public Types

typedef float DVALUE_t
 Dimension value type. More...
 

Public Member Functions

 cTriangle3f () noexcept
 
 cTriangle3f (const cVector3f *p)
 
 cTriangle3f (const cVector3f &a, const cVector3f &b, const cVector3f &c) noexcept
 
bool operator== (const cTriangle3f &other) const noexcept
 
bool operator!= (const cTriangle3f &other) const noexcept
 
bool isDegenerate () const noexcept
 
cPlanef get_Plane () const
 
cVector3f get_Normal () const
 
cVector3f get_Center () const
 
bool isFrontFacing (const cVector3f &vLookDir) const
 
bool isPointInside (const cVector3f &p) const
 
bool isPointInsideFast (const cVector3f &p) const
 
bool isOnSameSide (const cVector3f &p1, const cVector3f &p2, const cVector3f &a, const cVector3f &b) const
 
bool getIntersectionOfPlaneWithLine (const cVector3f &linePoint, const cVector3f &lineVect, cVector3f &outIntersection) const
 
bool getIntersectionWithLine (const cVector3f &linePoint, const cVector3f &lineVect, cVector3f &outIntersection) const
 
cVector3f GetBaryCentric (DVALUE_t f, DVALUE_t g) const
 
void setTri (const cVector3f *p)
 
void setTri (const cVector3f &a, const cVector3f &b, const cVector3f &c)
 
void TransformCoords (const cMatrix4x4f &mMatrix)
 
void MultV (const cVector3f vMult)
 
void DivV (const cVector3f vMult)
 
 UNITTEST_FRIEND (cTriangle3)
 

Public Attributes

cVector3f m_aPt [3]
 three verts/points of the triangle. DVALUE_t. More...
 

Detailed Description

a triangle in 3d space. 3 float 3d points. assume this is a clockwise=front triangle for purposes of front/back/normal. DX is backward of this ?? Normal 3d meshes use vertex arrays and indexes for more efficiency.

Member Typedef Documentation

◆ DVALUE_t

Dimension value type.

Constructor & Destructor Documentation

◆ cTriangle3f() [1/3]

GrayLib::cTriangle3f::cTriangle3f ( )
inlinenoexcept

◆ cTriangle3f() [2/3]

GrayLib::cTriangle3f::cTriangle3f ( const cVector3f p)
inline

◆ cTriangle3f() [3/3]

GrayLib::cTriangle3f::cTriangle3f ( const cVector3f a,
const cVector3f b,
const cVector3f c 
)
inlinenoexcept

Member Function Documentation

◆ DivV()

void GrayLib::cTriangle3f::DivV ( const cVector3f  vMult)
inline

◆ get_Center()

cVector3f GrayLib::cTriangle3f::get_Center ( ) const
inline

get center average point for the triangle.

◆ get_Normal()

cVector3f GrayLib::cTriangle3f::get_Normal ( ) const
inline

assume this is a clockwise=front triangle for purposes of front/back/normal

Note
The normal is not normalized.
Returns
the normal of the triangle.

◆ get_Plane()

cPlanef GrayLib::cTriangle3f::get_Plane ( ) const
inline
Returns
the plane of this triangle.

◆ GetBaryCentric()

cVector3f GrayLib::cTriangle3f::GetBaryCentric ( DVALUE_t  f,
DVALUE_t  g 
) const
inline

◆ getIntersectionOfPlaneWithLine()

bool GrayLib::cTriangle3f::getIntersectionOfPlaneWithLine ( const cVector3f linePoint,
const cVector3f lineVect,
cVector3f outIntersection 
) const
inline

Calculates the intersection between a 3d line and the plane the triangle is on.

  • lineVect: Vector of the line to intersect with. linePoint: Point of the line to intersect with. outIntersection: Place to store the intersection point, if there is one.
    Returns
    true if there was an intersection, false if there was not.

◆ getIntersectionWithLine()

bool GrayLib::cTriangle3f::getIntersectionWithLine ( const cVector3f linePoint,
const cVector3f lineVect,
cVector3f outIntersection 
) const
inline

an intersection with a 3d line segment.

Note
points are returned as intersection, which are on the line, but not between the start and end point of the line. If you want the returned point be between start and end, please use getIntersectionWithLimitedLine().
  • lineVect: Vector of the line to intersect with. linePoint: Point of the line to intersect with. outIntersection: Place to store the intersection point, if there is one.
Returns
Returns true if there was an intersection, false if there was not.

◆ isDegenerate()

bool GrayLib::cTriangle3f::isDegenerate ( ) const
inlinenoexcept

Empty triangles are bad. Degenerate triangles.

◆ isFrontFacing()

bool GrayLib::cTriangle3f::isFrontFacing ( const cVector3f vLookDir) const
inline

Returns if the triangle is front of backfacing.

  • vLookDir: Look direction.
    Returns
    true if the plane is front facing, which mean it would be visible, and false if it is backfacing. assume this is a clockwise=front triangle for purposes of front/back/normal

◆ isOnSameSide()

bool GrayLib::cTriangle3f::isOnSameSide ( const cVector3f p1,
const cVector3f p2,
const cVector3f a,
const cVector3f b 
) const
inline

◆ isPointInside()

bool GrayLib::cTriangle3f::isPointInside ( const cVector3f p) const
inline

a point is inside the triangle?

  • p: Point to test. Assumes that this point is already on the plane of the triangle.
    Returns
    true if the point is inside the triangle, otherwise false.

◆ isPointInsideFast()

bool GrayLib::cTriangle3f::isPointInsideFast ( const cVector3f p) const
inline

a point is inside the triangle. This method is an implementation of the example used in a paper by Kasper Fauerby original written by Keidy from Mr-Gamemaker.

  • p = Point to test. Assumes that this point is already on the plane of the triangle.
    Returns
    true if the point is inside the triangle, otherwise false.

◆ MultV()

void GrayLib::cTriangle3f::MultV ( const cVector3f  vMult)
inline

◆ operator!=()

bool GrayLib::cTriangle3f::operator!= ( const cTriangle3f other) const
inlinenoexcept

◆ operator==()

bool GrayLib::cTriangle3f::operator== ( const cTriangle3f other) const
inlinenoexcept

◆ setTri() [1/2]

void GrayLib::cTriangle3f::setTri ( const cVector3f a,
const cVector3f b,
const cVector3f c 
)
inline

◆ setTri() [2/2]

void GrayLib::cTriangle3f::setTri ( const cVector3f p)
inline

◆ TransformCoords()

void GrayLib::cTriangle3f::TransformCoords ( const cMatrix4x4f mMatrix)
inline

◆ UNITTEST_FRIEND()

GrayLib::cTriangle3f::UNITTEST_FRIEND ( cTriangle3  )

Member Data Documentation

◆ m_aPt

cVector3f GrayLib::cTriangle3f::m_aPt[3]

three verts/points of the triangle. DVALUE_t.


The documentation for this class was generated from the following file: