Documentation ¶
Overview ¶
Package f32 implements some linear algebra and GL helpers for float32s.
Types defined in this package have methods implementing common mathematical operations. The common form for these functions is
func (dst *T) Op(lhs, rhs *T)
which reads in traditional mathematical notation as
dst = lhs op rhs.
It is safe to use the destination address as the left-hand side, that is, dst *= rhs is dst.Mul(dst, rhs).
WARNING ¶
The interface to this package is not stable. It will change considerably. Only use functions that provide package documentation. Semantics are non-obvious. Be prepared for the package name to change.
Index ¶
- func Bytes(byteOrder binary.ByteOrder, values ...float32) []byte
- func Cos(x float32) float32
- func Sin(x float32) float32
- func Sqrt(x float32) float32
- func Tan(x float32) float32
- type Affine
- func (m *Affine) Eq(n *Affine, epsilon float32) bool
- func (m *Affine) Identity()
- func (m *Affine) Inverse(p *Affine)
- func (m *Affine) Mul(p, q *Affine)
- func (m *Affine) Rotate(p *Affine, radians float32)
- func (m *Affine) Scale(p *Affine, x, y float32)
- func (m Affine) String() string
- func (m *Affine) Translate(p *Affine, x, y float32)
- type Mat3
- type Mat4
- func (m *Mat4) Eq(n *Mat4, epsilon float32) bool
- func (m *Mat4) Identity()
- func (m *Mat4) LookAt(eye, center, up *Vec3)
- func (m *Mat4) Mul(a, b *Mat4)
- func (m *Mat4) Perspective(fov Radian, aspect, near, far float32)
- func (m *Mat4) Rotate(p *Mat4, angle Radian, axis *Vec3)
- func (m *Mat4) Scale(p *Mat4, x, y, z float32)
- func (m Mat4) String() string
- func (m *Mat4) Translate(p *Mat4, x, y, z float32)
- type Radian
- type Vec3
- type Vec4
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Affine ¶
type Affine [2]Vec3
An Affine is a 3x3 matrix of float32 values for which the bottom row is implicitly always equal to [0 0 1]. Elements are indexed first by row then column, i.e. m[row][column].
func (*Affine) Eq ¶
Eq reports whether each component of m is within epsilon of the same component in n.
func (*Affine) Rotate ¶
Rotate sets m to a rotation in radians followed by p. It is equivalent to m.Mul(p, affineRotation).
type Mat3 ¶
type Mat3 [3]Vec3
A Mat3 is a 3x3 matrix of float32 values. Elements are indexed first by row then column, i.e. m[row][column].
type Mat4 ¶
type Mat4 [4]Vec4
A Mat4 is a 4x4 matrix of float32 values. Elements are indexed first by row then column, i.e. m[row][column].
func (*Mat4) Perspective ¶
Perspective sets m to be the GL perspective matrix.
func (*Mat4) Rotate ¶
Rotate sets m to a rotation in radians around a specified axis, followed by p. It is equivalent to m.Mul(p, affineRotation).