julenum/num/quat
Package for quaternion numbers.
Index
fn NaN(): Quat
fn Inf(sign: int): Quat
fn AxisAngle(x: f64, y: f64, z: f64, radians: f64): Quat
struct Quat
fn NaN(*self): bool
fn Inf(*self): bool
fn Inv(mut *self, &q: *Quat)
fn Exp(mut *self, &q: *Quat)
fn Log(mut *self, &q: *Quat)
fn Pow(mut *self, &q: *Quat, &r: *Quat)
fn PowReal(mut *self, &q: *Quat, r: f64)
fn Sqrt(mut *self, &q: *Quat)
fn Sin(mut *self, &q: *Quat)
fn Sinh(mut *self, &q: *Quat)
fn Cos(mut *self, &q: *Quat)
fn Cosh(mut *self, &q: *Quat)
fn Tan(mut *self, &q: *Quat)
fn Tanh(mut *self, &q: *Quat)
fn Asin(mut *self, &q: *Quat)
fn Asinh(mut *self, &q: *Quat)
fn Acos(mut *self, &q: *Quat)
fn Acosh(mut *self, &q: *Quat)
fn Atan(mut *self, &q: *Quat)
fn Atanh(mut *self, &q: *Quat)
fn Abs(*self): f64
fn Zero(*self): bool
fn Add(mut *self, &x: *Quat, &y: *Quat)
fn Sub(mut *self, &x: *Quat, &y: *Quat)
fn Mul(mut *self, &x: *Quat, &y: *Quat)
fn Scale(mut *self, &q: *Quat, k: f64)
fn Norm(*self): f64
fn Normalize(mut *self, &q: *Quat)
fn Conj(mut *self, &q: *Quat)
NaN
fn NaN(): Quat
Returns a quaternion NaN.
Inf
fn Inf(sign: int): Quat
Returns a quaternion ±infinity by sign.
AxisAngle
fn AxisAngle(x: f64, y: f64, z: f64, radians: f64): Quat
Returns a unit quaternion representing a rotation around the given axis (x, y, z) by the specified angle in radians.
Components of the rotation axis vector. Rotation vector is assumed (but not enforced) that this is a unit vector.
Quat
struct Quat {
W: f64
X: f64
Y: f64
Z: f64
}
Quaternion with floating-point precision.
NaN
fn NaN(*self): bool
Reports whether any field of quaternion is NaN and none are an infinity.
Inf
fn Inf(*self): bool
Reports whether any of field of quaternion is ±infinity.
Inv
fn Inv(mut *self, &q: *Quat)
Sets self to the quaternion inverse of q.
Exp
fn Exp(mut *self, &q: *Quat)
Sets self to the product e**q, the base-e exponential of q.
Log
fn Log(mut *self, &q: *Quat)
Sets self to the natural logarithm of q.
Pow
fn Pow(mut *self, &q: *Quat, &r: *Quat)
Sets self to the product q**r, the base-q exponential of r. For generalized compatibility with math::Pow:
Pow(0, ±0) returns 1+0i+0j+0k
Pow(0, r) for W(r)<0 returns Inf+0i+0j+0k if X(r), Y(r), Z(r) are zero,
otherwise Inf+Inf i+Inf j+Inf k.
PowReal
fn PowReal(mut *self, &q: *Quat, r: f64)
Sets self to the product q**r, the base-q exponential of r. For generalized compatibility with math::Pow:
PowReal(0, ±0) returns 1+0i+0j+0k
PowReal(0, c) for c<0 returns Inf+0i+0j+0k.
Sqrt
fn Sqrt(mut *self, &q: *Quat)
Sets self to the √q.
Sin
fn Sin(mut *self, &q: *Quat)
Sets self to the sine of q.
Sinh
fn Sinh(mut *self, &q: *Quat)
Sets self to the hyperbolic sine of q.
Cos
fn Cos(mut *self, &q: *Quat)
Sets self to the cosine of q.
Cosh
fn Cosh(mut *self, &q: *Quat)
Sets self to the hyperbolic cosine of q.
Tan
fn Tan(mut *self, &q: *Quat)
Sets self to the tangent of q.
Tanh
fn Tanh(mut *self, &q: *Quat)
Sets self the hyperbolic tangent of q.
Asin
fn Asin(mut *self, &q: *Quat)
Sets self to the inverse sine of q.
Asinh
fn Asinh(mut *self, &q: *Quat)
Sets self to the inverse hyperbolic sine of q.
Acos
fn Acos(mut *self, &q: *Quat)
Sets self to the inverse cosine of q.
Acosh
fn Acosh(mut *self, &q: *Quat)
Sets self to the inverse hyperbolic cosine of q.
Atan
fn Atan(mut *self, &q: *Quat)
Atan returns the inverse tangent of q.
Atanh
fn Atanh(mut *self, &q: *Quat)
Atanh returns the inverse hyperbolic tangent of q.
Abs
fn Abs(*self): f64
Returns the absolute value (also called the modulus) of quaternion.
Special cases are:
Abs() = +Inf, if quaternion is ±Inf.
Abs() = NaN, if quaternion is NaN
Zero
fn Zero(*self): bool
Reports whether all fields of quaternion are zero.
Add
fn Add(mut *self, &x: *Quat, &y: *Quat)
Sets self to the sum of x+y.
Sub
fn Sub(mut *self, &x: *Quat, &y: *Quat)
Sets self to the difference x-y.
Mul
fn Mul(mut *self, &x: *Quat, &y: *Quat)
Sets self to the Hamiltonian product x*y.
Scale
fn Scale(mut *self, &q: *Quat, k: f64)
Sets self to q scaled by k.
Norm
fn Norm(*self): f64
Returns the norm (magnitude or length) of the quaternion.
Normalize
fn Normalize(mut *self, &q: *Quat)
Sets self to normalized quaternion q.
Conj
fn Conj(mut *self, &q: *Quat)
Sets self to the quaternion conjugate of q.