Struct truck_geometry::decorators::RevolutedCurve

source ·
pub struct RevolutedCurve<C> { /* private fields */ }
Expand description

surface constructed by revoluting a curve

§Examples

Revoluted sphere

use truck_geometry::prelude::*;
use std::f64::consts::PI;
let knot_vec = KnotVec::bezier_knot(2);
let control_points = vec![
    Vector4::new(1.0, 0.0, 0.0, 1.0),
    Vector4::new(0.0, 1.0, 0.0, 0.0),
    Vector4::new(-1.0, 0.0, 0.0, 1.0),
];
// upper half circle on xy-plane
let uhcircle = NurbsCurve::new(BSplineCurve::new(knot_vec, control_points));
// sphere constructed by revolute circle
let sphere = RevolutedCurve::by_revolution(
    uhcircle, Point3::origin(), Vector3::unit_x(),
);
const N: usize = 30;
for i in 0..=N {
    for j in 0..=N {
        let u = i as f64 / N as f64;
        let v = 2.0 * PI * j as f64 / N as f64;
        let pt: Vector3 = sphere.subs(u, v).to_vec();
        assert_near2!(pt.magnitude2(), 1.0);
        assert_near!(pt, sphere.normal(u, v));
    }
}

Implementations§

source§

impl<C> RevolutedCurve<C>

source

pub fn by_revolution(curve: C, origin: Point3, axis: Vector3) -> Self

Creates a surface by revoluting a curve.

source

pub const fn entity_curve(&self) -> &C

Returns the curve before revoluted.

source

pub fn into_entity_curve(self) -> C

Into the curve before revoluted.

source

pub const fn origin(&self) -> Point3

Returns origin of revolution

source

pub const fn axis(&self) -> Vector3

Returns axis of revolution

source§

impl<C: ParametricCurve3D + BoundedCurve> RevolutedCurve<C>

source

pub fn is_front_fixed(&self) -> bool

Returns true if the front point of the curve is on the axis of rotation.

§Examples
use truck_geometry::prelude::*;
let line = BSplineCurve::new(
    KnotVec::bezier_knot(1),
    vec![Point3::new(0.0, 0.0, 0.0), Point3::new(0.0, 0.0, 1.0)],
);
let surface0 = RevolutedCurve::by_revolution(line.clone(), Point3::origin(), Vector3::unit_y());
assert!(surface0.is_front_fixed());
let surface1 = RevolutedCurve::by_revolution(line, Point3::new(1.0, 0.0, 0.0), Vector3::unit_y());
assert!(!surface1.is_front_fixed());
source

pub fn is_back_fixed(&self) -> bool

Returns true if the back point of the curve is on the axis of rotation.

§Examples
use truck_geometry::prelude::*;
let line = BSplineCurve::new(
    KnotVec::bezier_knot(1),
    vec![Point3::new(0.0, 0.0, 1.0), Point3::new(0.0, 0.0, 0.0)],
);
let surface0 = RevolutedCurve::by_revolution(line.clone(), Point3::origin(), Vector3::unit_y());
assert!(surface0.is_back_fixed());
let surface1 = RevolutedCurve::by_revolution(line, Point3::new(1.0, 0.0, 0.0), Vector3::unit_y());
assert!(!surface1.is_back_fixed());

Trait Implementations§

source§

impl<C: ParametricCurve3D + BoundedCurve> BoundedSurface for RevolutedCurve<C>

source§

fn range_tuple(&self) -> ((f64, f64), (f64, f64))

Return the ends of parameter_range by tuple.
source§

impl<C: Clone> Clone for RevolutedCurve<C>

source§

fn clone(&self) -> RevolutedCurve<C>

Returns a copy 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<C: Debug> Debug for RevolutedCurve<C>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, C> Deserialize<'de> for RevolutedCurve<C>
where C: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a> IncludeCurve<BSplineCurve<Point3<f64>>> for RevolutedCurve<&'a BSplineCurve<Point3>>

source§

fn include(&self, curve: &BSplineCurve<Point3>) -> bool

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

impl<'a> IncludeCurve<BSplineCurve<Point3<f64>>> for RevolutedCurve<&'a NurbsCurve<Vector4>>

source§

fn include(&self, curve: &BSplineCurve<Point3>) -> bool

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

impl IncludeCurve<BSplineCurve<Point3<f64>>> for RevolutedCurve<BSplineCurve<Point3>>

source§

fn include(&self, curve: &BSplineCurve<Point3>) -> bool

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

impl IncludeCurve<BSplineCurve<Point3<f64>>> for RevolutedCurve<NurbsCurve<Vector4>>

