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.

#Vec3Source

``newtype Vec3 a``

Instances

• `(Eq a) => Eq (Vec3 a)`
• `(Ord a) => Ord (Vec3 a)`
• `(Show a) => Show (Vec3 a)`
• `(Semiring a) => Semigroup (Vec3 a)`
• `(Semiring a) => Monoid (Vec3 a)`

#vec3Source

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

Construct a `Vec3` from three arguments.

#toArraySource

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

Convert a `Vec3` to a three-element array.

#fromArraySource

``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.

#normalizeSource

``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.

#magnitudeSource

``magnitude :: Vec3 Number -> Number``

#dotSource

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

#vzeroSource

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

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

#vsubSource

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

#scalarMulSource

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