Documentation ¶
Index ¶
- Constants
- func Abs32(x float32) float32
- func Acos32(x float32) float32
- func AngleQuat(q1, q2 *Quat) float32
- func AngleVec3(v1, v2 *Vec3) float32
- func Asin32(x float32) float32
- func Atan232(x, y float32) float32
- func Atan32(x float32) float32
- func Clamp[T constraints.Ordered](x, min, max T) T
- func Cos32(x float32) float32
- func DistVec2(v1, v2 *Vec2) float32
- func DistVec3(v1, v2 *Vec3) float32
- func DistVec4(v1, v2 *Vec4) float32
- func DotQuat(q1, q2 *Quat) float32
- func DotVec2(v1, v2 *Vec2) float32
- func DotVec3(v1, v2 *Vec3) float32
- func DotVec4(v1, v2 *Vec4) float32
- func EqF32(f1, f2 float32) bool
- func EqF32Epsilon(f1, f2, eps float32) bool
- func Sin32(x float32) float32
- func Sincos32(x float32) (sinx, cosx float32)
- func SqrDistVec2(v1, v2 *Vec2) float32
- func SqrDistVec3(v1, v2 *Vec3) float32
- func SqrDistVec4(v1, v2 *Vec4) float32
- func Sqrt32(x float32) float32
- func Tan32(x float32) float32
- type Mat
- type Mat2
- func (m *Mat2) Add(m2 *Mat2) *Mat2
- func (m *Mat2) Clone() *Mat2
- func (m *Mat2) Col(c int) Vec2
- func (m *Mat2) Determinant() float32
- func (m *Mat2) Eq(m2 *Mat2) bool
- func (m *Mat2) Get(row, col int) float32
- func (m *Mat2) Invert() *Mat2
- func (m1 *Mat2) Mul(m2 *Mat2) *Mat2
- func (m *Mat2) Scale(x float32) *Mat2
- func (m *Mat2) Set(row, col int, val float32)
- func (m *Mat2) Size() MatSize
- func (m *Mat2) String() string
- func (m *Mat2) Sub(m2 *Mat2) *Mat2
- func (m *Mat2) Transpose() *Mat2
- type Mat3
- func (m *Mat3) Add(m2 *Mat3) *Mat3
- func (m *Mat3) Clone() *Mat3
- func (m *Mat3) Col(c int) Vec3
- func (m *Mat3) Determinant() float32
- func (m *Mat3) Eq(m2 *Mat3) bool
- func (m *Mat3) Get(row, col int) float32
- func (m *Mat3) Invert() *Mat3
- func (m *Mat3) Mul(m2 *Mat3) *Mat3
- func (m *Mat3) Scale(x float32) *Mat3
- func (m *Mat3) Set(row, col int, val float32)
- func (m *Mat3) Size() MatSize
- func (m *Mat3) String() string
- func (m *Mat3) Sub(m2 *Mat3) *Mat3
- func (m *Mat3) ToMat2() Mat2
- func (m *Mat3) Transpose() *Mat3
- type Mat4
- func AddMat4(m1, m2 *Mat4) Mat4
- func MulMat4(m1, m2 *Mat4) Mat4
- func NewMat4Arr(col0, col1, col2, col3 [4]float32) *Mat4
- func NewMat4Diag(diagVal float32) Mat4
- func NewMat4DiagArr(diag [4]float32) Mat4
- func NewMat4Id() Mat4
- func NewMat4Vec4(col0, col1, col2, col3 *Vec4) Mat4
- func Perspective(fov, aspectRatio, nearClip, farClip float32) Mat4
- func SubMat4(m1, m2 *Mat4) Mat4
- func (m *Mat4) Add(m2 *Mat4) *Mat4
- func (v *Mat4) Clone() *Mat4
- func (m *Mat4) Col(c int) Vec4
- func (m *Mat4) Determinant() float32
- func (m *Mat4) Eq(m2 *Mat4) bool
- func (m *Mat4) Get(row, col int) float32
- func (m *Mat4) Invert() *Mat4
- func (m *Mat4) InvertAndTranspose() *Mat4
- func (m *Mat4) Mul(m2 *Mat4) *Mat4
- func (m *Mat4) Scale(x float32) *Mat4
- func (m *Mat4) Set(row, col int, val float32)
- func (m *Mat4) Size() MatSize
- func (m *Mat4) String() string
- func (m *Mat4) Sub(m2 *Mat4) *Mat4
- func (m *Mat4) ToMat2() Mat2
- func (m *Mat4) ToMat3() Mat3
- func (m *Mat4) Transpose() *Mat4
- type MatSize
- type Quat
- func NewQuat(x, y, z, w float32) Quat
- func NewQuatAngleAxis(rotRad float32, rotAxisNormX, rotAxisNormY, rotAxisNormZ float32) Quat
- func NewQuatAngleAxisVec(rotRad float32, rotAxisNorm *Vec3) Quat
- func NewQuatArr(arr [4]float32) Quat
- func NewQuatEuler(x, y, z float32) Quat
- func NewQuatEulerVec(v *Vec3) Quat
- func NewQuatId() Quat
- func NewQuatVec(v *Vec4) Quat
- type Swizzle1
- type Swizzle2
- type Swizzle3
- type Swizzle4
- type TrMat
- func LookAtLH(pos, targetPos, worldUp *Vec3) TrMat
- func LookAtRH(pos, targetPos, worldUp *Vec3) TrMat
- func NewRotMatQuat(q *Quat) TrMat
- func NewScaleMat(scaleX, scaleY, scaleZ float32) TrMat
- func NewScaleMatVec(v *Vec3) TrMat
- func NewTrMatId() TrMat
- func NewTrMatWithPos(x, y, z float32) TrMat
- func NewTrMatWithPosVec(pos *Vec3) TrMat
- func NewTranslationMat(posX, posY, posZ float32) TrMat
- func NewTranslationMatVec(v *Vec3) TrMat
- func Ortho(left, right, top, bottom, nearClip, farClip float32) TrMat
- func (t *TrMat) Clone() *TrMat
- func (t *TrMat) Eq(m *TrMat) bool
- func (t *TrMat) Mul(m *TrMat) *TrMat
- func (t *TrMat) Rotate(rads float32, axisX, axisY, axisZ float32) *TrMat
- func (t *TrMat) RotateVec(rads float32, axis *Vec3) *TrMat
- func (t *TrMat) Scale(x, y, z float32) *TrMat
- func (t *TrMat) ScaleVec(v *Vec3) *TrMat
- func (t *TrMat) Translate(x, y, z float32) *TrMat
- func (t *TrMat) TranslateVec(v *Vec3) *TrMat
- type Vec2
- func (v *Vec2) Add(v2 *Vec2) *Vec2
- func (v *Vec2) AddG(g float32)
- func (v *Vec2) AddR(r float32)
- func (v *Vec2) AddRG(r, g float32)
- func (v *Vec2) AddX(x float32)
- func (v *Vec2) AddXY(x, y float32)
- func (v *Vec2) AddY(y float32)
- func (v *Vec2) Clone() *Vec2
- func (v *Vec2) Eq(v2 *Vec2) bool
- func (v *Vec2) G() float32
- func (v *Vec2) Mag() float32
- func (v *Vec2) Normalize()
- func (v *Vec2) R() float32
- func (v *Vec2) Scale(x float32) *Vec2
- func (v *Vec2) ScaleArr(arr [2]float32) *Vec2
- func (v *Vec2) ScaleVec(v2 *Vec2) *Vec2
- func (v *Vec2) Set(x, y float32)
- func (v *Vec2) SetG(g float32)
- func (v *Vec2) SetR(r float32)
- func (v *Vec2) SetRG(r, g float32)
- func (v *Vec2) SetX(x float32)
- func (v *Vec2) SetXY(x, y float32)
- func (v *Vec2) SetY(y float32)
- func (v *Vec2) SqrMag() float32
- func (v *Vec2) String() string
- func (v *Vec2) Sub(v2 *Vec2) *Vec2
- func (v *Vec2) X() float32
- func (v *Vec2) Y() float32
- type Vec3
- func (v *Vec3) Add(v2 *Vec3) *Vec3
- func (v *Vec3) AddB(b float32)
- func (v *Vec3) AddG(g float32)
- func (v *Vec3) AddR(r float32)
- func (v *Vec3) AddRG(r, g float32)
- func (v *Vec3) AddRGB(r, g, b float32)
- func (v *Vec3) AddX(x float32)
- func (v *Vec3) AddXY(x, y float32)
- func (v *Vec3) AddXYZ(x, y, z float32)
- func (v *Vec3) AddY(y float32)
- func (v *Vec3) AddZ(z float32)
- func (v *Vec3) AsRad() *Vec3
- func (v *Vec3) B() float32
- func (v *Vec3) Clone() *Vec3
- func (v *Vec3) Eq(v2 *Vec3) bool
- func (v *Vec3) G() float32
- func (v *Vec3) Mag() float32
- func (v *Vec3) Normalize() *Vec3
- func (v *Vec3) R() float32
- func (v *Vec3) RotByQuat(q *Quat) *Vec3
- func (v *Vec3) Scale(x float32) *Vec3
- func (v *Vec3) ScaleArr(arr [3]float32) *Vec3
- func (v *Vec3) ScaleVec(v2 *Vec3) *Vec3
- func (v *Vec3) Set(x, y, z float32)
- func (v *Vec3) SetB(f float32)
- func (v *Vec3) SetG(f float32)
- func (v *Vec3) SetR(f float32)
- func (v *Vec3) SetRG(r, g float32)
- func (v *Vec3) SetRGB(r, g, b float32)
- func (v *Vec3) SetX(f float32)
- func (v *Vec3) SetXY(x, y float32)
- func (v *Vec3) SetXYZ(x, y, z float32)
- func (v *Vec3) SetY(f float32)
- func (v *Vec3) SetZ(f float32)
- func (v *Vec3) SqrMag() float32
- func (v *Vec3) String() string
- func (v *Vec3) Sub(v2 *Vec3) *Vec3
- func (v *Vec3) X() float32
- func (v *Vec3) Y() float32
- func (v *Vec3) Z() float32
- type Vec4
- func (v *Vec4) A() float32
- func (v *Vec4) Add(v2 *Vec4) *Vec4
- func (v *Vec4) AddA(a float32)
- func (v *Vec4) AddB(b float32)
- func (v *Vec4) AddG(g float32)
- func (v *Vec4) AddR(r float32)
- func (v *Vec4) AddRG(r, g float32)
- func (v *Vec4) AddRGB(r, g, b float32)
- func (v *Vec4) AddRGBA(r, g, b, a float32)
- func (v *Vec4) AddW(w float32)
- func (v *Vec4) AddX(x float32)
- func (v *Vec4) AddXY(x, y float32)
- func (v *Vec4) AddXYZ(x, y, z float32)
- func (v *Vec4) AddXYZW(x, y, z, w float32)
- func (v *Vec4) AddY(y float32)
- func (v *Vec4) AddZ(z float32)
- func (v *Vec4) B() float32
- func (v *Vec4) Clone() *Vec4
- func (v *Vec4) Eq(v2 *Vec4) bool
- func (v *Vec4) G() float32
- func (v *Vec4) Mag() float32
- func (v *Vec4) Normalize()
- func (v *Vec4) R() float32
- func (v *Vec4) Scale(x float32) *Vec4
- func (v *Vec4) ScaleArr(arr [4]float32) *Vec4
- func (v *Vec4) ScaleVec(v2 *Vec4) *Vec4
- func (v *Vec4) Set(x, y, z, w float32)
- func (v *Vec4) SetA(f float32)
- func (v *Vec4) SetB(f float32)
- func (v *Vec4) SetG(f float32)
- func (v *Vec4) SetR(f float32)
- func (v *Vec4) SetRG(r, g float32)
- func (v *Vec4) SetRGB(r, g, b float32)
- func (v *Vec4) SetRGBA(r, g, b, a float32)
- func (v *Vec4) SetW(f float32)
- func (v *Vec4) SetX(f float32)
- func (v *Vec4) SetXY(x, y float32)
- func (v *Vec4) SetXYZ(x, y, z float32)
- func (v *Vec4) SetXYZW(x, y, z, w float32)
- func (v *Vec4) SetY(f float32)
- func (v *Vec4) SetZ(f float32)
- func (v *Vec4) SqrMag() float32
- func (v *Vec4) String() string
- func (v *Vec4) Sub(v2 *Vec4) *Vec4
- func (v *Vec4) W() float32
- func (v *Vec4) X() float32
- func (v *Vec4) Y() float32
- func (v *Vec4) Z() float32
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func Clamp ¶ added in v0.50.0
func Clamp[T constraints.Ordered](x, min, max T) T
Clamp returns:
min if x<min max if x>max x if x>=min && x<=max
func EqF32Epsilon ¶ added in v0.0.8
EqF32Epsilon true if abs(f1-f2) <= eps
func SqrDistVec2 ¶ added in v0.0.4
DistVec2 returns the squared euclidean distance between v1 and v2 (avoids a sqrt)
func SqrDistVec3 ¶ added in v0.0.4
DistVec3 returns the squared euclidean distance between v1 and v2 (avoids a sqrt)
func SqrDistVec4 ¶ added in v0.0.5
DistVec4 returns the squared euclidean distance between v1 and v2 (avoids a sqrt)
Types ¶
type Mat2 ¶
type Mat2 struct {
Data [2][2]float32
}
func NewMat2Arr ¶ added in v0.45.0
func NewMat2Diag ¶ added in v0.45.0
func NewMat2DiagArr ¶ added in v0.45.0
func NewMat2Vec2 ¶ added in v0.45.0
func (*Mat2) Determinant ¶ added in v0.45.0
func (*Mat2) Invert ¶ added in v0.45.0
Invert inverts this matrix.
Note that the inverse is not defined if the determinant is zero or extremely small. In the case the determinant is zero the matrix will (usually) get filled with infinities
type Mat3 ¶
type Mat3 struct {
Data [3][3]float32
}
func NewMat3Arr ¶ added in v0.45.0
func NewMat3Diag ¶ added in v0.45.0
func NewMat3DiagArr ¶ added in v0.45.0
func NewMat3Vec3 ¶ added in v0.45.0
func (*Mat3) Determinant ¶ added in v0.45.0
func (*Mat3) Invert ¶ added in v0.45.0
Invert inverts this matrix.
Note that the inverse is not defined if the determinant is zero or extremely small. In the case the determinant is zero the matrix will (usually) get filled with infinities
type Mat4 ¶
type Mat4 struct {
Data [4][4]float32
}
func NewMat4Arr ¶ added in v0.45.0
func NewMat4Diag ¶ added in v0.45.0
func NewMat4DiagArr ¶ added in v0.45.0
func NewMat4Vec4 ¶ added in v0.45.0
func Perspective ¶ added in v0.2.1
Perspective creates a perspective projection matrix
func (*Mat4) Determinant ¶ added in v0.45.0
func (*Mat4) Invert ¶ added in v0.45.0
Invert inverts this matrix.
Note that the inverse is not defined if the determinant is zero or extremely small. In the case the determinant is zero the matrix will (usually) get filled with infinities
func (*Mat4) InvertAndTranspose ¶ added in v0.45.0
InvertAndTranspose is equivalent to m.Invert().Transpose(), that is invert first, then transpose the inverted matrix.
This function is provided as a convenience and as a small optimization, as it inlines the invert and transpose functions which means we only have 1 function call.
Additionally, the inverse of the matrix is written to the matrix immediately transposed instead of writing the inverse and then transposing it in a second operation.
func (*Mat4) ToMat2 ¶ added in v0.45.0
ToMat2 returns a Mat2 that contains the top-left 2x2 section of the Mat4. That is, columns 2 and 3, and rows 2 and 3, are dropped.
type Quat ¶ added in v0.1.0
type Quat struct {
Vec4
}
func NewQuatAngleAxis ¶ added in v0.1.0
NewQuatAngleAxis produces a quaternion thats rotates rotRad radians around the *normalized* vector rotAxisNorm
func NewQuatAngleAxisVec ¶ added in v0.46.0
NewQuatAngleAxisVec produces a quaternion thats rotates rotRad radians around the *normalized* vector rotAxisNorm
func NewQuatArr ¶ added in v0.46.0
func NewQuatEuler ¶ added in v0.1.0
NewQuatEuler takes rotations in radians and produces a rotation that rotates around the z-axis, y-axis and lastly x-axis.
func NewQuatEulerVec ¶ added in v0.46.0
NewQuatEulerVec takes rotations in radians and produces a rotation that rotates around the z-axis, y-axis and lastly x-axis.
func NewQuatVec ¶ added in v0.46.0
func (*Quat) Angle ¶ added in v0.3.0
Angle returns the angle represented by this quaternion in radians
type TrMat ¶ added in v0.1.0
type TrMat struct {
Mat4
}
TrMat represents a transformation matrix
func LookAtLH ¶ added in v0.42.0
LookAtLH does a left-handed coordinate system lookAt. Can be used to create the view matrix
func LookAtRH ¶ added in v0.42.0
LookAtRH does a right-handed coordinate system lookAt (RH is the default for OpenGL). Can be used to create the view matrix
func NewRotMatQuat ¶ added in v0.48.0
func NewScaleMat ¶ added in v0.1.0
func NewScaleMatVec ¶ added in v0.48.0
func NewTrMatId ¶ added in v0.1.1
func NewTrMatId() TrMat
func NewTrMatWithPos ¶ added in v0.49.0
func NewTrMatWithPosVec ¶ added in v0.49.0
func NewTranslationMat ¶ added in v0.1.0
func NewTranslationMatVec ¶ added in v0.48.0
func (*TrMat) Rotate ¶ added in v0.3.0
Rotate takes a *normalized* axis and angles in radians to rotate around the given axis
func (*TrMat) RotateVec ¶ added in v0.48.0
RotateVec takes a *normalized* axis and angles in radians to rotate around the given axis
func (*TrMat) Scale ¶ added in v0.1.0
Scale multiplies the scale components of the transformation matrix by v
func (*TrMat) ScaleVec ¶ added in v0.48.0
ScaleVec multiplies the scale components of the transformation matrix by v
func (*TrMat) Translate ¶ added in v0.1.0
Translate adds v to the translation components of the transformation matrix
func (*TrMat) TranslateVec ¶ added in v0.48.0
TranslateVec adds v to the translation components of the transformation matrix
type Vec2 ¶
type Vec2 struct {
Data [2]float32
}
func MulMat2Vec2 ¶ added in v0.0.6
MulMat2Vec2 v2 = m1 * v1
func NewVec2Arr ¶ added in v0.45.0
func ReflectVec2 ¶ added in v0.0.8
ReflectVec2 returns the reflected vector of the incoming vector 'v', and the surface normal 'n'.
Note: n must be normalized or you will get wrong results
type Vec3 ¶
type Vec3 struct {
Data [3]float32
}
func MulMat3Vec3 ¶ added in v0.0.6
MulMat3Vec3 v2 = m1 * v1
func NewVec3Arr ¶ added in v0.45.0
func ReflectVec3 ¶ added in v0.0.8
ReflectVec3 returns the reflected vector of the incoming vector 'v', and the surface normal 'n'.
Note: n must be normalized or you will get wrong results
func (*Vec3) AsRad ¶ added in v0.1.0
AsRad returns a new vector with all values converted to Radians (i.e. multiplied by gglm.Deg2Rad)
func (*Vec3) Normalize ¶ added in v0.0.6
Normalize normalizes this vector and returns it (doesn't copy)
type Vec4 ¶ added in v0.0.3
type Vec4 struct {
Data [4]float32
}
func MulMat4Vec4 ¶ added in v0.0.6
MulMat4Vec4 v2 = m1 * v1