Class triangle

Inheritance Relationships

Base Type

Class Documentation

class acme::triangle : public acme::entity

Triangle class container.

Triangle in 3D space. The triangle is defined by three arbitrary points.

Public Types

typedef std::shared_ptr<entity> ptr

Shared pointer to entity object.

typedef std::vector<ptr> vecptr

Vector of pointers to entity objects.

Public Functions

triangle(triangle const&) = default

Triangle copy constructor.

triangle(triangle&&) = default

Triangle move constructor.

triangle &operator=(const triangle&) = default

Triangle assignment operator.

triangle &operator=(triangle&&) = default

Triangle move assignment operator.

~triangle(void) override = default

Triangle class destructor.

triangle(void)

Triangle class constructor.

triangle(real vertex0_x, real vertex0_y, real vertex0_z, real vertex1_x, real vertex1_y, real vertex1_z, real vertex2_x, real vertex2_y, real vertex2_z)

Triangle class constructor.

Parameters
  • vertex0_x – Input x value of first triangle vertex

  • vertex0_y – Input y value of first triangle vertex

  • vertex0_z – Input z value of first triangle vertex

  • vertex1_x – Input x value of second triangle vertex

  • vertex1_y – Input y value of second triangle vertex

  • vertex1_z – Input z value of second triangle vertex

  • vertex2_x – Input x value of third triangle vertex

  • vertex2_y – Input y value of third triangle vertex

  • vertex2_z – Input z value of third triangle vertex

triangle(point const &vertex0, point const &vertex1, point const &vertex2)

Triangle class constructor.

Parameters
  • vertex0 – Input first triangle vertex point

  • vertex1 – Input second triangle vertex point

  • vertex2 – Input third triangle vertex point

triangle(point const vertex[3])

Triangle class constructor.

Parameters

vertex – Input triangle verices

bool isApprox(triangle const &triangle_in, real tolerance = EPSILON) const

Check if objects are (almost) equal.

Parameters
  • triangle_in – Input triangle object

  • tolerance – Tolerance

point const &vertex(integer i) const

Get i-th triangle vertex const reference.

Parameters

i – New triangle vertex

point &vertex(integer i)

Get i-th triangle vertex reference.

Parameters

i – New triangle vertex

point const &operator[](integer i) const

Get i-th triangle vertex const reference.

Parameters

i – New triangle vertex

point &operator[](integer i)

Get i-th triangle vertex reference.

Parameters

i – New triangle vertex

point centroid(void) const

Get triangle centroid.

segment edge(integer i) const

Get triangle edge created by i-th and j-th vertices.

Parameters

i – Triangle i-th vertex index

vec3 normal(void) const

Get triangle face normal (normalized vector)

void swap(integer i, integer j)

Swap triangle vertices.

Parameters
  • i – Triangle i-th vertex index

  • j – Triangle j-th vertex index

real perimeter(void) const

Calculate triangle perimeter length.

real area(void) const

Calculate triangle area.

void barycentric(point const &point_in, real &u, real &v, real &w) const

Compute barycentric coordinates (u,v,w) for point.

Parameters
  • point_in – Input point

  • u – Output barycentric coordinate u

  • v – Output barycentric coordinate v

  • w – Output barycentric coordinate w

plane layingPlane(void) const

Get triangle laying plane.

virtual void translate(vec3 const &vector_in) override

Translate triangle by vector.

Parameters

vector_in – Input translation vector

virtual void transform(affine const &affine_in) override

Transform triangle with affine transformation matrix.

Parameters

affine_in – 4x4 affine transformation matrix

bool isInside(point const &point_in, real tolerance = EPSILON) const

Check if a point lays inside the triangle.

Parameters
  • point_in – Query point

  • tolerance – Tolerance

virtual bool isDegenerated(real tolerance = EPSILON) const override

Check if triangle is degenerated to point or segment.

Parameters

tolerance – Tolerance

inline virtual integer level(void) const override

Return object hierarchical level.

inline virtual std::string type(void) const override

Return object type as string.

inline virtual bool isNone(void) const override

Check whether the object is no entity.

inline virtual bool isPoint(void) const override

Check whether the object is a point.

inline virtual bool isLine(void) const override

Check whether the object is a line.

inline virtual bool isRay(void) const override

Check whether the object is a ray.

inline virtual bool isPlane(void) const override

Check whether the object is a plane.

inline virtual bool isSegment(void) const override

Check whether the object is a segment.

inline virtual bool isTriangle(void) const override

Check whether the object is a triangle.

inline virtual bool isDisk(void) const override

Check whether the object is a disk.

inline virtual bool isBall(void) const override

Check whether the object is a ball.

inline virtual bool isClampable(void) const override

Check whether in the triangle is clampable.

inline virtual bool isNonClampable(void) const override

Check whether in the triangle is non-clampable.

virtual bool clamp(vec3 &min, vec3 &max) const override

Get minumum and maximum values along axes.

Parameters
  • min – Input minimum point

  • max – Input maximum point

virtual bool clamp(real &min_x, real &min_y, real &min_z, real &max_x, real &max_y, real &max_z) const override

Get minumum and maximum values along axes.

Parameters
  • min_x – Input x value of minimum point

  • min_y – Input y value of minimum point

  • min_z – Input z value of minimum point

  • max_x – Input x value of maximum point

  • max_y – Input y value of maximum point

  • max_z – Input z value of maximum point

void rotate(real angle, vec3 const &axis)

Rotate entity by a rotation angle around an arbitrary axis.

Parameters
  • angle – Input angle [rad]

  • axis – Input axis

inline bool isEntity(void) const

Check whether the object is an entity.