Trait GenericVector3

Source
pub trait GenericVector3:
    HasXYZ
    + Approx
    + PartialEq
    + AddAssign
    + SubAssign
    + Neg<Output = Self>
    + Sub<Self, Output = Self>
    + Mul<Self::Scalar, Output = Self>
    + Div<Self::Scalar, Output = Self>
    + Add<Self, Output = Self> {
    type Affine: Affine3D<Vector3 = Self>;
    type Aabb: Aabb3<Vector = Self>;
    type Vector2: GenericVector2<Scalar = Self::Scalar, Vector3 = Self>;

Show 15 methods // Required methods fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self; fn splat(value: Self::Scalar) -> Self; fn to_2d(self) -> Self::Vector2; fn magnitude(self) -> Self::Scalar; fn magnitude_sq(self) -> Self::Scalar; fn dot(self, other: Self) -> Self::Scalar; fn cross(self, rhs: Self) -> Self; fn normalize(self) -> Self; fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>; fn distance(self, other: Self) -> Self::Scalar; fn distance_sq(self, rhs: Self) -> Self::Scalar; fn min(self, rhs: Self) -> Self; fn max(self, rhs: Self) -> Self; fn clamp(self, min: Self, max: Self) -> Self; fn is_finite(self) -> bool;
}
Expand description

A generic three-dimensional vector trait.

The GenericVector3 trait abstracts over three-dimensional vectors, allowing for easy transition between different precisions (e.g., f32 and f64) without necessitating significant codebase modifications. It provides the common operations one would expect for 3D vectors, such as dot products, cross products, and normalization.

Implementors of this trait can benefit from the ability to switch between different precision representations seamlessly, making it ideal for applications where varying precision levels might be desirable at different stages or configurations.

The associated Scalar type represents the scalar type (e.g., f32 or f64) used by the vector, and Vector2 is the corresponding two-dimensional vector type.

Note: The actual trait functionality might vary based on the concrete implementations.

Required Associated Types§

Source

type Affine: Affine3D<Vector3 = Self>

Source

type Aabb: Aabb3<Vector = Self>

Source

type Vector2: GenericVector2<Scalar = Self::Scalar, Vector3 = Self>

Required Methods§

Source

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source

fn splat(value: Self::Scalar) -> Self

Source

fn to_2d(self) -> Self::Vector2

Source

fn magnitude(self) -> Self::Scalar

Source

fn magnitude_sq(self) -> Self::Scalar

Source

fn dot(self, other: Self) -> Self::Scalar

Source

fn cross(self, rhs: Self) -> Self

Source

fn normalize(self) -> Self

Source

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source

fn distance(self, other: Self) -> Self::Scalar

Source

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source

fn min(self, rhs: Self) -> Self

Source

fn max(self, rhs: Self) -> Self

Source

fn clamp(self, min: Self, max: Self) -> Self

Clamps the vector’s components to be within the range defined by min and max.

§Note

This implementation does not follow nalgebra’s convention for clamp. In nalgebra, clamp is symmetric around zero. In this implementation, clamp ensures that self is bounded by min and max in a non-symmetric way: self.min(max).max(min).

Source

fn is_finite(self) -> bool

returns false on all inf or NaN values

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl GenericVector3 for Vector3<f32>

Source§

type Vector2 = Vector2<f32>

Source§

type Affine = Matrix4<f32>

Source§

type Aabb = Aabb3<f32>

Source§

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source§

fn splat(value: Self::Scalar) -> Self

Source§

fn to_2d(self) -> Self::Vector2

Source§

fn magnitude(self) -> Self::Scalar

Source§

fn magnitude_sq(self) -> Self::Scalar

Source§

fn normalize(self) -> Self

Source§

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source§

fn dot(self, rhs: Self) -> Self::Scalar

Source§

fn cross(self, rhs: Self) -> Self

Source§

fn distance(self, rhs: Self) -> Self::Scalar

Source§

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source§

fn min(self, rhs: Self) -> Self

Source§

