Trait truck_rendimpl::modeling::Homogeneous[]

pub trait Homogeneous<S>: VectorSpace<Scalar = S> where
    S: BaseFloat, 
{ type Vector: VectorSpace; type Point: EuclideanSpace; pub fn truncate(self) -> Self::Vector;
pub fn weight(self) -> S;
pub fn from_point(point: Self::Point) -> Self; pub fn to_point(self) -> Self::Point { ... }
pub fn rat_der(self, der: Self) -> <Self::Point as EuclideanSpace>::Diff { ... }
pub fn rat_der2(
        self,
        der: Self,
        der2: Self
    ) -> <Self::Point as EuclideanSpace>::Diff { ... }
pub fn rat_cross_der(
        &self,
        uder: Self,
        vder: Self,
        uvder: Self
    ) -> Self::Vector { ... } }

Homogeneous coordinate of an Euclidean space and a vector space.

Examples

use truck_base::cgmath64::*;
use truck_base::cgmath_extend_traits::*;
assert_eq!(Vector4::new(8.0, 6.0, 4.0, 2.0).truncate(), Vector3::new(8.0, 6.0, 4.0));
assert_eq!(Vector4::new(8.0, 6.0, 4.0, 2.0).weight(), 2.0);
assert_eq!(Vector4::new(8.0, 6.0, 4.0, 2.0).to_point(), Point3::new(4.0, 3.0, 2.0));
assert_eq!(Vector4::from_point(Point3::new(4.0, 3.0, 2.0)), Vector4::new(4.0, 3.0, 2.0, 1.0));

Associated Types

type Vector: VectorSpace

The tangent vector of Self::Point

type Point: EuclideanSpace

The point expressed by homogeneous coordinate

Loading content...

Required methods

pub fn truncate(self) -> Self::Vector

Returns the first dim - 1 components.

pub fn weight(self) -> S

Returns the last component.

pub fn from_point(point: Self::Point) -> Self

Returns homogeneous coordinate.

Loading content...

Provided methods

pub fn to_point(self) -> Self::Point

Returns the projection to the plane whose the last component is 1.0.

pub fn rat_der(self, der: Self) -> <Self::Point as EuclideanSpace>::Diff

Returns the derivation of the rational curve.

For a curve c(t) = (c_0(t), c_1(t), c_2(t), c_3(t)), returns the derivation of the projected curve (c_0 / c_3, c_1 / c_3, c_2 / c_3, 1.0).

Arguments

  • self - the point of the curve c(t)
  • der - the derivation c’(t) of the curve

Examples

use truck_base::cgmath64::*;
use truck_base::cgmath_extend_traits::*;
// calculate the derivation at t = 1.5
let t = 1.5;
// the curve: c(t) = (t^2, t^3, t^4, t)
let pt = Vector4::new(t * t, t * t * t, t * t * t * t, t);
// the derivation: c'(t) = (2t, 3t^2, 4t^3, 1)
let der = Vector4::new(2.0 * t, 3.0 * t * t, 4.0 * t * t * t, 1.0);
// the projected curve: \bar{c}(t) = (t, t^2, t^3, 1)
// the derivation of the proj'ed curve: \bar{c}'(t) = (1, 2t, 3t^2, 0)
let ans = Vector3::new(1.0, 2.0 * t, 3.0 * t * t);
assert_eq!(pt.rat_der(der), ans);

pub fn rat_der2(
    self,
    der: Self,
    der2: Self
) -> <Self::Point as EuclideanSpace>::Diff

Returns the 2nd-ord derivation of the rational curve.

For a curve c(t) = (c_0(t), c_1(t), c_2(t), c_3(t)), returns the 2nd ordered derivation of the projected curve (c_0 / c_3, c_1 / c_3, c_2 / c_3).

Arguments

  • self - the point of the curve c(t)
  • der - the derivation c’(t) of the curve
  • der2 - the 2nd ordered derivation c’’(t) of the curve

