public |
Inheritance Graph
graph BT
Triangle
click Triangle "classGeometry_1_1Triangle"
Description
Triangle defined by three vertices.
Author: Benjamin Eikel
Date: 2011-12-02
* c
* X
* / \
* / \
* X-----X
* a b
*
Creation
Triangle() Default constructor. |
|
Triangle(const vec_t & vertexA, const vec_t & vertexB, const vec_t & vertexC) Default constructor with vertices. |
Operators
bool | operator==(const Triangle & other) const Equality operator. |
Information
const vec_t & | getVertexA() const Return the first vertex. |
const vec_t & | getVertexB() const Return the second vertex. |
const vec_t & | getVertexC() const Return the third vertex. |
vec_t & | operator[](uint_fast8_t nr) |
const vec_t & | operator[](uint_fast8_t nr) const |
vec_t | getEdgeAB() const Return the first edge. |
vec_t | getEdgeBC() const Return the second edge. |
vec_t | getEdgeCA() const Return the third edge. |
vec_t | getEdgeBA() const Return the first reverse edge. |
vec_t | getEdgeCB() const Return the second reverse edge. |
vec_t | getEdgeAC() const Return the third reverse edge. |
Modification
void | setVertexA(const vec_t & v) Assign the first vertex. |
void | setVertexB(const vec_t & v) Assign the second vertex. |
void | setVertexC(const vec_t & v) Assign the third vertex. |
Calculation
value_t | calcArea() const |
vec_t | calcNormal() const |
vec_t | calcPoint( value_t u, value_t v) const |
vec_t | calcBarycentricCoordinates(const vec_t & p) const |
vec_t | calcCircumcenter() const |
vec_t | closestPoint(const vec_t & p, _Vec3 < value_t > & barycentric) const |
value_t | distanceSquared(const vec_t & p) const |
bool | isDegenerate() const |
Serialization
Public Types
typedef T_ | vec_t |
typedef typename vec_t::value_t | value_t |
Documentation
function
Geometry::Triangle::Triangle
public | inline |
Triangle( | ) |
Default constructor.
Defined in Geometry/Triangle.h:53
function
Geometry::Triangle::Triangle
public | inline |
Triangle( | const vec_t & | vertexA, |
const vec_t & | vertexB, | |
const vec_t & | vertexC | |
) |
Default constructor with vertices.
Defined in Geometry/Triangle.h:56
function
Geometry::Triangle::operator==
public | const | inline |
bool operator==( | const Triangle & | other ) const |
Equality operator.
Defined in Geometry/Triangle.h:63
function
Geometry::Triangle::getVertexA
public | const | inline |
const vec_t & getVertexA( | ) const |
Return the first vertex.
Defined in Geometry/Triangle.h:71
function
Geometry::Triangle::getVertexB
public | const | inline |
const vec_t & getVertexB( | ) const |
Return the second vertex.
Defined in Geometry/Triangle.h:75
function
Geometry::Triangle::getVertexC
public | const | inline |
const vec_t & getVertexC( | ) const |
Return the third vertex.
Defined in Geometry/Triangle.h:79
function
Geometry::Triangle::operator[]
public | inline |
vec_t & operator[]( | uint_fast8_t | nr ) |
array-access operator
Defined in Geometry/Triangle.h:84
function
Geometry::Triangle::operator[]
public | const | inline |
const vec_t & operator[]( | uint_fast8_t | nr ) const |
const array-access operator
Defined in Geometry/Triangle.h:90
function
Geometry::Triangle::getEdgeAB
public | const | inline |
vec_t getEdgeAB( | ) const |
Return the first edge.
Defined in Geometry/Triangle.h:96
function
Geometry::Triangle::getEdgeBC
public | const | inline |
vec_t getEdgeBC( | ) const |
Return the second edge.
Defined in Geometry/Triangle.h:100
function
Geometry::Triangle::getEdgeCA
public | const | inline |
vec_t getEdgeCA( | ) const |
Return the third edge.
Defined in Geometry/Triangle.h:104
function
Geometry::Triangle::getEdgeBA
public | const | inline |
vec_t getEdgeBA( | ) const |
Return the first reverse edge.
Defined in Geometry/Triangle.h:109
function
Geometry::Triangle::getEdgeCB
public | const | inline |
vec_t getEdgeCB( | ) const |
Return the second reverse edge.
Defined in Geometry/Triangle.h:113
function
Geometry::Triangle::getEdgeAC
public | const | inline |
vec_t getEdgeAC( | ) const |
Return the third reverse edge.
Defined in Geometry/Triangle.h:117
function
Geometry::Triangle::setVertexA
public | inline |
void setVertexA( | const vec_t & | v ) |
Assign the first vertex.
Defined in Geometry/Triangle.h:125
function
Geometry::Triangle::setVertexB
public | inline |
void setVertexB( | const vec_t & | v ) |
Assign the second vertex.
Defined in Geometry/Triangle.h:129
function
Geometry::Triangle::setVertexC
public | inline |
void setVertexC( | const vec_t & | v ) |
Assign the third vertex.
Defined in Geometry/Triangle.h:133
function
Geometry::Triangle::calcArea
public | const | inline |
value_t calcArea( | ) const |
Return the area of the triangle.
Returns
The area.
Defined in Geometry/Triangle.h:146
function
Geometry::Triangle::calcNormal
public | const | inline |
vec_t calcNormal( | ) const |
Return the unit length normal of this triangle.
Returns
Normal vector
Defined in Geometry/Triangle.h:156
function
Geometry::Triangle::calcPoint
public | const | inline |
vec_t calcPoint( | value_t | u, |
value_t | v | |
) const |
Calculate a point inside the triangle based on two barycentric coordinates with vertex A as origin.
Parameters
- u
- Barycentric coordinate in AB direction
- v
- Barycentric coordinate in AC direction
Returns
Point corresponding to the given barycentric coordinates
Defined in Geometry/Triangle.h:168
function
Geometry::Triangle::calcBarycentricCoordinates
public | const | inline |
vec_t calcBarycentricCoordinates( | const vec_t & | p ) const |
Calculate the barycentric coordinates of the given pointpwith reference to this triangle.
Parameters
- p
- Position in Cartesian coordinates that should be converted to barycentric coordinates
Returns
Barycentric coordinates
See also: http://science.kennesaw.edu/~plaval/math4490/barycentric.pdf
* c
* X
* /.\
* / . \
* / . \ alpha = A_a / A
* /A_b.A_a\ beta = A_b / A
* / .X. \ gamma = A_c / A
* / . p . \
* /. A_c .\
* X---------------X
* a b
*
Defined in Geometry/Triangle.h:192
function
Geometry::Triangle::calcCircumcenter
public | const | inline |
vec_t calcCircumcenter( | ) const |
Calculate the circumcenter of the triangle, i.e., the center of the sphere that is defined by the three triangle vertices.
See also: http://mathworld.wolfram.com/BarycentricCoordinates.html
Returns
Circumcenter of the triangle
Defined in Geometry/Triangle.h:222
function
Geometry::Triangle::closestPoint
public | const | inline |
vec_t closestPoint( | const vec_t & | p, |
_Vec3 < value_t > & | barycentric | |
) const |
Return the point of this triangle that has minimum distance to a pointp.
Implementation taken from Christer Ericson: Real-Time Collision Detection. Morgan Kaufmann, 2004.
Parameters
- p
- Query position
- barycentric
- Barycentric coordinates of the point inside the triangle
Returns
Point of this triangle with minimum distance to the query position
* c
* X result
* / \ | p
* / \ / _,--X
* / X--´
* / \
* / \
* X-----------X
* a b
*
Defined in Geometry/Triangle.h:254
function
Geometry::Triangle::distanceSquared
public | const | inline |
value_t distanceSquared( | const vec_t & | p ) const |
Calculate the squared distance of a pointpto this triangle.
Parameters
- p
- Query position
Returns
Squared distance ofpto the triangle
* c
* X
* / \ p
* / \ _,--X
* / X--´|
* / \ distance
* / \
* X-----------X
* a b
*
Defined in Geometry/Triangle.h:333
function
Geometry::Triangle::isDegenerate
public | const | inline |
bool isDegenerate( | ) const |
Check if the triangle is degenerate. The check is done by testing if the area of the triangle is nearly zero.
Returns
true
if this is a degenerate triangle,false
otherwise.
Defined in Geometry/Triangle.h:344
typedef
Geometry::Triangle::vec_t
public |
typedef T_ vec_t |
Defined in Geometry/Triangle.h:38
typedef
Geometry::Triangle::value_t
public |
typedef typename vec_t::value_t value_t |
Defined in Geometry/Triangle.h:39