Documentation ¶
Index ¶
- Constants
- Variables
- func RealEqual(a, b Real) bool
- func RealIsNaN(a Real) bool
- type Matrix3
- func (m *Matrix3) Add(m2 *Matrix3)
- func (m *Matrix3) Determinant() Real
- func (m *Matrix3) Invert() Matrix3
- func (m1 *Matrix3) MulMatrix3(m2 *Matrix3) Matrix3
- func (m *Matrix3) MulVector3(v *Vector3) Vector3
- func (m *Matrix3) MulWith(s Real)
- func (m *Matrix3) SetBlockInertiaTensor(halfSize *Vector3, mass Real)
- func (m *Matrix3) SetComponents(v1 *Vector3, v2 *Vector3, v3 *Vector3)
- func (m *Matrix3) SetIdentity()
- func (m *Matrix3) SetInertiaTensorCoeffs(ix, iy, iz, ixy, ixz, iyz Real)
- func (m *Matrix3) TransformTranspose(v *Vector3) Vector3
- func (m *Matrix3) Transpose() Matrix3
- type Matrix3x4
- func (m *Matrix3x4) GetAxis(colNumber int) Vector3
- func (m *Matrix3x4) MulMatrix3x4(o *Matrix3x4) Matrix3x4
- func (m *Matrix3x4) MulVector3(v *Vector3) Vector3
- func (m *Matrix3x4) SetAsTransform(pos *Vector3, rot *Quat)
- func (m *Matrix3x4) SetIdentity()
- func (m *Matrix3x4) TransformInverse(v *Vector3) Vector3
- type Matrix4
- type Quat
- func (q *Quat) AddScaledVector(v *Vector3, scale Real)
- func (q *Quat) Conjugated() Quat
- func (q *Quat) Dot(q2 *Quat) Real
- func (q *Quat) Inverse()
- func (q *Quat) Len() Real
- func (q *Quat) LookAt(eye, center, up *Vector3)
- func (q *Quat) Mul(q2 *Quat)
- func (q *Quat) Normalize()
- func (q *Quat) Rotate(v *Vector3) Vector3
- func (q *Quat) Scale(c Real)
- func (q *Quat) SetIdentity()
- type Real
- type Vector3
- func (v *Vector3) Add(v2 *Vector3)
- func (v *Vector3) AddScaled(v2 *Vector3, scale Real)
- func (v *Vector3) Clear()
- func (v *Vector3) ComponentProduct(v2 *Vector3)
- func (v *Vector3) Cross(v2 *Vector3) Vector3
- func (v *Vector3) Dot(v2 *Vector3) Real
- func (v *Vector3) Magnitude() Real
- func (v *Vector3) MulWith(r Real)
- func (v *Vector3) Normalize()
- func (v *Vector3) Set(v2 *Vector3)
- func (v *Vector3) SquareMagnitude() Real
- func (v *Vector3) Sub(v2 *Vector3)
- type Vector4
Constants ¶
const ( MinNormal = Real(1.1754943508222875e-38) // 1 / 2**(127 - 1) MinValue = Real(math.SmallestNonzeroFloat64) MaxValue = Real(math.MaxFloat64) )
Variables ¶
Functions ¶
Types ¶
type Matrix3 ¶
type Matrix3 [9]Real
Matrix3 is a 3x3 matrix of floats in column-major order.
func (*Matrix3) Determinant ¶
Determinant calculates the determinant of a matrix which is a measure of a square matrix's singularity and invertability, among other things.
func (*Matrix3) Invert ¶
Inv computes the inverse of a square matrix. An inverse is a square matrix such that when multiplied by the original, yields the identity.
func (*Matrix3) MulMatrix3 ¶
MulMatrix3 multiplies a 3x3 matrix by another 3x3 matrix.
func (*Matrix3) MulVector3 ¶
MulVector3 multiplies a 3x3 matrix by a vector.
func (*Matrix3) SetBlockInertiaTensor ¶
SetBlockInertiaTensor sets the value of the matrix as an inertia tensor of a rectangular block aligned with the body's coordinate system with the given axis half sizes and mass.
func (*Matrix3) SetComponents ¶
SetComponents sets the matrix vales based off of the three vectors given. Each vector should be arranged as a column in the matrix and should then be passed in order.
func (*Matrix3) SetIdentity ¶
func (m *Matrix3) SetIdentity()
SetIdentity loads the matrix with its identity.
func (*Matrix3) SetInertiaTensorCoeffs ¶
SetInertiaTensorCoeffs sets the value of the matrix from inertia tensor values.
func (*Matrix3) TransformTranspose ¶
TransformTranspose transforms the given vector by the transpose of this matrix
type Matrix3x4 ¶
type Matrix3x4 [12]Real
Matrix3x4 is a 3x4 matrix of floats in column-major order that can be used to hold a rotation and translation in 3D space where the 4th row would have been [0 0 0 1]
func (*Matrix3x4) MulMatrix3x4 ¶
Mul3x4 multiplies a 3x4 matrix by another 3x4 matrix. This operation is meant to mimic a 4x4 * 4x4 operation where the last row is {0, 0, 0, 1}.
func (*Matrix3x4) MulVector3 ¶
MulVector3 transforms the given vector by the matrix and returns the result.
func (*Matrix3x4) SetAsTransform ¶
SetAsTransform sets the 3x4 matrix to be a transform matrix based on the position and orientation passed in.
func (*Matrix3x4) SetIdentity ¶
func (m *Matrix3x4) SetIdentity()
SetIdentity loads the matrix with its identity.
func (*Matrix3x4) TransformInverse ¶
TransformInverse transforms the vector by the transformational inverse of this matrix. NOTE: will not work on matrixes with scale or shears.
type Matrix4 ¶
type Matrix4 [16]Real
Matrix4 is a 4x4 matrix of floats in column-major order.
func (*Matrix4) SetIdentity ¶
func (m *Matrix4) SetIdentity()
SetIdentity loads the matrix with its identity.
type Quat ¶
type Quat Vector4
Quat is the type of a quaternion (w,x,y,z).
func QuatBetweenVectors ¶
QuatBetweenVectors calculates the rotation between two vectors. Note: this was modified from the go-gl/mathgl library.
func QuatFromAxis ¶
QuatFromAxis creates an quaternion from an axis and an angle.
func (*Quat) AddScaledVector ¶
AddScaledVector adds the given vector to this quaternion, scaled by the given amount.
func (*Quat) Conjugated ¶
Conjugated returns the conjugate of a quaternion. Equivalent to Quat{w,-x,-y,-z}.
func (*Quat) Dot ¶
Dot calculates the dot product between two quaternions, equivalent to if this was a Vector4
func (*Quat) Inverse ¶
func (q *Quat) Inverse()
Inverse calculates the inverse of a quaternion. The inverse is equivalent to the conjugate divided by the square of the length.
This method computes the square norm by directly adding the sum of the squares of all terms instead of actually squaring q1.Len(), both for performance and percision.
func (*Quat) LookAt ¶
LookAt sets the quaternion to the orientation needed to look at a 'center' from the 'eye' position with 'up' as a reference vector for the up direction. Note: this was modified from the go-gl/mathgl library.
func (*Quat) SetIdentity ¶
func (q *Quat) SetIdentity()
SetIdentity loads the quaternion with its identity.
type Real ¶
type Real float64
Real is the type of float used in the library.
const Epsilon Real = 1e-7
Espilon is used to test equality of the floats and represents how close two Reals can be and still test positive for equality.
type Vector3 ¶
type Vector3 [3]Real
Vector3 is a vector of three floats.
func (*Vector3) ComponentProduct ¶
ComponentProduct performs a component-wise product with another vector.
func (*Vector3) Normalize ¶
func (v *Vector3) Normalize()
Normalize sets the vector the normalized value.
func (*Vector3) SquareMagnitude ¶
SquareMagnitude returns the magitude of the vector, squared.