Documentation
¶
Overview ¶
MathGL is a simple 3D math library written in Go which should help writing OpenGL code.
MathGL is a simple 3D math library written in Go which should help writing OpenGL code.
Index ¶
- Constants
- func Fabs32(f float32) float32
- func FalmostEqual32(lhs float32, rhs float32) bool
- func Fcos32(x float32) float32
- func Fdeg2rad32(degrees float32) float32
- func Fmax32(lhs float32, rhs float32) float32
- func Fmin32(lhs float32, rhs float32) float32
- func Frad2deg32(radians float32) float32
- func Fsin32(x float32) float32
- func Fsqr32(s float32) float32
- func Fsqrt32(x float32) float32
- type Mat3
- func (m *Mat3) Adjugate()
- func (m *Mat3) AreEqual(candidate *Mat3) bool
- func (m *Mat3) Assign(input *Mat3)
- func (m *Mat3) Determinant() float32
- func (m *Mat3) Fill(content float32)
- func (m *Mat3) Identity()
- func (m *Mat3) Inverse() bool
- func (m *Mat3) IsIdentity() bool
- func (m *Mat3) Multiply(in *Mat3)
- func (m *Mat3) RotationAxisAngle(axis Vec3, radians float32)
- func (m *Mat3) RotationX(radians float32)
- func (m *Mat3) RotationY(radians float32)
- func (m *Mat3) RotationZ(radians float32)
- func (m *Mat3) ScalarMultiply(factor float32)
- func (m *Mat3) Scaling(x, y float32)
- func (m *Mat3) Translation(x, y float32)
- func (m *Mat3) Transpose()
- type Mat4
- func (m *Mat4) AreEqual(candidate *Mat4) bool
- func (m *Mat4) Assign(input *Mat4)
- func (m *Mat4) Determinant() float32
- func (m *Mat4) ExtractRotation() *Mat3
- func (m *Mat4) Fill(content float32)
- func (m *Mat4) GetForwardVec3() *Vec3
- func (m *Mat4) GetRightVec3() *Vec3
- func (m *Mat4) GetUpVec3() *Vec3
- func (m *Mat4) Identity()
- func (m *Mat4) Inverse() bool
- func (m *Mat4) IsIdentity() bool
- func (m *Mat4) Multiply(in *Mat4)
- func (m *Mat4) RotationAxisAngle(axis Vec3, radians float32)
- func (m *Mat4) RotationPitchYawRoll(pitch, yaw, roll float32)
- func (m *Mat4) RotationTranslation(rotation *Mat3, translation *Vec3)
- func (m *Mat4) RotationX(radians float32)
- func (m *Mat4) RotationY(radians float32)
- func (m *Mat4) RotationZ(radians float32)
- func (m *Mat4) ScalarMultiply(factor float32)
- func (m *Mat4) Scaling(x, y, z float32)
- func (m *Mat4) Translation(x, y, z float32)
- func (m *Mat4) Transpose()
- type Plane
- type PlaneEnum
- type PointClassificationEnum
- type Poly
- type Seg2
- type Vec2
- func (v *Vec2) Add(x *Vec2)
- func (v *Vec2) AreEqual(x *Vec2) bool
- func (v *Vec2) Assign(x *Vec2)
- func (v *Vec2) Cross()
- func (v *Vec2) Dot(x *Vec2) float32
- func (v *Vec2) Fill(x, y float32)
- func (v *Vec2) Length() float32
- func (v *Vec2) LengthSq() float32
- func (v *Vec2) Normalize()
- func (v *Vec2) Scale(s float32)
- func (v *Vec2) String() string
- func (v *Vec2) Subtract(x *Vec2)
- func (v *Vec2) Transform(m *Mat3)
- func (v *Vec2) Zero()
- type Vec3
- func (v *Vec3) Add(x *Vec3)
- func (v *Vec3) AreEqual(x *Vec3) bool
- func (v *Vec3) Assign(x *Vec3)
- func (v *Vec3) Cross(x *Vec3)
- func (v *Vec3) Dot(x *Vec3) float32
- func (v *Vec3) Fill(x, y, z float32)
- func (v *Vec3) InverseTransform(m *Mat4)
- func (v *Vec3) InverseTransformNormal(m *Mat4)
- func (v *Vec3) Length() float32
- func (v *Vec3) LengthSq() float32
- func (v *Vec3) Normalize()
- func (v *Vec3) Scale(s float32)
- func (v *Vec3) String() string
- func (v *Vec3) Subtract(x *Vec3)
- func (v *Vec3) Transform(m *Mat4)
- func (v *Vec3) TransformArray(x []Vec4, m *Mat4)
- func (v *Vec3) TransformCoord(m *Mat4)
- func (v *Vec3) TransformNormal(m *Mat4)
- func (v *Vec3) Zero()
- type Vec4
- func (v *Vec4) Add(x *Vec4)
- func (v *Vec4) AreEqual(x *Vec4) bool
- func (v *Vec4) Assign(x *Vec4)
- func (v *Vec4) Cross(x *Vec4)
- func (v *Vec4) Dot(x *Vec4) float32
- func (v *Vec4) Fill(x, y, z, w float32)
- func (v *Vec4) Length() float32
- func (v *Vec4) LengthSq() float32
- func (v *Vec4) Normalize()
- func (v *Vec4) Scale(s float32)
- func (v *Vec4) String() string
- func (v *Vec4) Subtract(x *Vec4)
- func (v *Vec4) Transform(m *Mat4)
- func (v *Vec4) Zero()
Constants ¶
const ( PI float32 = 3.14159265358979323846264338327950288419716939937510582097494459 PIover180 float32 = 0.017453292519943295 PIunder180 float32 = 57.29577951308232 )
Some constants which are often used
Variables ¶
This section is empty.
Functions ¶
func FalmostEqual32 ¶
Returns true if two float32 are almost the same (the threshold is epsilon = 1/64).
func Fdeg2rad32 ¶
Returns the radius value from a given degree value given in float32.
func Frad2deg32 ¶
Returns the degrees value from a given radius value given in float32.
Types ¶
type Mat3 ¶
type Mat3 [9]float32
3x3 Matrix type. Column major.
func (*Mat3) Determinant ¶
Returns the calculated determinant from the matrix as float32.
func (*Mat3) IsIdentity ¶
Returns true if the matrix is a identity matrix.
func (*Mat3) RotationAxisAngle ¶
Sets the matrix to a matrix that rotates with the help of the given vector Vec3 and angle float32
func (*Mat3) ScalarMultiply ¶
Multiplies the matrix with a given scalar in float32.
func (*Mat3) Translation ¶
Set the matrix to a translation matrix, which translates with given x,y floats32
type Mat4 ¶
type Mat4 [16]float32
4x4 Matrix type. Column major.
func (*Mat4) Determinant ¶
Returns the calculated determinant from the matrix as float32.
func (*Mat4) ExtractRotation ¶
Extract a 3x3 rotation matrix from the input 4x4 transformation.
func (*Mat4) GetForwardVec3 ¶
Get the forward vector from a 4x4 matrix.
func (*Mat4) GetRightVec3 ¶
Get the right vector from a 4x4 matrix.
func (*Mat4) Inverse ¶
Inverse the matrix with the given determinant in float32. Returns true if the inverse could be build.
func (*Mat4) IsIdentity ¶
Returns true if the matrix is a identity matrix.
func (*Mat4) RotationAxisAngle ¶
Sets the matrix to a matrix that rotates with the help of the given vector Vec3 and angle float32
func (*Mat4) RotationPitchYawRoll ¶
Sets the matrix to a rotation matrix from pitch, yaw and roll.
func (*Mat4) RotationTranslation ¶
Sets the matrix to a transformation matrix using a 3x3 rotation matrix and a 3d vector representing a translation.
func (*Mat4) ScalarMultiply ¶
Multiplies the matrix with a given scalar in float32.
func (*Mat4) Translation ¶
Set the matrix to a translation matrix, which translates with given x,y floats32
type PointClassificationEnum ¶
type PointClassificationEnum int
const ( POINT_INFRONT_OF_PLANE PointClassificationEnum = iota POINT_BEHIND_PLANE POINT_ON_PLANE )
type Seg2 ¶
type Seg2 struct {
A, B Vec2
}
func (Seg2) DistFromOrigin ¶
type Vec2 ¶
type Vec2 struct {
X, Y float32
}
2 dimensional vector.
type Vec3 ¶
type Vec3 struct {
X, Y, Z float32
}
2 dimensional vector.
func (*Vec3) InverseTransform ¶
Transforms the Vec3 by a given Mat4 inversely
func (*Vec3) InverseTransformNormal ¶
Transforms a normal Vec3 with the given Mat4 matrix inversely. Omits the translation, only scaling + rotating
func (*Vec3) TransformArray ¶
/ Loops through an input slice transforming each Vec4 by the given Mat3
func (*Vec3) TransformCoord ¶
Transform a texture Vec3 with the given Mat4 matrix
func (*Vec3) TransformNormal ¶
Transform a normal Vec3 with the given Mat4 matrix. Omits the translation, only scaling + rotating
type Vec4 ¶
type Vec4 struct {
X, Y, Z, W float32
}
4 dimensional vector.
func (*Vec4) Cross ¶
Saves the Vec4 perpendicular to the given Vec4 (Attention: This is a Vec3 Cross Product in a homogeneous 4D environment!)