Module beagle::vec [] [src]

An array of Scalars, written Vec<D, V> but pronounced 'vector'.

Vectors support binary operations between two Vectors or between one Vector and one Scalar. All Arithmetic operators and Bitwise operators are supported, where the two Scalar types involved support the operation. All operations operate on each component separately.

Vectors also support Negation and Logical Negation where the underlying Scalar Type supports it.

Examples

use beagle::vec::{Vec3};

let v1 = Vec3::new([2f32, 3f32, 5f32]);
let v2 = Vec3::new([7f32, 11f32, 13f32]);
assert_eq!(v1+v2, Vec3::new([9f32, 14f32, 18f32]));

Structs

Vec

An array of Scalars, written Vec<D, V> but pronounced 'vector'.

Functions

cross

Returns the cross product of s and t.

distance

Returns the distance between lhs and rhs.

distance2

Returns the distance squared between lhs and rhs.

dot

Multiply two Vectors component-wise, summing the results. Known as a dot product.

faceforward

Returns n if nref.dot(i) is negative, else -n.

is_perpendicular

Returns cos²(θ) < ε², where θ = the angle between a and b.

length

Returns the length of s.

length2

Returns the length squared of s.

normalize

Returns an approximated normalized version of s. This is generally faster than normalize_exact.

normalize_exact

Returns an exact normalized version of s. Basically v / v.length()

reflect

Reflects i against n as i - n * dot(i,n) * 2.

Type Definitions

Vec1

An alias for Vec<One, V>

Vec2

An alias for Vec<One, V>

Vec3

An alias for Vec<One, V>

Vec4

An alias for Vec<One, V>