fn max(self, rhs: Self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn is_finite(self) -> bool

Source§

impl GenericVector3 for Vector3<f64>

Source§

type Vector2 = Vector2<f64>

Source§

type Affine = Matrix4<f64>

Source§

type Aabb = Aabb3<f64>

Source§

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source§

fn splat(value: Self::Scalar) -> Self

Source§

fn to_2d(self) -> Self::Vector2

Source§

fn magnitude(self) -> Self::Scalar

Source§

fn magnitude_sq(self) -> Self::Scalar

Source§

fn normalize(self) -> Self

Source§

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source§

fn dot(self, rhs: Self) -> Self::Scalar

Source§

fn cross(self, rhs: Self) -> Self

Source§

fn distance(self, rhs: Self) -> Self::Scalar

Source§

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source§

fn min(self, rhs: Self) -> Self

Source§

fn max(self, rhs: Self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn is_finite(self) -> bool

Source§

impl GenericVector3 for Vec3A

Source§

type Vector2 = Vec2A

Source§

type Aabb = Aabb3A

Source§

type Affine = Mat4A

Source§

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source§

fn splat(value: Self::Scalar) -> Self

Source§

fn to_2d(self) -> Self::Vector2

Source§

fn magnitude(self) -> Self::Scalar

Source§

fn magnitude_sq(self) -> Self::Scalar

Source§

fn dot(self, other: Self) -> Self::Scalar

Source§

fn cross(self, rhs: Self) -> Self

Source§

fn normalize(self) -> Self

Source§

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source§

fn distance(self, other: Self) -> Self::Scalar

Source§

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source§

fn min(self, rhs: Self) -> Self

Source§

fn max(self, rhs: Self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn is_finite(self) -> bool

Source§

impl GenericVector3 for Vec3

Source§

type Affine = Mat4

Source§

type Aabb = Aabb3

Source§

type Vector2 = Vec2

Source§

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source§

fn to_2d(self) -> Self::Vector2

Source§

fn splat(value: Self::Scalar) -> Self

Source§

fn magnitude(self) -> Self::Scalar

Source§

fn magnitude_sq(self) -> Self::Scalar

Source§

fn normalize(self) -> Self

Source§

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source§

fn dot(self, rhs: Self) -> Self::Scalar

Source§

fn cross(self, rhs: Self) -> Self

Source§

fn distance(self, rhs: Self) -> Self::Scalar

Source§

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source§

fn min(self, rhs: Self) -> Self

Source§

fn max(self, rhs: Self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn is_finite(self) -> bool

Source§

impl GenericVector3 for DVec3

Source§

type Affine = DMat4

Source§

type Aabb = DAabb3

Source§

type Vector2 = DVec2

Source§

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source§

fn to_2d(self) -> Self::Vector2

Source§

fn splat(value: Self::Scalar) -> Self

Source§

fn magnitude(self) -> Self::Scalar

Source§

fn magnitude_sq(self) -> Self::Scalar

Source§

fn normalize(self) -> Self

Source§

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source§

fn dot(self, rhs: Self) -> Self::Scalar

Source§

fn cross(self, rhs: Self) -> Self

Source§

fn distance(self, rhs: Self) -> Self::Scalar

Source§

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source§

fn min(self, rhs: Self) -> Self

Source§

fn max(self, rhs: Self) -> Self

Source§

fn clamp(self, min: Self, max: Self) -> Self

Source§

fn is_finite(self) -> bool

Source§

impl GenericVector3 for Vector3<f32>

Source§

fn clamp(self, min: Self, max: Self) -> Self

Note that this operation is not symmetrical as nalgebra::clamp()

Source§

type Vector2 = Matrix<f32, Const<2>, Const<1>, ArrayStorage<f32, 2, 1>>

Source§

type Affine = Matrix<f32, Const<4>, Const<4>, ArrayStorage<f32, 4, 4>>

Source§

type Aabb = Aabb3<f32>

Source§

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source§

fn splat(value: Self::Scalar) -> Self

Source§

fn to_2d(self) -> Self::Vector2

Source§

fn magnitude(self) -> Self::Scalar

Source§

fn magnitude_sq(self) -> Self::Scalar

Source§

fn normalize(self) -> Self

Source§

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source§

fn dot(self, rhs: Self) -> Self::Scalar

Source§

fn cross(self, rhs: Self) -> Self

Source§

fn distance(self, rhs: Self) -> Self::Scalar

Source§

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source§

fn min(self, rhs: Self) -> Self

Source§

fn max(self, rhs: Self) -> Self

Source§

fn is_finite(self) -> bool

Source§

impl GenericVector3 for Vector3<f64>

Source§

fn clamp(self, min: Self, max: Self) -> Self

Note that this operation is not symmetrical as nalgebra::clamp()

Source§

type Vector2 = Matrix<f64, Const<2>, Const<1>, ArrayStorage<f64, 2, 1>>

Source§

type Affine = Matrix<f64, Const<4>, Const<4>, ArrayStorage<f64, 4, 4>>

Source§

type Aabb = Aabb3<f64>

Source§

fn new(x: Self::Scalar, y: Self::Scalar, z: Self::Scalar) -> Self

Source§

fn splat(value: Self::Scalar) -> Self

Source§

fn to_2d(self) -> Self::Vector2

Source§

fn magnitude(self) -> Self::Scalar

Source§

fn magnitude_sq(self) -> Self::Scalar

Source§

fn normalize(self) -> Self

Source§

fn try_normalize(self, epsilon: Self::Scalar) -> Option<Self>

Source§

fn dot(self, rhs: Self) -> Self::Scalar

Source§

fn cross(self, rhs: Self) -> Self

Source§

fn distance(self, rhs: Self) -> Self::Scalar

Source§

fn distance_sq(self, rhs: Self) -> Self::Scalar

Source§

fn min(self, rhs: Self) -> Self

Source§

fn max(self, rhs: Self) -> Self

Source§

fn is_finite(self) -> bool

Implementors§