Module

Linear.V3

Package
purescript-linear
Repository
afcondon/purescript-linear

3-dimensional vectors.

This module provides the V3 type for 3D vector operations, including the cross product for computing perpendicular vectors.

#V3 Source

data V3 a

A 3-dimensional vector.

origin = V3 0.0 0.0 0.0
up = V3 0.0 1.0 0.0

Constructors

Instances

#cross Source

cross :: forall a. Ring a => V3 a -> V3 a -> V3 a

The cross product of two 3D vectors.

The result is perpendicular to both input vectors, with magnitude equal to the area of the parallelogram they span.

cross (V3 1.0 0.0 0.0) (V3 0.0 1.0 0.0) = V3 0.0 0.0 1.0

#triple Source

triple :: forall a. Ring a => V3 a -> V3 a -> V3 a -> a

The scalar triple product of three vectors.

This equals the signed volume of the parallelepiped formed by the vectors.

triple (V3 1.0 0.0 0.0) (V3 0.0 1.0 0.0) (V3 0.0 0.0 1.0) = 1.0

#ex Source

ex :: forall a. Semiring a => V3 a

Unit vector along the x-axis.

#ey Source

ey :: forall a. Semiring a => V3 a

Unit vector along the y-axis.

#ez Source

ez :: forall a. Semiring a => V3 a

Unit vector along the z-axis.

#getX Source

getX :: forall a. V3 a -> a

Get the x component of a V3.

#getY Source

getY :: forall a. V3 a -> a

Get the y component of a V3.

#getZ Source

getZ :: forall a. V3 a -> a

Get the z component of a V3.