Saga
Saga Game Engine
Loading...
Searching...
No Matches
Saga::Geometry::Triangle Struct Reference

Represents a 3D triangle, equipped with some utility functions. More...

#include <triangle.h>

Public Member Functions

glm::vec3 toBarycentric (const glm::vec3 pos)
 Convert a point from cartesian to barycentric coordinate with respect to the current triangle.
 
glm::vec2 toUV (const glm::vec3 pos)
 Convert a point from cartesian to UV coordinate.
 
glm::vec3 getNormal ()
 Get the normal of this triangle.
 

Public Attributes

glm::vec3 a
 
glm::vec3 b
 
glm::vec3 c
 
std::optional< glm::vec3 > normal_cached
 

Detailed Description

Represents a 3D triangle, equipped with some utility functions.

Member Function Documentation

◆ getNormal()

glm::vec3 Saga::Geometry::Triangle::getNormal ( )

Get the normal of this triangle.

Returns
glm::vec3 the normal of this triangle in the direction of cross(b-a, c-a).

◆ toBarycentric()

glm::vec3 Saga::Geometry::Triangle::toBarycentric ( const glm::vec3  pos)

Convert a point from cartesian to barycentric coordinate with respect to the current triangle.

Parameters
posthe position in cartesian space.
Returns
glm::vec3 the barycentric coordinate (u,v,w) such that p projected onto the plane of a,b,c is = u * a + v * b + w * c.

◆ toUV()

glm::vec2 Saga::Geometry::Triangle::toUV ( const glm::vec3  pos)

Convert a point from cartesian to UV coordinate.

Parameters
posthe position in cartesian space.
Returns
glm::vec3 the barycentric coordinate (u,v,w) such that p = u * a + v * b + w * c.
Here is the call graph for this function:

Member Data Documentation

◆ a

glm::vec3 Saga::Geometry::Triangle::a

◆ b

glm::vec3 Saga::Geometry::Triangle::b

◆ c

glm::vec3 Saga::Geometry::Triangle::c

◆ normal_cached

std::optional<glm::vec3> Saga::Geometry::Triangle::normal_cached

The documentation for this struct was generated from the following files: