#[repr(C)]pub struct Plane<N>{
pub normal: Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>,
pub bias: N,
}
Expand description
Plane encoding position with singed bias along unit normal.
Realizes plane equation a*x+b*y+c*z+d=0
with unit normal [x, y, z]
and signed bias d
.
Fields§
§normal: Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>
Plane unit normal.
bias: N
Signed bias along unit normal.
Implementations§
Source§impl<N> Plane<N>
impl<N> Plane<N>
Sourcepub fn new(
normal: Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>,
distance: N,
) -> Plane<N>
pub fn new( normal: Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>, distance: N, ) -> Plane<N>
Plane from unit normal
and signed distance
from the origin.
use trackball::{
nalgebra::{Point3, Vector3},
Plane,
};
// Plane intersecting y-axis at `5.0`.
let plane = Plane::new(Vector3::y_axis(), 5.0);
// Origin projected onto plane where plane intersects y-axis.
let point = plane.project_point(&Point3::origin());
assert_eq!(point, Point3::new(0.0, 5.0, 0.0));
// Bias is negated distance.
assert_eq!(plane.distance(), 5.0);
assert_eq!(plane.bias, -5.0);
// Plane intersecting y-axis at `-5.0`.
let plane = Plane::new(Vector3::y_axis(), -5.0);
// Origin projected onto plane where plane intersects y-axis.
let point = plane.project_point(&Point3::origin());
assert_eq!(point, Point3::new(0.0, -5.0, 0.0));
// Bias is negated distance.
assert_eq!(plane.distance(), -5.0);
assert_eq!(plane.bias, 5.0);
Sourcepub fn with_point(
normal: Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>,
point: &OPoint<N, Const<3>>,
) -> Plane<N>
pub fn with_point( normal: Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>, point: &OPoint<N, Const<3>>, ) -> Plane<N>
Plane from unit normal with point in plane.
Sourcepub fn distance_from(&self, point: &OPoint<N, Const<3>>) -> N
pub fn distance_from(&self, point: &OPoint<N, Const<3>>) -> N
Signed orthogonal distance from point
.
Sourcepub fn project_point(&self, point: &OPoint<N, Const<3>>) -> OPoint<N, Const<3>>
pub fn project_point(&self, point: &OPoint<N, Const<3>>) -> OPoint<N, Const<3>>
Projects point onto plane.
Sourcepub fn project_axis(
&self,
axis: &Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>,
) -> Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>
pub fn project_axis( &self, axis: &Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>, ) -> Unit<Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>>
Projects axis onto plane.
Sourcepub fn project_vector(
&self,
vector: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>,
) -> Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>
pub fn project_vector( &self, vector: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>, ) -> Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>
Projects vector onto plane.
Sourcepub fn angle_between(
&self,
a: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>,
b: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>,
) -> N
pub fn angle_between( &self, a: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>, b: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>, ) -> N
Singed angle from a
to b
where both vectors are in the plane.
Sourcepub fn rotate_by(self, rot: &Unit<Quaternion<N>>) -> Plane<N>
pub fn rotate_by(self, rot: &Unit<Quaternion<N>>) -> Plane<N>
Rotates plane.
Sourcepub fn translate_by(
self,
vec: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>,
) -> Plane<N>
pub fn translate_by( self, vec: &Matrix<N, Const<3>, Const<1>, ArrayStorage<N, 3, 1>>, ) -> Plane<N>
Translates plane.
Sourcepub fn transform_by(self, iso: &Isometry<N, Unit<Quaternion<N>>, 3>) -> Plane<N>
pub fn transform_by(self, iso: &Isometry<N, Unit<Quaternion<N>>, 3>) -> Plane<N>
Transforms plane by direct isometry, i.e., rotation followed by translation.
use core::f64::{
consts::FRAC_PI_2,
EPSILON,
};
use trackball::{
approx::AbsDiffEq,
nalgebra::{Isometry3, Vector3},
Plane,
};
// Plane intersecting y-axis at `5.0`.
let plane = Plane::new(Vector3::y_axis(), 5.0)
.transform_by(&Isometry3::new(
// Translation by after rotation.
Vector3::new(-5.0, 0.0, 0.0),
// Rotation by 90 degrees before translation.
Vector3::new(0.0, 0.0, FRAC_PI_2),
));
// Plane intersecting x-axis at `-10.0`.
assert!(plane.abs_diff_eq(&Plane::new(-Vector3::x_axis(), 10.0), EPSILON));
Trait Implementations§
Source§impl<N> AbsDiffEq for Plane<N>
impl<N> AbsDiffEq for Plane<N>
Source§fn default_epsilon() -> <N as AbsDiffEq>::Epsilon
fn default_epsilon() -> <N as AbsDiffEq>::Epsilon
The default tolerance to use when testing values that are close together. Read more
Source§fn abs_diff_eq(
&self,
other: &Plane<N>,
epsilon: <N as AbsDiffEq>::Epsilon,
) -> bool
fn abs_diff_eq( &self, other: &Plane<N>, epsilon: <N as AbsDiffEq>::Epsilon, ) -> bool
A test for equality that uses the absolute difference to compute the approximate
equality of two numbers.
Source§fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool
The inverse of
AbsDiffEq::abs_diff_eq
.Source§impl<'de, N> Deserialize<'de> for Plane<N>
impl<'de, N> Deserialize<'de> for Plane<N>
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Plane<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Plane<N>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<N> From<Reflection<N, Const<3>, ArrayStorage<N, 3, 1>>> for Plane<N>
impl<N> From<Reflection<N, Const<3>, ArrayStorage<N, 3, 1>>> for Plane<N>
Source§fn from(reflection: Reflection<N, Const<3>, ArrayStorage<N, 3, 1>>) -> Plane<N>
fn from(reflection: Reflection<N, Const<3>, ArrayStorage<N, 3, 1>>) -> Plane<N>
Converts to this type from the input type.
Source§impl<N> RelativeEq for Plane<N>
impl<N> RelativeEq for Plane<N>
Source§fn default_max_relative() -> <N as AbsDiffEq>::Epsilon
fn default_max_relative() -> <N as AbsDiffEq>::Epsilon
The default relative tolerance for testing values that are far-apart. Read more
Source§fn relative_eq(
&self,
other: &Plane<N>,
epsilon: <N as AbsDiffEq>::Epsilon,
max_relative: <N as AbsDiffEq>::Epsilon,
) -> bool
fn relative_eq( &self, other: &Plane<N>, epsilon: <N as AbsDiffEq>::Epsilon, max_relative: <N as AbsDiffEq>::Epsilon, ) -> bool
A test for equality that uses a relative comparison if the values are far apart.
Source§fn relative_ne(
&self,
other: &Rhs,
epsilon: Self::Epsilon,
max_relative: Self::Epsilon,
) -> bool
fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon, ) -> bool
The inverse of
RelativeEq::relative_eq
.Source§impl<N> Serialize for Plane<N>
impl<N> Serialize for Plane<N>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl<N> UlpsEq for Plane<N>
impl<N> UlpsEq for Plane<N>
Source§fn default_max_ulps() -> u32
fn default_max_ulps() -> u32
The default ULPs to tolerate when testing values that are far-apart. Read more
impl<N> Copy for Plane<N>
impl<N> Eq for Plane<N>
impl<N> StructuralPartialEq for Plane<N>
Auto Trait Implementations§
impl<N> Freeze for Plane<N>where
N: Freeze,
impl<N> RefUnwindSafe for Plane<N>where
N: RefUnwindSafe,
impl<N> Send for Plane<N>
impl<N> Sync for Plane<N>
impl<N> Unpin for Plane<N>where
N: Unpin,
impl<N> UnwindSafe for Plane<N>where
N: UnwindSafe,
Blanket Implementations§
Source§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
Source§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
Return the
T
ShaderType
for self
. When used in AsBindGroup
derives, it is safe to assume that all images in self
exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.