1module Math.Vector4 where
2{-| A high performance linear algebra library using native JS arrays. Geared
3towards 3D graphics and use with `Graphics.WebGL`. All vectors are immutable.
9The set functions create a new copy of the vector, updating a single field.
11@docs getX, getY, setX, setY
14@docs add, sub, negate, scale, dot, normalize, direction,
15 length, lengthSquared, distance, distanceSquared
18toTuple, fromTuple, toRecord, fromRecord
21import Native.Math.Vector4
25{-| Creates a new 4-element vector with the given x, y, z, and w values. -}
26v4 : Float -> Float -> Float -> Float -> Vec4
27v4 = Native.Math.Vector4.v4
29{-| Extract the x component of a vector. -}
31getX = Native.Math.Vector4.getX
33{-| Extract the y component of a vector. -}
35getY = Native.Math.Vector4.getY
37{-| Extract the z component of a vector. -}
39getZ = Native.Math.Vector4.getZ
41{-| Extract the w component of a vector. -}
43getW = Native.Math.Vector4.getW
45{-| Update the x component of a vector, returning a new vector. -}
46setX : Float -> Vec4 -> Vec4
47setX = Native.Math.Vector4.setX
49{-| Update the y component of a vector, returning a new vector. -}
50setY : Float -> Vec4 -> Vec4
51setY = Native.Math.Vector4.setY
53{-| Update the z component of a vector, returning a new vector. -}
54setZ : Float -> Vec4 -> Vec4
55setZ = Native.Math.Vector4.setZ
57{-| Update the w component of a vector, returning a new vector. -}
58setW : Float -> Vec4 -> Vec4
59setW = Native.Math.Vector4.setW
61{-| Convert a vector to a tuple. -}
62toTuple : Vec4 -> (Float,Float,Float,Float)
63toTuple = Native.Math.Vector4.toTuple
65{-| Convert a vector to a record. -}
66toRecord : Vec4 -> { x:Float, y:Float, z:Float, w:Float }
67toRecord = Native.Math.Vector4.toRecord
69{-| Convert a tuple to a vector. -}
70fromTuple : (Float,Float,Float,Float) -> Vec4
71fromTuple = Native.Math.Vector4.fromTuple
73{-| Convert a record to a vector. -}
74fromRecord : { x:Float, y:Float, z:Float, w:Float } -> Vec4
75fromRecord = Native.Math.Vector4.fromRecord
77{-| Vector addition: a + b -}
78add : Vec4 -> Vec4 -> Vec4
79add = Native.Math.Vector4.add
81{-| Vector subtraction: a - b -}
82sub : Vec4 -> Vec4 -> Vec4
83sub = Native.Math.Vector4.sub
85{-| Vector negation: -a -}
87negate = Native.Math.Vector4.neg
89{-| The normalized direction from a to b: (a - b) / |a - b| -}
90direction : Vec4 -> Vec4 -> Vec4
91direction = Native.Math.Vector4.direction
93{-| The length of the given vector: |a| -}
95length = Native.Math.Vector4.length
97{-| The square of the length of the given vector: |a| * |a| -}
98lengthSquared : Vec4 -> Float
99lengthSquared = Native.Math.Vector4.lengthSquared
101{-| The distance between two vectors. -}
102distance : Vec4 -> Vec4 -> Float
103distance = Native.Math.Vector4.distance
105{-| The square of the distance between two vectors. -}
106distanceSquared : Vec4 -> Vec4 -> Float
107distanceSquared = Native.Math.Vector4.distanceSquared
109{-| A unit vector with the same direction as the given vector: a / |a| -}
110normalize : Vec4 -> Vec4
111normalize = Native.Math.Vector4.normalize
113{-| Multiply the vector by a scalar: a * k -}
114scale : Vec4 -> Float -> Vec4
115scale = Native.Math.Vector4.scale
117{-| The dot product of a and b -}
118dot : Vec4 -> Vec4 -> Float
119dot = Native.Math.Vector4.dot
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