source§

fn include(&self, curve: &BSplineCurve<Point3>) -> bool

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

impl<'a> IncludeCurve<NurbsCurve<Vector4<f64>>> for RevolutedCurve<&'a BSplineCurve<Point3>>

source§

fn include(&self, curve: &NurbsCurve<Vector4>) -> bool

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

impl<'a> IncludeCurve<NurbsCurve<Vector4<f64>>> for RevolutedCurve<&'a NurbsCurve<Vector4>>

source§

fn include(&self, curve: &NurbsCurve<Vector4>) -> bool

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

impl IncludeCurve<NurbsCurve<Vector4<f64>>> for RevolutedCurve<BSplineCurve<Point3>>

source§

fn include(&self, curve: &NurbsCurve<Vector4>) -> bool

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

impl IncludeCurve<NurbsCurve<Vector4<f64>>> for RevolutedCurve<NurbsCurve<Vector4>>

source§

fn include(&self, curve: &NurbsCurve<Vector4>) -> bool

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

impl<C: Clone> Invertible for RevolutedCurve<C>

source§

fn invert(&mut self)

Inverts self
source§

fn inverse(&self) -> Self

Returns the inverse.
source§

impl<C> ParameterDivision2D for RevolutedCurve<C>

source§

fn parameter_division( &self, (urange, vrange): ((f64, f64), (f64, f64)), tol: f64, ) -> (Vec<f64>, Vec<f64>)

Creates the surface division Read more
source§

impl<C: ParametricCurve3D> ParametricSurface for RevolutedCurve<C>

source§

type Point = Point3<f64>

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

type Vector = Vector3<f64>

The derivation vector of the curve.
source§

fn subs(&self, u: f64, v: f64) -> Point3

Substitutes the parameter (u, v).
source§

fn uder(&self, u: f64, v: f64) -> Vector3

Returns the derivation by u.
source§

fn vder(&self, u: f64, v: f64) -> Vector3

Returns the derivation by v.
source§

fn uuder(&self, u: f64, v: f64) -> Vector3

Returns the 2nd-order derivation by u.
source§

fn vvder(&self, u: f64, v: f64) -> Vector3

Returns the 2nd-order derivation by v.
source§

fn uvder(&self, u: f64, v: f64) -> Vector3

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

fn parameter_range(&self) -> (ParameterRange, ParameterRange)

The range of the parameter of the surface.
source§

fn u_period(&self) -> Option<f64>

None in default; Some(period) if periodic w.r.t. parameter u.
source§

fn v_period(&self) -> Option<f64>

None in default; Some(period) if periodic w.r.t. parameter v.
source§

fn try_range_tuple(&self) -> (Option<(f64, f64)>, Option<(f64, f64)>)

Return the ends of parameter_range by tuple. If the range is unbounded, return `None``.
source§

impl<C: ParametricCurve3D + BoundedCurve> ParametricSurface3D for RevolutedCurve<C>

source§

fn normal(&self, u: f64, v: f64) -> Vector3

Returns the normal vector at (u, v).
source§

impl<C: PartialEq> PartialEq for RevolutedCurve<C>

source§

fn eq(&self, other: &RevolutedCurve<C>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<C: ParametricCurve3D + BoundedCurve> SearchNearestParameter<D2> for RevolutedCurve<C>

source§

type Point = Point3<f64>

point
source§

fn search_nearest_parameter<H: Into<SPHint2D>>( &self, point: Point3, hint: H, trials: usize, ) -> Option<(f64, f64)>

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

impl<C: ParametricCurve3D + BoundedCurve> SearchParameter<D2> for RevolutedCurve<C>

source§

type Point = Point3<f64>

point
source§

fn search_parameter<H: Into<SPHint2D>>( &self, point: Point3, hint: H, trials: usize, ) -> Option<(f64, f64)>

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

impl<C> Serialize for RevolutedCurve<C>
where C: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<C: Copy> Copy for RevolutedCurve<C>

source§

impl<C> StructuralPartialEq for RevolutedCurve<C>

Auto Trait Implementations§

§

impl<C> Freeze for RevolutedCurve<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for RevolutedCurve<C>
where C: RefUnwindSafe,

§

impl<C> Send for RevolutedCurve<C>
where C: Send,

§

impl<C> Sync for RevolutedCurve<C>
where C: Sync,

§

impl<C> Unpin for RevolutedCurve<C>
where C: Unpin,

§

impl<C> UnwindSafe for RevolutedCurve<C>
where C: UnwindSafe,

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,