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 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
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
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
.
transform by trans
.
transformed geometry by trans
.
Auto Trait Implementations
impl RefUnwindSafe for Plane
impl UnwindSafe for Plane
Blanket Implementations
Mutably borrows from an owned value. Read more