Triangle3

Struct Triangle3 

Source
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: Plane

Implementations§

Source§

impl Triangle3

Source

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.

Source

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 Clone for Triangle3

Source§

fn clone(&self) -> Triangle3

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Shape for Triangle3

Source§

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>

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>

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§

impl Copy for Triangle3

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.