1module Math.Vector where
3{-| A high performance linear algebra library using native JS arrays. Geared
4towards 3D graphics and use with `Graphics.WebGL`.
6All vectors are immutable.
12The set functions create a new copy of the vector, updating a single field.
14@docs getX, getY, getZ, setX, setY, setZ, toTuple, toRecord
17@docs add, sub, neg, direction, length, lengthSquared, normalize, scale, dot, cross
27{-| Creates a new 3-element vector with the given values.
29v3 : Float -> Float -> Float -> Vec3
32{-| The unit vector î which points in the x direction: `v3 1 0 0` -}
34i = Native.MJS.v3 1 0 0
36{-| The unit vector ĵ which points in the y direction: `v3 0 1 0` -}
38j = Native.MJS.v3 0 1 0
40{-| The unit vector &kcirc; which points in the z direction: `v3 0 0 1` -}
42k = Native.MJS.v3 0 0 1
44{-| Extract the x component of a vector. -}
48{-| Extract the y component of a vector. -}
52{-| Extract the z component of a vector. -}
56{-| Update the x component of a vector. -}
60{-| Update the y component of a vector. -}
64{-| Update the z component of a vector. -}
68{-| Convert a vector to a tuple.
70toTuple : Vec3 -> (Float,Float,Float)
71toTuple = Native.MJS.toTuple3
73{-| Convert a vector to a record.
75toRecord : Vec3 -> { x:Float, y:Float, z:Float }
76toRecord = Native.MJS.toRecord3
78{-| Vector addition: a + b
80add : Vec3 -> Vec3 -> Vec3
83{-| Vector subtraction: a - b
85sub : Vec3 -> Vec3 -> Vec3
88{-| Vector negation: -a
93{-| The normalized direction from a to b: (a - b) / |a - b|
95direction : Vec3 -> Vec3 -> Vec3
96direction = Native.MJS.v3direction
98{-| The length of the given vector: |a|
100length : Vec3 -> Float
101length = Native.MJS.v3length
103{-| The square of the length of the given vector: |a| * |a|
105lengthSquared : Vec3 -> Float
106lengthSquared = Native.MJS.v3lengthSquared
108{-| A unit vector with the same direction as the given vector: a / |a|
110normalize : Vec3 -> Vec3
111normalize = Native.MJS.v3normalize
113{-| Multiply the vector by a scalar: a * k
115scale : Vec3 -> Float -> Vec3
116scale = Native.MJS.v3scale
118{-| The dot product of a and b
120dot : Vec3 -> Vec3 -> Float
121dot = Native.MJS.v3dot
123{-| The cross product of a and b
125cross : Vec3 -> Vec3 -> Vec3
126cross = Native.MJS.v3cross
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list