Examples

use truck_base::cgmath64::*;
use truck_base::cgmath_extend_traits::*;
// calculate the derivation at t = 1.5
let t = 1.5;
// the curve: c(t) = (t^2, t^3, t^4, t)
let pt = Vector4::new(t * t, t * t * t, t * t * t * t, t);
// the derivation: c'(t) = (2t, 3t^2, 4t^3, 1)
let der = Vector4::new(2.0 * t, 3.0 * t * t, 4.0 * t * t * t, 1.0);
// the 2nd ord. deri.: c''(t) = (2, 6t, 12t^2, 0)
let der2 = Vector4::new(2.0, 6.0 * t, 12.0 * t * t, 0.0);
// the projected curve: \bar{c}(t) = (t, t^2, t^3, 1)
// the derivation of the proj'ed curve: \bar{c}'(t) = (1, 2t, 3t^2, 0)
// the 2nd ord. deri. of the proj'ed curve: \bar{c}''(t) = (0, 2, 6t, 0)
let ans = Vector3::new(0.0, 2.0, 6.0 * t);
assert_eq!(pt.rat_der2(der, der2), ans);

pub fn rat_cross_der(&self, uder: Self, vder: Self, uvder: Self) -> Self::Vector

Returns the cross derivation of the rational surface.

For a surface s(u, v) = (s_0(u, v), s_1(u, v), s_2(u, v), s_3(u, v)), returns the derivation of the projected surface (s_0 / s_3, s_1 / s_3, s_2 / s_3) by both u and v.

Arguments

  • self - the point of the surface s(u, v)
  • uder - the u-derivation s_u(u, v) of the surface
  • vder - the v-derivation s_v(u, v) of the surface
  • uvder - the 2nd ordered derivation s_{uv}(u, v) of the surface

Examples

use truck_base::cgmath64::*;
// calculate the derivation at (u, v) = (1.0, 2.0).
let (u, v) = (1.0, 2.0);
// the curve: s(u, v) = (u^3 v^2, u^2 v^3, u v, u)
let pt = Vector4::new(
    u * u * u * v * v,
    u * u * v * v * v,
    u * v,
    u,
);
// the u-derivation: s_u(u, v) = (3u^2 v^2, 2u * v^3, v, 1)
let uder = Vector4::new(
    3.0 * u * u * v * v,
    2.0 * u * v * v * v,
    v,
    1.0,
);
// the v-derivation: s_v(u, v) = (2u^3 v, 3u^2 v^2, u, 0)
let vder = Vector4::new(
    2.0 * u * u * u * v,
    3.0 * u * u * v * v,
    u,
    0.0,
);
// s_{uv}(u, v) = (6u^2 v, 6u v^2, 1, 0)
let uvder = Vector4::new(6.0 * u * u * v, 6.0 * u * v * v, 1.0, 0.0);
// the projected surface: \bar{s}(u, v) = (u^2 v^2, u v^3, v)
// \bar{s}_u(u, v) = (2u v^2, v^3, 0)
// \bar{s}_v(u, v) = (2u^2 v, 3u v^2, 1)
// \bar{s}_{uv}(u, v) = (4uv, 3v^2, 0)
let ans = Vector3::new(4.0 * u * v, 3.0 * v * v, 0.0);
assert_eq!(pt.rat_cross_der(uder, vder, uvder), ans);
Loading content...

Implementations on Foreign Types

impl<S> Homogeneous<S> for Vector2<S> where
    S: BaseFloat, 

type Vector = Vector1<S>

type Point = Point1<S>

impl<S> Homogeneous<S> for Vector4<S> where
    S: BaseFloat, 

type Vector = Vector3<S>

type Point = Point3<S>

impl<S> Homogeneous<S> for Vector3<S> where
    S: BaseFloat, 

type Vector = Vector2<S>

type Point = Point2<S>

Loading content...

Implementors

Loading content...