Documentation
¶
Index ¶
- type Mat2
- type Mat2x3
- type Mat3
- type Mat4
- func DecomposeAffineTransform(m Mat4) (scale, rotation, translation Mat4)
- func Identity4() Mat4
- func LookAt(pos, target, up Vec3) Mat4
- func Mul4(m0 Mat4, m ...Mat4) Mat4
- func Ortho(left, right, bottom, top, near, far float32) Mat4
- func Perspective(fovRadians, aspect, near, far float32) Mat4
- func RotateAbout(v Vec3, radians float32) Mat4
- func RotateX(radians float32) Mat4
- func RotateY(radians float32) Mat4
- func RotateZ(radians float32) Mat4
- func Scale(dx, dy, dz float32) Mat4
- func ScaleV(v Vec3) Mat4
- func Translate(dx, dy, dz float32) Mat4
- func TranslateV(v Vec3) Mat4
- type Vec2
- func (v Vec2) Add(w Vec2) Vec2
- func (v Vec2) Dot(w Vec2) float32
- func (v Vec2) Homogeneous() Vec3
- func (v Vec2) MulMat(m Mat2) Vec2
- func (v Vec2) MulScalar(s float32) Vec2
- func (v Vec2) Negate() Vec2
- func (v Vec2) Norm() float32
- func (v Vec2) Normalized() Vec2
- func (v Vec2) SquareNorm() float32
- func (v Vec2) String() string
- func (v Vec2) Sub(w Vec2) Vec2
- type Vec3
- func (v Vec3) Add(w Vec3) Vec3
- func (v Vec3) ByZ() Vec2
- func (v Vec3) Cross(w Vec3) Vec3
- func (v Vec3) Dot(w Vec3) float32
- func (v Vec3) DropZ() Vec2
- func (v Vec3) Homogeneous() Vec4
- func (v Vec3) MulMat(m Mat3) Vec3
- func (v Vec3) MulScalar(s float32) Vec3
- func (v Vec3) Negate() Vec3
- func (v Vec3) Norm() float32
- func (v Vec3) Normalized() Vec3
- func (v Vec3) SquareNorm() float32
- func (v Vec3) String() string
- func (v Vec3) Sub(w Vec3) Vec3
- type Vec4
- func (v Vec4) Add(w Vec4) Vec4
- func (v Vec4) ByW() Vec3
- func (v Vec4) Dot(w Vec4) float32
- func (v Vec4) DropW() Vec3
- func (v Vec4) MulMat(m Mat4) Vec4
- func (v Vec4) MulScalar(s float32) Vec4
- func (v Vec4) Negate() Vec4
- func (v Vec4) Norm() float32
- func (v Vec4) Normalized() Vec4
- func (v Vec4) SquareNorm() float32
- func (v Vec4) String() string
- func (v Vec4) Sub(w Vec4) Vec4
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Mat2 ¶
type Mat2 [4]float32
Mat2 is a 2 by 2 matrix of float32s in row-major order.
func (Mat2) Homogeneous ¶
Homogeneous returns the homogeneous 3-dimensional equivalent of the 2-dimensional matrix.
func (Mat2) Transposed ¶ added in v1.1.0
Transposed returns a transposed copy of m.
type Mat2x3 ¶
type Mat2x3 [6]float32
Mat2x3 is a 2x3 matrix of float32s in row-major order. It represents a homogeneous 3x3 matrix where the last line is 0,0,1 implicitly.
func Identity2x3 ¶
func Identity2x3() Mat2x3
Identity2x3 returns the 2 by 3 homogeneous identity matrix.
type Mat3 ¶
type Mat3 [9]float32
Mat3 is a 3 by 3 matrix of float32s in row-major order.
func (Mat3) Homogeneous ¶
Homogeneous returns the homogeneous 4-dimensional equivalent of the 3-dimensional matrix.
func (Mat3) Transposed ¶ added in v1.1.0
Transposed returns a transposed copy of m.
type Mat4 ¶
type Mat4 [16]float32
Mat4 is a 4 by 4 matrix of float32s in row-major order.
func DecomposeAffineTransform ¶
DecomposeAffineTransform decomposes the given matrix into scale, rotation and translation matrices that, when multiplied in that order, produce the original matrix. See this forum post for reference: https://math.stackexchange.com/questions/237369/given-this-transformation-matrix-how-do-i-decompose-it-into-translation-rotati
func LookAt ¶
LookAt returns a matrix that, when used for the camera, looks at target from position pos. Since you can tilt your head in infinite ways looking from one point at another, the up vector is used to specify which direction is up.
func Perspective ¶
Perspective returns an perspective projection matrix.
func RotateAbout ¶
RotateAbout reutrns 4 by 4 matrix that, when multiplied with a homogeneous 4-element 3D vector, rotates the vector about the given vector v by the given angle in radians.
func RotateX ¶
RotateX reutrns 4 by 4 matrix that, when multiplied with a homogeneous 4-element 3D vector, rotates the vector about the x-axis by the given angle in radians.
func RotateY ¶
RotateY reutrns 4 by 4 matrix that, when multiplied with a homogeneous 4-element 3D vector, rotates the vector about the y-axis by the given angle in radians.
func RotateZ ¶
RotateZ reutrns 4 by 4 matrix that, when multiplied with a homogeneous 4-element 3D vector, rotates the vector about the z-axis by the given angle in radians.
func Scale ¶
Scale reutrns 4 by 4 matrix that, when multiplied with a homogeneous 4-element 3D vector, scales the vector by the given factors in x, y and z.
func ScaleV ¶
ScaleV is the same as Scale, but it takes a Vec3 as its argument instead of single x, y, z parameters.
func Translate ¶
Translate reutrns 4 by 4 matrix that, when multiplied with a homogeneous 4-element 3D vector, moves the vector by the given amounts in x, y and z.
func TranslateV ¶
TranslateV is the same as Translate, but it takes a Vec3 as its argument instead of single x, y, z parameters.
type Vec2 ¶
type Vec2 [2]float32
Vec2 is a 2-element row vector. Elements are called x, y in the docs.
func (Vec2) Homogeneous ¶
Homogeneous returns a 3-element vector where x and y are the same as in v and z is 1.
func (Vec2) Normalized ¶
Normalized returns a copy of v with elements normalized so the returned vector has length 1.
func (Vec2) SquareNorm ¶
SquareNorm returns the square of the length of v.
type Vec3 ¶
type Vec3 [3]float32
Vec3 is a 3-element row vector. Elements are called x, y, z in the docs.
func (Vec3) ByZ ¶ added in v1.1.0
ByW returns a 2-element vector where x and y are the same as in v but divided by z. This can be useful when going back from a homogeneous 3-element vector with z != 1, down one dimension to a 2-element vector.
func (Vec3) DropZ ¶ added in v1.1.0
DropZ returns a 2-element vector where x and y are the same as in v. This can be useful when going back from a homogeneous 3-element vector with z == 1, down one dimension to a 2-element vector. If z != 1 then use ByZ() to divide by z instead.
func (Vec3) Homogeneous ¶
Homogeneous returns a 4-element vector where x, y and z are the same as in v and w is 1.
func (Vec3) Normalized ¶
Normalized returns a copy of v with elements normalized so the returned vector has length 1.
func (Vec3) SquareNorm ¶
SquareNorm returns the square of the length of v.
type Vec4 ¶
type Vec4 [4]float32
Vec4 is a 4-element row vector. Elements are called x, y, z, w in the docs.
func (Vec4) ByW ¶ added in v1.1.0
ByW returns a 3-element vector where x, y and z are the same as in v but divided by w. This can be useful when going back from a homogeneous 4-element vector with w != 1, down one dimension to a 3-element vector.
func (Vec4) DropW ¶
DropW returns a 3-element vector where x, y and z are the same as in v. This can be useful when going back from a homogeneous 4-element vector with w == 1, down one dimension to a 3-element vector. If w != 1 then use ByW() to divide by w instead.
func (Vec4) Normalized ¶ added in v1.1.0
Normalized returns a copy of v with elements normalized so the returned vector has length 1.
func (Vec4) SquareNorm ¶ added in v1.1.0
SquareNorm returns the square of the length of v.
Directories
¶
| Path | Synopsis |
|---|---|
|
column_major
|
|
|
d3dmath
Package d3dmath provices vector and matrix functions for Direct3D. Vectors are row vectors and matrices are stored in column-major order.
|
Package d3dmath provices vector and matrix functions for Direct3D. Vectors are row vectors and matrices are stored in column-major order. |
|
row_major
|
|
|
d3dmath
Package d3dmath provices vector and matrix functions for Direct3D. Vectors are row vectors and matrices are stored in row-major order.
|
Package d3dmath provices vector and matrix functions for Direct3D. Vectors are row vectors and matrices are stored in row-major order. |