Module

Data.Quaternion.Vec3

Package
purescript-quaternions
Repository
hdgarrood/purescript-quaternions

A minimal type for vectors in 3D space. This type is a newtype over Array a, with constructors to ensure that we do in fact have exactly three elements.

#Vec3 Source

newtype Vec3 a

Instances

#vec3 Source

vec3 :: forall a. a -> a -> a -> Vec3 a

Construct a Vec3 from three arguments.

#toArray Source

toArray :: forall a. Vec3 a -> Array a

Convert a Vec3 to a three-element array.

#fromArray Source

fromArray :: forall a. Partial => Array a -> Vec3 a

Convert a three-element array to a Vec3. If the argument does not have three elements, the behaviour of this function is undefined.

#normalize Source

normalize :: Vec3 Number -> Vec3 Number

Normalize a vector, returning a unit vector pointing in the same direction. Attempting to normalize the zero vector simply returns the zero vector.

#dot Source

dot :: forall a. Semiring a => Vec3 a -> Vec3 a -> a

#vzero Source

vzero :: forall a. Semiring a => Vec3 a

#vadd Source

vadd :: forall a. Semiring a => Vec3 a -> Vec3 a -> Vec3 a

#vsub Source

vsub :: forall a. Ring a => Vec3 a -> Vec3 a -> Vec3 a

#scalarMul Source

scalarMul :: forall a. Semiring a => a -> Vec3 a -> Vec3 a