#[repr(C)]
pub struct Perspective3<T> { /* private fields */ }
Expand description

A 3D perspective projection stored as a homogeneous 4x4 matrix.

Implementations§

source§

impl<T> Perspective3<T>

source

pub const fn from_matrix_unchecked(matrix: Matrix4<T>) -> Self

Wraps the given matrix to interpret it as a 3D perspective matrix.

It is not checked whether or not the given matrix actually represents a perspective projection.

source§

impl<T: RealField> Perspective3<T>

source

pub fn new(aspect: T, fovy: T, znear: T, zfar: T) -> Self

Creates a new perspective matrix from the aspect ratio, y field of view, and near/far planes.

source

pub fn inverse(&self) -> Matrix4<T>

Retrieves the inverse of the underlying homogeneous matrix.

source

pub fn to_homogeneous(self) -> Matrix4<T>

Computes the corresponding homogeneous matrix.

source

pub fn as_matrix(&self) -> &Matrix4<T>

A reference to the underlying homogeneous transformation matrix.

source

pub fn as_projective(&self) -> &Projective3<T>

A reference to this transformation seen as a Projective3.

source

pub fn to_projective(self) -> Projective3<T>

This transformation seen as a Projective3.

source

pub fn into_inner(self) -> Matrix4<T>

Retrieves the underlying homogeneous matrix.

source

pub fn unwrap(self) -> Matrix4<T>

👎Deprecated: use .into_inner() instead

Retrieves the underlying homogeneous matrix. Deprecated: Use Perspective3::into_inner instead.

source

pub fn aspect(&self) -> T

Gets the width / height aspect ratio of the view frustum.

source

pub fn fovy(&self) -> T

Gets the y field of view of the view frustum.

source

pub fn znear(&self) -> T

Gets the near plane offset of the view frustum.

source

pub fn zfar(&self) -> T

Gets the far plane offset of the view frustum.

source

pub fn project_point(&self, p: &Point3<T>) -> Point3<T>

Projects a point. Faster than matrix multiplication.

source

pub fn unproject_point(&self, p: &Point3<T>) -> Point3<T>

Un-projects a point. Faster than multiplication by the matrix inverse.

source

pub fn project_vector<SB>(&self, p: &Vector<T, U3, SB>) -> Vector3<T>
where SB: Storage<T, U3>,

Projects a vector. Faster than matrix multiplication.

source

pub fn set_aspect(&mut self, aspect: T)

Updates this perspective matrix with a new width / height aspect ratio of the view frustum.

source

pub fn set_fovy(&mut self, fovy: T)

Updates this perspective with a new y field of view of the view frustum.

source

pub fn set_znear(&mut self, znear: T)

Updates this perspective matrix with a new near plane offset of the view frustum.

source

pub fn set_zfar(&mut self, zfar: T)

Updates this perspective matrix with a new far plane offset of the view frustum.

source

pub fn set_znear_and_zfar(&mut self, znear: T, zfar: T)

Updates this perspective matrix with new near and far plane offsets of the view frustum.

Trait Implementations§

source§

impl<T: RealField + Arbitrary> Arbitrary for Perspective3<T>

source§

fn arbitrary(g: &mut Gen) -> Self

Return an arbitrary value. Read more
source§

fn shrink(&self) -> Box<dyn Iterator<Item = Self>>

Return an iterator of values that are smaller than itself. Read more
source§

impl<T> Archive for Perspective3<T>
where T: Archive, Matrix4<T>: Archive<Archived = Matrix4<T::Archived>> + Archive,

§

type Archived = Perspective3<<T as Archive>::Archived>

The archived representation of this type. Read more
§

type Resolver = Perspective3Resolver<T>

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
source§

unsafe fn resolve( &self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived )

Creates the archived version of this value at the given position and writes it to the given output. Read more
source§

impl<__C: ?Sized, T> CheckBytes<__C> for Perspective3<T>
where Matrix4<T>: CheckBytes<__C>,

