Struct truck_geometry::specifieds::Plane[][src]

pub struct Plane { /* fields omitted */ }
Expand description

plane

Example

use truck_geometry::*;
 
// arbitary three points
let pt0 = Point3::new(0.0, 1.0, 2.0);
let pt1 = Point3::new(1.0, 1.0, 3.0);
let pt2 = Point3::new(0.0, 2.0, 3.0);
 
// Creates a plane
let plane: Plane = Plane::new(pt0, pt1, pt2);
// The origin of the plane is pt0.
assert_near!(plane.origin(), pt0);
// The u-axis of the plane is the vector from pt0 to pt1.
assert_near!(plane.u_axis(), pt1 - pt0);
// The v-axis of the plane is the vector from pt0 to pt2.
assert_near!(plane.v_axis(), pt2 - pt0);
// The normal is the normalized u-axis × v-axis
assert_near!(plane.normal(), (pt1 - pt0).cross(pt2 - pt0).normalize());

Implementations

Creates a new plane from three points.

Returns the origin

Returns the u-axis

Returns the v-axis

Returns the normal

Examples
use truck_geometry::*;
let plane = Plane::new(
    Point3::new(0.0, 0.0, 0.0),
    Point3::new(1.0, 0.0, 0.0),
    Point3::new(0.0, 1.0, 0.0),
);
assert_near!(plane.normal(), Vector3::unit_z());

Gets the parameter of pt in plane’s matrix.

Examples
use truck_geometry::*;
let plane = Plane::new(
    Point3::new(1.0, 2.0, 3.0),
    Point3::new(2.0, 1.0, 3.0),
    Point3::new(3.0, 4.0, -1.0),
);

let pt = Point3::new(2.1, -6.5, 4.7);
let prm = plane.get_parameter(pt);
let rev = plane.origin()
    + prm[0] * plane.u_axis()
    + prm[1] * plane.v_axis()
    + prm[2] * plane.normal();
assert_near!(pt, rev);

into B-spline surface

Examples
use truck_geometry::*;
let pt0 = Point3::new(0.0, 1.0, 2.0);
let pt1 = Point3::new(1.0, 1.0, 3.0);
let pt2 = Point3::new(0.0, 2.0, 3.0);
let plane: Plane = Plane::new(pt0, pt1, pt2);
let surface: BSplineSurface<Point3> = plane.into_bspline();
assert_eq!(surface.parameter_range(), ((0.0, 1.0), (0.0, 1.0)));

const N: usize = 100;
for i in 0..=N {
    for j in 0..=N {
        let u = i as f64 / N as f64;
        let v = j as f64 / N as f64;
        let res = surface.subs(u, v);
        let ans = plane.subs(u, v);
        assert_near!(ans, res);
    }
}

into NURBS surface

Examples
use truck_geometry::*;
let pt0 = Point3::new(0.0, 1.0, 2.0);
let pt1 = Point3::new(1.0, 1.0, 3.0);
let pt2 = Point3::new(0.0, 2.0, 3.0);
let plane: Plane = Plane::new(pt0, pt1, pt2);
let surface: NURBSSurface<Vector4> = plane.into_nurbs();
assert_eq!(surface.parameter_range(), ((0.0, 1.0), (0.0, 1.0)));

const N: usize = 100;
for i in 0..=N {
    for j in 0..=N {
        let u = i as f64 / N as f64;
        let v = j as f64 / N as f64;
        let res = surface.subs(u, v);
        let ans = plane.subs(u, v);
        assert_near!(ans, res);
    }
}

Trait Implementations

The range of the parameter of the surface.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

Returns whether the curve curve is included in the surface self.

Returns whether the curve curve is included in the surface self.

Returns the inverse.

Inverts self

Creates the surface division Read more

The surface is in the space of Self::Point.

The derivation vector of the curve.

Substitutes the parameter (u, v).

Returns the derivation by u.

Returns the derivation by v.

Returns the 2nd-order derivation by u.

Returns the 2nd-order derivation by both u and v.

Returns the 2nd-order derivation by v.

Returns the normal vector at (u, v).

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

point

curve => f64, surface => (f64, f64)

Search nearest parameter t such that self.subs(t) is nearest point.
Returns None if could not find such parameter. Read more

point

curve => f64, surface => (f64, f64)

Search parameter t such that self.subs(t) is near point.
Returns None if could not find such parameter. Read more

Serialize this value into the given Serde serializer. Read more

transform by trans.

transformed geometry by trans.

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

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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.