Trait glamour::Scalar

source ·
pub trait Scalar: PodValue + PartialOrd + ToRaw<Raw = Self> + FromRaw + AsRaw + Display + Unit<Scalar = Self> + NumOps + NumCast + AbsDiffEq<Epsilon = Self> + From<bool> {
    type Vec2: Vector2<Scalar = Self>;
    type Vec3: Vector3<Scalar = Self>;
    type Vec4: Vector4<Scalar = Self>;

    const ZERO: Self;
    const ONE: Self;

    // Provided method
    fn try_cast<T2: Scalar>(self) -> Option<T2> { ... }
}
Expand description

All types that can serve as components of a SIMD type in glam.

This is implemented for f32, f64, i32, u32, i16, u16, i64, and u64.

Required Associated Types§

source

type Vec2: Vector2<Scalar = Self>

The underlying 2D vector type for this scalar (glam::Vec2, glam::DVec2, glam::IVec2, or glam::UVec2).

source

type Vec3: Vector3<Scalar = Self>

The underlying 3D vector type for this scalar (glam::Vec3, glam::DVec3, glam::IVec3, or glam::UVec3).

source

type Vec4: Vector4<Scalar = Self>

The underlying 4D vector type for this scalar (glam::Vec4, glam::DVec4, glam::IVec4, or glam::UVec4).

Required Associated Constants§

source

const ZERO: Self

Zero.

source

const ONE: Self

One.

Provided Methods§

source

fn try_cast<T2: Scalar>(self) -> Option<T2>

Try casting to another scalar type.

The cast always succeeds if the scalars have the same underlying type (i.e., the same Primitive associated type).

The cast fails under the same conditions where num_traits::NumCast::from() fails.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl Scalar for f32

source§

const ZERO: Self = 0f32

source§

const ONE: Self = 1f32

§

type Vec2 = Vec2

§

type Vec3 = Vec3

§

type Vec4 = Vec4

source§

impl Scalar for f64

source§

const ZERO: Self = 0f64

source§

const ONE: Self = 1f64

§

type Vec2 = DVec2

§

type Vec3 = DVec3

§

type Vec4 = DVec4

source§

impl Scalar for i16

source§

const ZERO: Self = 0i16

source§

const ONE: Self = 1i16

§

type Vec2 = I16Vec2

§

type Vec3 = I16Vec3

§

type Vec4 = I16Vec4

source§

impl Scalar for i32

source§

const ZERO: Self = 0i32

source§

const ONE: Self = 1i32

§

type Vec2 = IVec2

§

type Vec3 = IVec3

§

type Vec4 = IVec4

source§

impl Scalar for i64

source§

const ZERO: Self = 0i64

source§

const ONE: Self = 1i64

§

type Vec2 = I64Vec2

§

type Vec3 = I64Vec3

§

type Vec4 = I64Vec4

source§

impl Scalar for u16

source§

const ZERO: Self = 0u16

source§

const ONE: Self = 1u16

§

type Vec2 = U16Vec2

§

type Vec3 = U16Vec3

§

type Vec4 = U16Vec4

source§

impl Scalar for u32

source§

const ZERO: Self = 0u32

source§

const ONE: Self = 1u32

§

type Vec2 = UVec2

§

type Vec3 = UVec3

§

type Vec4 = UVec4

source§

impl Scalar for u64

source§

const ZERO: Self = 0u64

source§

const ONE: Self = 1u64

§

type Vec2 = U64Vec2

§

type Vec3 = U64Vec3

§

type Vec4 = U64Vec4

Implementors§