§

type Error = StructCheckError

The error that may result from checking the type.
source§

unsafe fn check_bytes<'__bytecheck>( value: *const Self, context: &mut __C ) -> Result<&'__bytecheck Self, StructCheckError>

Checks whether the given pointer points to a valid value within the given context. Read more
source§

impl<T: Clone> Clone for Perspective3<T>

source§

fn clone(&self) -> Perspective3<T>

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<T: RealField> Debug for Perspective3<T>

source§

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

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

impl<'a, T: RealField + Deserialize<'a>> Deserialize<'a> for Perspective3<T>

source§

fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
where Des: Deserializer<'a>,

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

impl<__D: Fallible + ?Sized, T> Deserialize<Perspective3<T>, __D> for Archived<Perspective3<T>>
where T: Archive, Matrix4<T>: Archive<Archived = Matrix4<T::Archived>> + Archive, Archived<Matrix4<T>>: Deserialize<Matrix4<T>, __D>,

source§

fn deserialize( &self, deserializer: &mut __D ) -> Result<Perspective3<T>, __D::Error>

Deserializes using the given deserializer
source§

impl<T: RealField> Distribution<Perspective3<T>> for Standard

source§

fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> Perspective3<T>

Generate an arbitrary random variate for testing purposes.

source§

fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>
where R: Rng, Self: Sized,

Create an iterator that generates random values of T, using rng as the source of randomness. Read more
source§

fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>
where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of Self through the closure F Read more
source§

impl<T: RealField> From<Perspective3<T>> for Matrix4<T>

source§

fn from(pers: Perspective3<T>) -> Self

Converts to this type from the input type.
source§

impl<T: RealField> PartialEq for Perspective3<T>

source§

fn eq(&self, right: &Self) -> bool

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

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

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

impl<__S: Fallible + ?Sized, T> Serialize<__S> for Perspective3<T>
where T: Archive, Matrix4<T>: Archive<Archived = Matrix4<T::Archived>> + Serialize<__S>,

source§

fn serialize(&self, serializer: &mut __S) -> Result<Self::Resolver, __S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
source§

impl<T: RealField + Serialize> Serialize for Perspective3<T>

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<T> Zeroable for Perspective3<T>

source§

fn zeroed() -> Self

source§

impl<T: Copy> Copy for Perspective3<T>

source§

impl<T: DeviceCopy> DeviceCopy for Perspective3<T>

source§

impl<T> Pod for Perspective3<T>
where T: RealField + Pod, Matrix4<T>: Pod,

Auto Trait Implementations§

§

impl<T> Freeze for Perspective3<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Perspective3<T>
where T: RefUnwindSafe,

§

impl<T> Send for Perspective3<T>
where T: Send,

§

impl<T> Sync for Perspective3<T>
where T: Sync,

§

impl<T> Unpin for Perspective3<T>
where T: Unpin,

§

impl<T> UnwindSafe for Perspective3<T>
where T: 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> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> ArchiveUnsized for T
where T: Archive,

§

type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike Archive, it may be unsized. Read more
§

type MetadataResolver = ()

The resolver for the metadata of this type. Read more
source§

unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata )

Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
source§

unsafe fn resolve_unsized( &self, from: usize, to: usize, resolver: Self::MetadataResolver, out: *mut RelPtr<Self::Archived, <isize as Archive>::Archived> )

Resolves a relative pointer to this value with the given from and to and writes it to the given output. 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> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
source§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
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> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, S> SerializeUnsized<S> for T
where T: Serialize<S>, S: Serializer + ?Sized,

source§

fn serialize_unsized( &self, serializer: &mut S ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
source§

fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>

Serializes the metadata for the given type.
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

unsafe 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

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

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>,

§

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>,

§

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> AnyBitPattern for T
where T: Pod,

source§

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

source§

impl<T> NoUninit for T
where T: Pod,

source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,