Template Class Triangle

Class Documentation

template<typename Vec = Eigen::Vector3f, typename Scalar = float>
class Triangle

Represents a triangle, allows for computation of barycentric coordinates.

Public Types

using BarycentricCoords = Vector3<Scalar>

Public Functions

Triangle(Vec a, Vec b, Vec c)

Construct a new Triangle object.

Parameters:
  • a – a point in clockwise order

  • b – a point in clockwise order

  • c – a point in clockwise order

Triangle(const std::array<Vec, 3UL> &array)

Construct a new Triangle object.

Parameters:

array – An array containing 3 Vec objects

inline Scalar area() const

Returns the precalculated area of this Triangle.

Returns:

Scalar Area of the Triangle

BarycentricCoords barycentric(Vec point) const

Calculates the barycentric coordinates of a point with respect to this triangle. Use point(BarycentricCoords) to do the opposite.

Parameters:

point

Returns:

BarycentricCoords

Vec point(BarycentricCoords barycentric) const

Calculates the cartesian coordinates from barycentric coordinates.

Parameters:

barycentric

Returns:

Vec

std::pair<Vec, Vec> getAABoundingBox() const

Returns the min and max corners of the axis aligned bounding box.

Returns:

std::pair<Vec, Vec> first is the min corner and second the max corner

bool contains(Vec point) const

Calculates if a point lies within the triangle.

Parameters:

point

Returns:

true

Returns:

false

Vec center() const

Calculates the triangles center.

Returns:

Vec

Vec normal() const

Calculates the triangles normal.

Returns:

Vec The normal of the triangle with length 1

inline Vec A() const
inline Vec B() const
inline Vec C() const
inline Vec AB() const
inline Vec BC() const
inline Vec CA() const