Skip to main content

Vec3Fix

Struct Vec3Fix 

Source
#[repr(C)]
pub struct Vec3Fix { pub x: Fix128, pub y: Fix128, pub z: Fix128, }
Expand description

3D vector using Fix128 components

Fields§

§x: Fix128

X component

§y: Fix128

Y component

§z: Fix128

Z component

Implementations§

Source§

impl Vec3Fix

Source

pub fn checked_scale(self, s: Fix128) -> Option<Self>

各成分を s 倍し、どれか 1 成分でも範囲外なら None を返す

Fix128::checked_mul の Vec3Fix 版 発散検出の投入点 (積分 position += velocity*dt と速度導出) で使う

Source§

impl Vec3Fix

Source

pub const ZERO: Self

Zero vector

Source

pub const UNIT_X: Self

Unit X vector

Source

pub const UNIT_Y: Self

Unit Y vector

Source

pub const UNIT_Z: Self

Unit Z vector

Source

pub const fn new(x: Fix128, y: Fix128, z: Fix128) -> Self

Create new vector

Source

pub const fn from_int(x: i64, y: i64, z: i64) -> Self

Create from integers

Source

pub fn from_f32(x: f32, y: f32, z: f32) -> Self

Create from f32 components (for SDF bridge) Create from f32 components (for SDF bridge, not deterministic!)

Source

pub fn to_f32(self) -> (f32, f32, f32)

Convert to f32 tuple (for SDF bridge)

Source

pub fn dot(self, rhs: Self) -> Fix128

Dot product

Source

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

Cross product

Source

pub fn length_squared(self) -> Fix128

Squared length (no sqrt)

Source

pub fn length(self) -> Fix128

Length (magnitude)

Source

pub fn normalize(self) -> Self

Normalize to unit length.

Returns Self::ZERO for zero-length vectors. Use Self::try_normalize when you need to distinguish a zero-length input from a valid unit vector.

Source

pub fn try_normalize(self) -> Option<Self>

Try to normalize, returning None for zero-length vectors.

Source

pub fn normalize_with_length(self) -> (Self, Fix128)

Normalize and return both the unit vector and the original length.

Avoids double sqrt when both normalized direction and distance are needed. Returns (Self::ZERO, Fix128::ZERO) if the vector is zero-length.

Source

pub fn checked_add(self, rhs: Self) -> Option<Self>

成分ごとの Fix128::checked_add (+ と同じ和、どれかの成分が |·| ≥ 2⁶³ なら None)

§Claims
  • Some の時は self + rhs と bit 一致する
  • 位置の加算のように wrap が反対側の端への移動になる経路だけが使う
Source

pub fn checked_dot(self, rhs: Self) -> Option<Fix128>

Self::dot と同じ値を計算し、積か和のどれかが範囲外なら None を返す

§Claims
  • Some の時は dot と bit 一致する (同じ積を同じ順で足す)
  • 3 つの積のどれか、または途中の和が |·| ≥ 2⁶³ なら None
Source

pub fn checked_length_squared(self) -> Option<Fix128>

Self::length_squared の範囲検査版 (|v|² ≥ 2⁶³ で None)

Some の時は length_squared と bit 一致する

Source

pub fn checked_length(self) -> Option<Fix128>

Self::length の範囲検査版 (|v| ≥ 2³¹·⁵ で None)

Some の時は length と bit 一致する 範囲外でも長さが要るなら Self::checked_length_scaled を使う

Source

pub fn checked_normalize(self) -> Option<Self>

Self::try_normalize の範囲検査版

長さ 0 と |v| ≥ 2³¹·⁵ (長さの 2 乗が範囲外) のどちらも None Some の時は try_normalize と bit 一致する 範囲外でも向きが要るなら Self::try_normalize_scaled を使う

Source

pub fn checked_length_scaled(self) -> Option<Fix128>

2 乗が範囲外になる大きさでも正しい長さ 結果自体が ≥ 2⁶³ (表せない) 時だけ None

§Claims
  • |v|² < 2⁶³ (length_squared が wrap しない範囲) では length と bit 一致する (同じ式をそのまま使う)
  • それより大きい時は、最大成分を 2 の冪で [2²⁹, 2³⁰) に寄せてから 2 乗するので wrap せず、相対誤差は約 2⁻⁹² (成分の切り捨てと sqrt の floor)
  • 結果が ≥ 2⁶³ (成分が 2⁶² 級) なら None
Source

pub fn try_normalize_scaled(self) -> Option<Self>

2 乗が範囲外になる大きさでも向きを返す正規化 零ベクトルだけ None

§Claims
  • try_normalize が Some を返す入力では try_normalize と bit 一致
  • try_normalize が範囲外 (|v| ≥ 2³¹·⁵) や長さの 2 乗の下位桁あふれ (|v| < 約 2⁻³²) で None を返す非零ベクトルには、最大成分を [2²⁹, 2³⁰) に寄せたベクトルを正規化して返す
Source

pub fn scale(self, s: Fix128) -> Self

Scale by scalar

Source

pub fn dot_simd(self, rhs: Self) -> Fix128

SIMD-accelerated dot product — safe public entry point.

On x86_64 with the simd feature enabled this dispatches to the SSE2 path (dot_simd_sse2). On every other platform it falls back to the scalar dot(). The result is bit-exact identical to dot() on every platform.

Source

pub fn length_squared_simd(self) -> Fix128

Squared length using SIMD-accelerated dot product.

Equivalent to length_squared() but dispatches through dot_simd. Result is bit-exact identical to length_squared().

Source

pub fn cross_simd(self, rhs: Self) -> Self

Cross product through the simd feature’s API surface — scalar-equivalent, bit-identical to cross() (see the module docs).

Source

pub fn dot_batch_4(a: [Self; 4], b: [Self; 4]) -> [Fix128; 4]

Batch dot product for 4 vector pairs — scalar-equivalent (four dot() calls, bit-identical). The batch shape is the API a future AVX-512 / NEON path would fill in.

Trait Implementations§

Source§

impl Add for Vec3Fix

Source§

type Output = Vec3Fix

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl Clone for Vec3Fix

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Vec3Fix

Source§

impl Debug for Vec3Fix

Source§

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

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

impl Default for Vec3Fix

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Vec3Fix

Source§

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

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

impl Div<Fix128> for Vec3Fix

Source§

type Output = Vec3Fix

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Fix128) -> Self

Performs the / operation. Read more
Source§

impl Eq for Vec3Fix

Source§

impl From<Vec3Fix> for [Fix128; 3]

Source§

fn from(v: Vec3Fix) -> Self

Converts to this type from the input type.
Source§

impl From<[Fix128; 3]> for Vec3Fix

Source§

fn from(arr: [Fix128; 3]) -> Self

Converts to this type from the input type.
Source§

impl Mul<Fix128> for Vec3Fix

Source§

type Output = Vec3Fix

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Fix128) -> Self

Performs the * operation. Read more
Source§

impl Neg for Vec3Fix

Source§

type Output = Vec3Fix

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self

Performs the unary - operation. Read more
Source§

impl PartialEq for Vec3Fix

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Vec3Fix

Source§

impl Sub for Vec3Fix

Source§

type Output = Vec3Fix

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more

Auto Trait Implementations§

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

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> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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.