Skip to content

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

NaN ​

jule
fn NaN(): Quat

Returns a quaternion NaN.

Inf ​

jule
fn Inf(sign: int): Quat

Returns a quaternion ±infinity by sign.

AxisAngle ​

jule
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 ​

jule
struct Quat {
	W: f64
	X: f64
	Y: f64
	Z: f64
}

Quaternion with floating-point precision.

Zero ​

jule
fn Zero(*self): bool

Reports whether all fields of quaternion are zero.

Add ​

jule
fn Add(mut *self, &x: *Quat, &y: *Quat)

Sets self to the sum of x+y.

Sub ​

jule
fn Sub(mut *self, &x: *Quat, &y: *Quat)

Sets self to the difference x-y.

Mul ​

jule
fn Mul(mut *self, &x: *Quat, &y: *Quat)

Sets self to the Hamiltonian product x*y.

Scale ​

jule
fn Scale(mut *self, &q: *Quat, k: f64)

Sets self to q scaled by k.

Norm ​

jule
fn Norm(*self): f64

Returns the norm (magnitude or length) of the quaternion.

Normalize ​

jule
fn Normalize(mut *self, &q: *Quat)

Sets self to normalized quaternion q.

Conj ​

jule
fn Conj(mut *self, &q: *Quat)

Sets self to the quaternion conjugate of q.

NaN ​

jule
fn NaN(*self): bool

Reports whether any field of quaternion is NaN and none are an infinity.

Inf ​

jule
fn Inf(*self): bool

Reports whether any of field of quaternion is ±infinity.

Inv ​

jule
fn Inv(mut *self, &q: *Quat)

Sets self to the quaternion inverse of q.

Exp ​

jule
fn Exp(mut *self, &q: *Quat)

Sets self to the product e**q, the base-e exponential of q.

Log ​

jule
fn Log(mut *self, &q: *Quat)

Sets self to the natural logarithm of q.

Pow ​

jule
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 ​

jule
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 ​

jule
fn Sqrt(mut *self, &q: *Quat)

Sets self to the √q.

Sin ​

jule
fn Sin(mut *self, &q: *Quat)

Sets self to the sine of q.

Sinh ​

jule
fn Sinh(mut *self, &q: *Quat)

Sets self to the hyperbolic sine of q.

Cos ​

jule
fn Cos(mut *self, &q: *Quat)

Sets self to the cosine of q.

Cosh ​

jule
fn Cosh(mut *self, &q: *Quat)

Sets self to the hyperbolic cosine of q.

Tan ​

jule
fn Tan(mut *self, &q: *Quat)

Sets self to the tangent of q.

Tanh ​

jule
fn Tanh(mut *self, &q: *Quat)

Sets self the hyperbolic tangent of q.

Asin ​

jule
fn Asin(mut *self, &q: *Quat)

Sets self to the inverse sine of q.

Asinh ​

jule
fn Asinh(mut *self, &q: *Quat)

Sets self to the inverse hyperbolic sine of q.

Acos ​

jule
fn Acos(mut *self, &q: *Quat)

Sets self to the inverse cosine of q.

Acosh ​

jule
fn Acosh(mut *self, &q: *Quat)

Sets self to the inverse hyperbolic cosine of q.

Atan ​

jule
fn Atan(mut *self, &q: *Quat)

Atan returns the inverse tangent of q.

Atanh ​

jule
fn Atanh(mut *self, &q: *Quat)

Atanh returns the inverse hyperbolic tangent of q.

Abs ​

jule
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