Struct fj_math::Plane

source ·
#[repr(C)]
pub struct Plane { /* private fields */ }
Expand description

A plane

Implementations§

Create a Plane from a parametric description

Access the origin of the plane

Examples found in repository?
src/plane.rs (line 44)
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    pub fn three_point_form(&self) -> [Point<3>; 3] {
        let a = self.origin();
        let b = self.origin() + self.u();
        let c = self.origin() + self.v();

        [a, b, c]
    }

    /// Convert the plane to constant-normal form
    pub fn constant_normal_form(&self) -> (Scalar, Vector<3>) {
        let normal = self.normal();
        let distance = normal.dot(&self.origin().coords);

        (distance, normal)
    }

    /// Determine whether the plane is parallel to the given vector
    pub fn is_parallel_to_vector(&self, vector: &Vector<3>) -> bool {
        self.normal().dot(vector) == Scalar::ZERO
    }

    /// Project a vector into the plane
    pub fn project_vector(&self, vector: &Vector<3>) -> Vector<2> {
        Vector::from([
            self.u().scalar_projection_onto(vector),
            self.v().scalar_projection_onto(vector),
        ])
    }

    /// Project a line into the plane
    pub fn project_line(&self, line: &Line<3>) -> Line<2> {
        let line_origin_relative_to_plane = line.origin() - self.origin();
        let line_origin_in_plane = Point {
            coords: Vector::from([
                self.u()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
                self.v()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
            ]),
        };

        let line_direction_in_plane = self.project_vector(&line.direction());

        Line::from_origin_and_direction(
            line_origin_in_plane,
            line_direction_in_plane,
        )
    }

Access the u-vector of the plane

Examples found in repository?
src/plane.rs (line 39)
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    pub fn normal(&self) -> Vector<3> {
        self.u().cross(&self.v()).normalize()
    }

    /// Convert the plane to three-point form
    pub fn three_point_form(&self) -> [Point<3>; 3] {
        let a = self.origin();
        let b = self.origin() + self.u();
        let c = self.origin() + self.v();

        [a, b, c]
    }

    /// Convert the plane to constant-normal form
    pub fn constant_normal_form(&self) -> (Scalar, Vector<3>) {
        let normal = self.normal();
        let distance = normal.dot(&self.origin().coords);

        (distance, normal)
    }

    /// Determine whether the plane is parallel to the given vector
    pub fn is_parallel_to_vector(&self, vector: &Vector<3>) -> bool {
        self.normal().dot(vector) == Scalar::ZERO
    }

    /// Project a vector into the plane
    pub fn project_vector(&self, vector: &Vector<3>) -> Vector<2> {
        Vector::from([
            self.u().scalar_projection_onto(vector),
            self.v().scalar_projection_onto(vector),
        ])
    }

    /// Project a line into the plane
    pub fn project_line(&self, line: &Line<3>) -> Line<2> {
        let line_origin_relative_to_plane = line.origin() - self.origin();
        let line_origin_in_plane = Point {
            coords: Vector::from([
                self.u()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
                self.v()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
            ]),
        };

        let line_direction_in_plane = self.project_vector(&line.direction());

        Line::from_origin_and_direction(
            line_origin_in_plane,
            line_direction_in_plane,
        )
    }

Access the v-vector of the plane

Examples found in repository?
src/plane.rs (line 39)
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    pub fn normal(&self) -> Vector<3> {
        self.u().cross(&self.v()).normalize()
    }

    /// Convert the plane to three-point form
    pub fn three_point_form(&self) -> [Point<3>; 3] {
        let a = self.origin();
        let b = self.origin() + self.u();
        let c = self.origin() + self.v();

        [a, b, c]
    }

    /// Convert the plane to constant-normal form
    pub fn constant_normal_form(&self) -> (Scalar, Vector<3>) {
        let normal = self.normal();
        let distance = normal.dot(&self.origin().coords);

        (distance, normal)
    }

    /// Determine whether the plane is parallel to the given vector
    pub fn is_parallel_to_vector(&self, vector: &Vector<3>) -> bool {
        self.normal().dot(vector) == Scalar::ZERO
    }

    /// Project a vector into the plane
    pub fn project_vector(&self, vector: &Vector<3>) -> Vector<2> {
        Vector::from([
            self.u().scalar_projection_onto(vector),
            self.v().scalar_projection_onto(vector),
        ])
    }

    /// Project a line into the plane
    pub fn project_line(&self, line: &Line<3>) -> Line<2> {
        let line_origin_relative_to_plane = line.origin() - self.origin();
        let line_origin_in_plane = Point {
            coords: Vector::from([
                self.u()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
                self.v()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
            ]),
        };

        let line_direction_in_plane = self.project_vector(&line.direction());

        Line::from_origin_and_direction(
            line_origin_in_plane,
            line_direction_in_plane,
        )
    }

Compute the normal of the plane

Examples found in repository?
src/plane.rs (line 53)
52
53
54
55
56
57
58
59
60
61
62
    pub fn constant_normal_form(&self) -> (Scalar, Vector<3>) {
        let normal = self.normal();
        let distance = normal.dot(&self.origin().coords);

        (distance, normal)
    }

    /// Determine whether the plane is parallel to the given vector
    pub fn is_parallel_to_vector(&self, vector: &Vector<3>) -> bool {
        self.normal().dot(vector) == Scalar::ZERO
    }

Convert the plane to three-point form

Convert the plane to constant-normal form

Determine whether the plane is parallel to the given vector

Project a vector into the plane

Examples found in repository?
src/plane.rs (line 84)
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
    pub fn project_line(&self, line: &Line<3>) -> Line<2> {
        let line_origin_relative_to_plane = line.origin() - self.origin();
        let line_origin_in_plane = Point {
            coords: Vector::from([
                self.u()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
                self.v()
                    .scalar_projection_onto(&line_origin_relative_to_plane),
            ]),
        };

        let line_direction_in_plane = self.project_vector(&line.direction());

        Line::from_origin_and_direction(
            line_origin_in_plane,
            line_direction_in_plane,
        )
    }

Project a line into the plane

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns the “default value” for a type. Read more
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==.
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.

Returns the argument unchanged.

Calls U::from(self).

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

Should always be Self
The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Checks if self is actually part of its subset T (and can be converted to it).
Use with care! Same as self.to_subset but without any property checks. Always succeeds.
The inclusion map: converts self to the equivalent element of its superset.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.