pub struct Triangle3 {
pub a: Vector3,
pub b: Vector3,
pub c: Vector3,
pub plane: Plane,
/* private fields */
}Fields§
§a: Vector3§b: Vector3§c: Vector3§plane: PlaneImplementations§
Source§impl Triangle3
impl Triangle3
Sourcepub fn new(a: &Vector3, b: &Vector3, c: &Vector3) -> Triangle3
pub fn new(a: &Vector3, b: &Vector3, c: &Vector3) -> Triangle3
Creates a new Triangle3 from three points.
§Arguments
a- A reference to the first vertex of the triangle.b- A reference to the second vertex of the triangle.c- A reference to the third vertex of the triangle. a, b, c must be defined in anticlockwise order (looked from the visible side)
§Returns
A new Triangle3 with the given vertices.
Sourcepub fn barycentric(&self, p: &Vector3) -> Vector3
pub fn barycentric(&self, p: &Vector3) -> Vector3
Returns the barycentric coordinates of a point in the triangle.
§Arguments
p- A reference to the point to calculate the barycentric coordinates.
§Returns
A new Vector3 with the barycentric coordinates of the point.
The coordinates are in the order of the vertices of the triangle (a, b, c).
The sum of the coordinates is always 1.
If the point is on the side of the triangle, one of the coordinates is zero.
If the point is inside the triangle, the coordinates are between 0 and 1.
The point (or any other value associated to the vertexes) is calculated as p = a * bar_a + b * bar_b + c * bar_c.
Trait Implementations§
Source§impl Shape for Triangle3
impl Shape for Triangle3
Source§fn normal(&self, _point: &Vector3) -> Vector3
fn normal(&self, _point: &Vector3) -> Vector3
Returns the normal (normalized) of the triangle at a given point.
Source§fn intersects(&self, line: &Line3) -> List<f64>
fn intersects(&self, line: &Line3) -> List<f64>
Returns the intersection of the triangle with a line. If the line is parallel to the triangle, it returns an empty list. If the line is in the plane of the triangle, it returns an empty list as a convention (because really, all lambdas fulfill). If the line intersects the triangle, it returns a list with the lambda value.
Source§fn closest_intersection(&self, line: &Line3) -> Option<Intersection>
fn closest_intersection(&self, line: &Line3) -> Option<Intersection>
Returns the intersection of the triangle with a line. If the line is parallel to the triangle, it returns an empty list. If the line is in the plane of the triangle, it returns an empty list as a convention (because really, all lambdas fulfill). If the line intersects the triangle, it returns a list with the lambda value.