[][src]Trait webgl_matrix::Vector

pub trait Vector {
    type VectorType;
    fn zeros() -> Self::VectorType;
fn ones() -> Self::VectorType;
fn mul(&self, rhs: &[f32]) -> Self::VectorType;
fn add(&self, rhs: &[f32]) -> Self::VectorType;
fn sub(&self, rhs: &[f32]) -> Self::VectorType;
fn scale(&self, factor: f32) -> Self::VectorType;
fn mag(&self) -> f32;
fn mag2(&self) -> f32;
fn dot(&self, rhs: &[f32]) -> f32; }

The base Vector trait

Note that vector operations are permitted on slices. This is useful for WebGl vertex storages, where many vectors are stored in a single array. The caveat obviously is the potential for errors. Sadly there is no secure alternative for handling this use-case.

Associated Types

Loading content...

Required methods

fn zeros() -> Self::VectorType

Create a vector filled with zeros

fn ones() -> Self::VectorType

Create a vector filled with ones

fn mul(&self, rhs: &[f32]) -> Self::VectorType

Perform element-wise multiplication with the given right-hand-side operand

fn add(&self, rhs: &[f32]) -> Self::VectorType

Perform element-wise addition with the given right-hand-side operand

fn sub(&self, rhs: &[f32]) -> Self::VectorType

Perform element-wise substraction with the given right-hand-side operand

fn scale(&self, factor: f32) -> Self::VectorType

Scale the vector elment-wise by the given constant

fn mag(&self) -> f32

Calculate the magnitude of this vector

fn mag2(&self) -> f32

Calculate the squared magnitude of this vector

fn dot(&self, rhs: &[f32]) -> f32

Calculate the dot product of this vector and the given right-hand-side operand

Loading content...

Implementors

impl Vector for Vec3[src]

type VectorType = Vec3

impl Vector for Vec4[src]

type VectorType = Vec4

Loading content...