Documentation ¶
Index ¶
- Constants
- Variables
- func Dot(x1, y1, z1, w1, x2, y2, z2, w2 float32) float32
- func DotV2(x1, y1, x2, y2 float32) float32
- func DotV3(x1, y1, z1, x2, y2, z2 float32) float32
- func Dst2V2(x1, y1, x2, y2 float32) float32
- func Dst2V3(x1, y1, z1, x2, y2, z2 float32) float32
- func DstV2(x1, y1, x2, y2 float32) float32
- func DstV3(x1, y1, z1, x2, y2, z2 float32) float32
- func Len2Q(x, y, z, w float32) float32
- func Len2V2(x, y float32) float32
- func Len2V3(x, y, z float32) float32
- func LenQ(x, y, z, w float32) float32
- func LenV2(x, y float32) float32
- func LenV3(x, y, z float32) float32
- func MulM3(mata [9]float32, matb [9]float32)
- func MulM4(mata [16]float32, matb [16]float32)
- type Affine2
- func (self *Affine2) ApplyTo(point *Vector2)
- func (self *Affine2) Det() float32
- func (self *Affine2) GetTranslation(position *Vector2) *Vector2
- func (self *Affine2) Idt() *Affine2
- func (self *Affine2) Inv() *Affine2
- func (self *Affine2) IsIdt() bool
- func (self *Affine2) IsTranslation() bool
- func (self *Affine2) Mul(other *Affine2) *Affine2
- func (self *Affine2) PreMulA(other *Affine2) *Affine2
- func (self *Affine2) PreRotate(degrees float32) *Affine2
- func (self *Affine2) PreRotateRad(radians float32) *Affine2
- func (self *Affine2) PreScale(scaleX, scaleY float32) *Affine2
- func (self *Affine2) PreScaleV(scale *Vector2) *Affine2
- func (self *Affine2) PreShear(shearX, shearY float32) *Affine2
- func (self *Affine2) PreShearV(shear *Vector2) *Affine2
- func (self *Affine2) PreTranslate(x, y float32) *Affine2
- func (self *Affine2) PreTranslateV(trn *Vector2) *Affine2
- func (self *Affine2) Rotate(degrees float32) *Affine2
- func (self *Affine2) RotateRad(radians float32) *Affine2
- func (self *Affine2) Scale(scaleX, scaleY float32) *Affine2
- func (self *Affine2) ScaleV(scale *Vector2) *Affine2
- func (self *Affine2) Set(other *Affine2) *Affine2
- func (self *Affine2) SetM3(matrix *Matrix3) *Affine2
- func (self *Affine2) SetM4(matrix *Matrix4) *Affine2
- func (self *Affine2) SetToProduct(l, r *Affine2) *Affine2
- func (self *Affine2) SetToRotation(cos, sin float32) *Affine2
- func (self *Affine2) SetToRotationRad(radians float32) *Affine2
- func (self *Affine2) SetToScaling(scaleX, scaleY float32) *Affine2
- func (self *Affine2) SetToScalingV(scale *Vector2) *Affine2
- func (self *Affine2) SetToShearing(shearX, shearY float32) *Affine2
- func (self *Affine2) SetToShearingV(shear *Vector2) *Affine2
- func (self *Affine2) SetToTranslation(x, y float32) *Affine2
- func (self *Affine2) SetToTranslationV(trn *Vector2) *Affine2
- func (self *Affine2) SetToTrnRotRadScl(x, y, radians, scaleX, scaleY float32) *Affine2
- func (self *Affine2) SetToTrnRotRadSclV(trn *Vector2, radians float32, scale *Vector2) *Affine2
- func (self *Affine2) SetToTrnRotScl(x, y, degrees, scaleX, scaleY float32) *Affine2
- func (self *Affine2) SetToTrnRotSclV(trn *Vector2, degrees float32, scale *Vector2) *Affine2
- func (self *Affine2) SetToTrnScl(x, y, scaleX, scaleY float32) *Affine2
- func (self *Affine2) SetToTrnSclV(trn, scale *Vector2) *Affine2
- func (self *Affine2) Shear(shearX, shearY float32) *Affine2
- func (self *Affine2) ShearV(shear *Vector2) *Affine2
- func (self *Affine2) String() string
- func (self *Affine2) Translate(x, y float32) *Affine2
- func (self *Affine2) TranslateV(trn *Vector2) *Affine2
- type IVector
- type Matrix3
- func (self *Matrix3) Det() float32
- func (self *Matrix3) GetRotation() float32
- func (self *Matrix3) GetRotationRad() float32
- func (self *Matrix3) GetScale(scale *Vector2) *Vector2
- func (self *Matrix3) GetTranslation(position *Vector2) *Vector2
- func (self *Matrix3) GetValues() [9]float32
- func (self *Matrix3) Idt() *Matrix3
- func (self *Matrix3) Inv() *Matrix3
- func (self *Matrix3) Mul(m *Matrix3) *Matrix3
- func (self *Matrix3) MulLeft(m *Matrix3) *Matrix3
- func (self *Matrix3) Rotate(degrees float32) *Matrix3
- func (self *Matrix3) RotateRad(radians float32) *Matrix3
- func (self *Matrix3) Scale(scaleX, scaleY float32) *Matrix3
- func (self *Matrix3) ScaleV(scale *Vector2) *Matrix3
- func (self *Matrix3) Scl(scale float32) *Matrix3
- func (self *Matrix3) SclV(scale *Vector2) *Matrix3
- func (self *Matrix3) SclV3(scale *Vector3) *Matrix3
- func (self *Matrix3) Set(values [9]float32) *Matrix3
- func (self *Matrix3) SetA(affine *Affine2) *Matrix3
- func (self *Matrix3) SetM3(mat *Matrix3) *Matrix3
- func (self *Matrix3) SetM4(mat *Matrix4) *Matrix3
- func (self *Matrix3) SetToRotation(degrees float32) *Matrix3
- func (self *Matrix3) SetToRotationAxis(axis *Vector3, cos, sin float32) *Matrix3
- func (self *Matrix3) SetToRotationAxisDeg(axis *Vector3, degrees float32) *Matrix3
- func (self *Matrix3) SetToRotationRad(radians float32) *Matrix3
- func (self *Matrix3) SetToScaling(scaleX, scaleY float32) *Matrix3
- func (self *Matrix3) SetToScalingV(scale *Vector2) *Matrix3
- func (self *Matrix3) SetToTranslation(x, y float32) *Matrix3
- func (self *Matrix3) SetToTranslationV(translation *Vector2) *Matrix3
- func (self *Matrix3) String() string
- func (self *Matrix3) Translate(x, y float32) *Matrix3
- func (self *Matrix3) TranslateV(translation *Vector2) *Matrix3
- func (self *Matrix3) Transpose() *Matrix3
- func (self *Matrix3) Trn(x, y float32) *Matrix3
- func (self *Matrix3) TrnV(vector *Vector2) *Matrix3
- func (self *Matrix3) TrnV3(vector *Vector3) *Matrix3
- type Matrix4
- func (self *Matrix4) Avg(other *Matrix4, w float32) *Matrix4
- func (self *Matrix4) AvgM4(t []*Matrix4) *Matrix4
- func (self *Matrix4) AvgM4W(t []*Matrix4, w []float32) *Matrix4
- func (self *Matrix4) Copy() *Matrix4
- func (self *Matrix4) Det() float32
- func (self *Matrix4) Det3x3() float32
- func (self *Matrix4) Extract4x3Matrix(dst []float32)
- func (self *Matrix4) GetRotation(rotation *Quaternion, normalizeAxes bool) *Quaternion
- func (self *Matrix4) GetRotationQ(rotation *Quaternion) *Quaternion
- func (self *Matrix4) GetScale(scale *Vector3) *Vector3
- func (self *Matrix4) GetScaleX() float32
- func (self *Matrix4) GetScaleXSquared() float32
- func (self *Matrix4) GetScaleY() float32
- func (self *Matrix4) GetScaleYSquared() float32
- func (self *Matrix4) GetScaleZ() float32
- func (self *Matrix4) GetScaleZSquared() float32
- func (self *Matrix4) GetTranslation(position *Vector3) *Vector3
- func (self *Matrix4) GetValues() [16]float32
- func (self *Matrix4) Idt() *Matrix4
- func (self *Matrix4) Inv() *Matrix4
- func (self *Matrix4) Lerp(matrix *Matrix4, alpha float32) *Matrix4
- func (self *Matrix4) MulLeft(matrix *Matrix4) *Matrix4
- func (self *Matrix4) MulM4(matrix *Matrix4) *Matrix4
- func (self *Matrix4) RotateAxis(axisX, axisY, axisZ, degrees float32) *Matrix4
- func (self *Matrix4) RotateQ(rotation *Quaternion) *Matrix4
- func (self *Matrix4) RotateRad(axis *Vector3, radians float32) *Matrix4
- func (self *Matrix4) RotateRadAxis(axisX, axisY, axisZ, radians float32) *Matrix4
- func (self *Matrix4) RotateV3(v1, v2 *Vector3) *Matrix4
- func (self *Matrix4) RotateV3Axis(axis *Vector3, degrees float32) *Matrix4
- func (self *Matrix4) Scale(scaleX, scaleY, scaleZ float32) *Matrix4
- func (self *Matrix4) Scl(x, y, z float32) *Matrix4
- func (self *Matrix4) SclV(scale *Vector3) *Matrix4
- func (self *Matrix4) SclValue(scale float32) *Matrix4
- func (self *Matrix4) Set(tX, tY, tZ, qX, qY, qZ, qW, scaleX, scaleY, scaleZ float32) *Matrix4
- func (self *Matrix4) SetA2(affine *Affine2) *Matrix4
- func (self *Matrix4) SetAsAffine(affine *Affine2) *Matrix4
- func (self *Matrix4) SetAsAffineM4(mat *Matrix4) *Matrix4
- func (self *Matrix4) SetFromEulerAngles(yaw, pitch, roll float32) *Matrix4
- func (self *Matrix4) SetFromEulerAnglesRad(yaw, pitch, roll float32) *Matrix4
- func (self *Matrix4) SetM3(mat *Matrix3) *Matrix4
- func (self *Matrix4) SetM4(matrix *Matrix4) *Matrix4
- func (self *Matrix4) SetQ(quaternion *Quaternion) *Matrix4
- func (self *Matrix4) SetQR(qX, qY, qZ, qW float32) *Matrix4
- func (self *Matrix4) SetTQ(tX, tY, tZ, qX, qY, qZ, qW float32) *Matrix4
- func (self *Matrix4) SetToLookAt(direction, up *Vector3) *Matrix4
- func (self *Matrix4) SetToLookAtPos(position, target, up *Vector3) *Matrix4
- func (self *Matrix4) SetToOrtho(left, right, bottom, top, near, far float32) *Matrix4
- func (self *Matrix4) SetToOrtho2D(x, y, width, height float32) *Matrix4
- func (self *Matrix4) SetToOrtho2DNear(x, y, width, height, near, far float32) *Matrix4
- func (self *Matrix4) SetToProjectionLeft(left, right, bottom, top, near, far float32) *Matrix4
- func (self *Matrix4) SetToProjectionNear(near, far, fovy, aspectRatio float32) *Matrix4
- func (self *Matrix4) SetToRotation(x1, y1, z1, x2, y2, z2 float32) *Matrix4
- func (self *Matrix4) SetToRotationAxis(axisX, axisY, axisZ, degrees float32) *Matrix4
- func (self *Matrix4) SetToRotationRad(axisX, axisY, axisZ, radians float32) *Matrix4
- func (self *Matrix4) SetToRotationRadV3(axis *Vector3, radians float32) *Matrix4
- func (self *Matrix4) SetToRotationV(v1, v2 *Vector3) *Matrix4
- func (self *Matrix4) SetToRotationV3(axis *Vector3, degrees float32) *Matrix4
- func (self *Matrix4) SetToScaling(x, y, z float32) *Matrix4
- func (self *Matrix4) SetToScalingV3(vector *Vector3) *Matrix4
- func (self *Matrix4) SetToTranslation(x, y, z float32) *Matrix4
- func (self *Matrix4) SetToTranslationAndScaling(translationX, tY, tZ, scalingX, scalingY, scalingZ float32) *Matrix4
- func (self *Matrix4) SetToTranslationAndScalingV3(translation, scaling *Vector3) *Matrix4
- func (self *Matrix4) SetToTranslationV3(vector *Vector3) *Matrix4
- func (self *Matrix4) SetToWorld(position, forward, up *Vector3) *Matrix4
- func (self *Matrix4) SetTranslation(x, y, z float32) *Matrix4
- func (self *Matrix4) SetTranslationV3(vector *Vector3) *Matrix4
- func (self *Matrix4) SetV(position *Vector3, orientation *Quaternion) *Matrix4
- func (self *Matrix4) SetVAxis(xAxis, yAxis, zAxis, pos *Vector3) *Matrix4
- func (self *Matrix4) SetVRS(p *Vector3, orient *Quaternion, scale *Vector3) *Matrix4
- func (self *Matrix4) SetValues(values [16]float32) *Matrix4
- func (self *Matrix4) String() string
- func (self *Matrix4) ToNormalMatrix() *Matrix4
- func (self *Matrix4) Tra() *Matrix4
- func (self *Matrix4) Translate(x, y, z float32) *Matrix4
- func (self *Matrix4) TranslateV(translation *Vector3) *Matrix4
- func (self *Matrix4) Trn(x, y, z float32) *Matrix4
- func (self *Matrix4) TrnV(vector *Vector3) *Matrix4
- type Path
- type Quaternion
- func (self *Quaternion) Add(qx, qy, qz, qw float32) *Quaternion
- func (self *Quaternion) AddQ(quaternion *Quaternion) *Quaternion
- func (self *Quaternion) Conjugate() *Quaternion
- func (self *Quaternion) Copy() *Quaternion
- func (self *Quaternion) Dot(x, y, z, w float32) float32
- func (self *Quaternion) DotQ(other *Quaternion) float32
- func (self *Quaternion) Exp(alpha float32) *Quaternion
- func (self *Quaternion) GetAngle() float32
- func (self *Quaternion) GetAngleAround(axisX, axisY, axisZ float32) float32
- func (self *Quaternion) GetAngleAroundRad(axisX, axisY, axisZ float32) float32
- func (self *Quaternion) GetAngleAroundRadV(axis *Vector3) float32
- func (self *Quaternion) GetAngleAroundV(axis *Vector3) float32
- func (self *Quaternion) GetAngleRad() float32
- func (self *Quaternion) GetAxisAngle(axis *Vector3) float32
- func (self *Quaternion) GetAxisAngleRad(axis *Vector3) float32
- func (self *Quaternion) GetGimbalPole() int
- func (self *Quaternion) GetPitch() float32
- func (self *Quaternion) GetPitchRad() float32
- func (self *Quaternion) GetRoll() float32
- func (self *Quaternion) GetRollRad() float32
- func (self *Quaternion) GetSwingTwist(axisX, axisY, axisZ float32, swing, twist *Quaternion)
- func (self *Quaternion) GetSwingTwistV(axis *Vector3, swing, twist *Quaternion)
- func (self *Quaternion) GetYaw() float32
- func (self *Quaternion) GetYawRad() float32
- func (self *Quaternion) Idt() *Quaternion
- func (self *Quaternion) IsIdentity() bool
- func (self *Quaternion) IsIdentityTolerance(tolerance float32) bool
- func (self *Quaternion) Len() float32
- func (self *Quaternion) Len2() float32
- func (self *Quaternion) Mul(x, y, z, w float32) *Quaternion
- func (self *Quaternion) MulLeft(x, y, z, w float32) *Quaternion
- func (self *Quaternion) MulLeftQ(other *Quaternion) *Quaternion
- func (self *Quaternion) MulQ(other *Quaternion) *Quaternion
- func (self *Quaternion) MulScalar(scalar float32) *Quaternion
- func (self *Quaternion) Nor() *Quaternion
- func (self *Quaternion) Set(x, y, z, w float32) *Quaternion
- func (self *Quaternion) SetEulerAngles(yaw, pitch, roll float32) *Quaternion
- func (self *Quaternion) SetEulerAnglesRad(yaw, pitch, roll float32) *Quaternion
- func (self *Quaternion) SetFromAxes(xx, xy, xz, yx, yy, yz, zx, zy, zz float32) *Quaternion
- func (self *Quaternion) SetFromAxesNormalize(normalizeAxes bool, xx, xy, xz, yx, yy, yz, zx, zy, zz float32) *Quaternion
- func (self *Quaternion) SetFromAxis(x, y, z, degrees float32) *Quaternion
- func (self *Quaternion) SetFromAxisRad(x, y, z, radians float32) *Quaternion
- func (self *Quaternion) SetFromAxisRadV3(axis *Vector3, radians float32) *Quaternion
- func (self *Quaternion) SetFromAxisV3(axis *Vector3, degrees float32) *Quaternion
- func (self *Quaternion) SetFromCross(x1, y1, z1, x2, y2, z2 float32) *Quaternion
- func (self *Quaternion) SetFromCrossV3(v1, v2 *Vector3) *Quaternion
- func (self *Quaternion) SetFromMatrixM3(matrix *Matrix3) *Quaternion
- func (self *Quaternion) SetFromMatrixM3Normalize(normalizeAxes bool, matrix *Matrix3) *Quaternion
- func (self *Quaternion) SetFromMatrixM4(matrix *Matrix4) *Quaternion
- func (self *Quaternion) SetFromMatrixM4Normalize(normalizeAxes bool, matrix *Matrix4) *Quaternion
- func (self *Quaternion) SetQ(quaternion *Quaternion) *Quaternion
- func (self *Quaternion) SetV3(axis *Vector3, angle float32) *Quaternion
- func (self *Quaternion) Slerp(end *Quaternion, alpha float32) *Quaternion
- func (self *Quaternion) SlerpQ(q []*Quaternion) *Quaternion
- func (self *Quaternion) SlerpW(q []*Quaternion, w []float32) *Quaternion
- func (self *Quaternion) String() string
- func (self *Quaternion) ToMatrix(matrix [16]float32)
- func (self *Quaternion) Transform(v *Vector3) *Vector3
- type Vector2
- func (self *Vector2) Add(x, y float32) *Vector2
- func (self *Vector2) AddV(v *Vector2) *Vector2
- func (self *Vector2) Angle() float32
- func (self *Vector2) AngleRad() float32
- func (self *Vector2) AngleRadVector2(reference *Vector2) float32
- func (self *Vector2) AngleVector2(reference *Vector2) float32
- func (self *Vector2) Clamp(min, max float32) *Vector2
- func (self *Vector2) Copy() *Vector2
- func (self *Vector2) Crs(x, y float32) float32
- func (self *Vector2) CrsV(v *Vector2) float32
- func (self *Vector2) Dot(ox, oy float32) float32
- func (self *Vector2) DotV(v *Vector2) float32
- func (self *Vector2) Dst(x, y float32) float32
- func (self *Vector2) Dst2(x, y float32) float32
- func (self *Vector2) Dst2V(v *Vector2) float32
- func (self *Vector2) DstV(v *Vector2) float32
- func (self *Vector2) EpsilonEquals(x, y, epsilon float32) bool
- func (self *Vector2) EpsilonEqualsV(other *Vector2, epsilon float32) bool
- func (self *Vector2) Equals(v *Vector2) bool
- func (self *Vector2) HasOppositeDirection(v *Vector2) bool
- func (self *Vector2) HasSameDirection(v *Vector2) bool
- func (self *Vector2) HashCode() int
- func (self *Vector2) Interpolate(target *Vector2, alpha float32, interpolation Interpolation) *Vector2
- func (self *Vector2) IsCollinear(other *Vector2) bool
- func (self *Vector2) IsCollinearEpsilon(other *Vector2, epsilon float32) bool
- func (self *Vector2) IsCollinearOpposite(other *Vector2) bool
- func (self *Vector2) IsCollinearOppositeEpsilon(other *Vector2, epsilon float32) bool
- func (self *Vector2) IsOnLine(other *Vector2) bool
- func (self *Vector2) IsOnLineEpsilon(other *Vector2, epsilon float32) bool
- func (self *Vector2) IsPerpendicular(v *Vector2) bool
- func (self *Vector2) IsPerpendicularEpsilon(vector *Vector2, epsilon float32) bool
- func (self *Vector2) IsUnit() bool
- func (self *Vector2) IsUnitMargin(margin float32) bool
- func (self *Vector2) IsZero() bool
- func (self *Vector2) IsZeroMargin(margin float32) bool
- func (self *Vector2) Len() float32
- func (self *Vector2) Len2() float32
- func (self *Vector2) Lerp(target *Vector2, alpha float32) *Vector2
- func (self *Vector2) Limit(limit float32) *Vector2
- func (self *Vector2) Limit2(limit2 float32) *Vector2
- func (self *Vector2) Mul(mat Matrix3) *Vector2
- func (self *Vector2) MulAdd(v *Vector2, mulVec *Vector2) *Vector2
- func (self *Vector2) MulAddScalar(v *Vector2, scalar float32) *Vector2
- func (self *Vector2) Nor() *Vector2
- func (self *Vector2) Rotate(degrees float32) *Vector2
- func (self *Vector2) Rotate90(dir int) *Vector2
- func (self *Vector2) RotateRad(radians float32) *Vector2
- func (self *Vector2) Scl(x, y float32) *Vector2
- func (self *Vector2) SclScalar(scalar float32) *Vector2
- func (self *Vector2) SclV(v *Vector2) *Vector2
- func (self *Vector2) Set(x, y float32) *Vector2
- func (self *Vector2) SetAngle(degrees float32) *Vector2
- func (self *Vector2) SetAngleRad(radians float32) *Vector2
- func (self *Vector2) SetLength(length float32) *Vector2
- func (self *Vector2) SetLength2(len2 float32) *Vector2
- func (self *Vector2) SetV(v *Vector2) *Vector2
- func (self *Vector2) SetZero() *Vector2
- func (self *Vector2) String() string
- func (self *Vector2) Sub(x, y float32) *Vector2
- func (self *Vector2) SubV(v *Vector2) *Vector2
- type Vector3
- func (self *Vector3) Add(x, y, z float32) *Vector3
- func (self *Vector3) AddV(vector *Vector3) *Vector3
- func (self *Vector3) AddValue(value float32) *Vector3
- func (self *Vector3) Clamp(min, max float32) *Vector3
- func (self *Vector3) Copy() *Vector3
- func (self *Vector3) Crs(x, y, z float32) *Vector3
- func (self *Vector3) CrsV(vector *Vector3) *Vector3
- func (self *Vector3) Dot(x, y, z float32) float32
- func (self *Vector3) DotV(vector *Vector3) float32
- func (self *Vector3) Dst(x, y, z float32) float32
- func (self *Vector3) Dst2V(point *Vector3) float32
- func (self *Vector3) Dst2V3(x, y, z float32) float32
- func (self *Vector3) DstV(vector *Vector3) float32
- func (self *Vector3) EpsilonEquals(x, y, z, epsilon float32) bool
- func (self *Vector3) EpsilonEqualsV(other *Vector3, epsilon float32) bool
- func (self *Vector3) HasOppositeDirection(vector *Vector3) bool
- func (self *Vector3) HasSameDirection(vector *Vector3) bool
- func (self *Vector3) Idt(vector *Vector3) bool
- func (self *Vector3) Interpolate(target *Vector3, alpha float32, interpolator interpolation.Interpolation) *Vector3
- func (self *Vector3) IsCollinear(other *Vector3) bool
- func (self *Vector3) IsCollinearEpsilon(other *Vector3, epsilon float32) bool
- func (self *Vector3) IsCollinearOpposite(other *Vector3) bool
- func (self *Vector3) IsCollinearOppositeEpsilon(other *Vector3, epsilon float32) bool
- func (self *Vector3) IsOnLine(other *Vector3) bool
- func (self *Vector3) IsOnLineEpsilon(other *Vector3, epsilon float32) bool
- func (self *Vector3) IsPerpendicular(vector *Vector3) bool
- func (self *Vector3) IsPerpendicularEpsilon(vector *Vector3, epsilon float32) bool
- func (self *Vector3) IsUnit() bool
- func (self *Vector3) IsUnitMargin(margin float32) bool
- func (self *Vector3) IsZero() bool
- func (self *Vector3) IsZeroMargin(margin float32) bool
- func (self *Vector3) Len() float32
- func (self *Vector3) Len2() float32
- func (self *Vector3) Lerp(target *Vector3, alpha float32) *Vector3
- func (self *Vector3) Limit(limit float32) *Vector3
- func (self *Vector3) Limit2(limit2 float32) *Vector3
- func (self *Vector3) Mul(matrix *Matrix4) *Vector3
- func (self *Vector3) Mul4x3(matrix []float32) *Vector3
- func (self *Vector3) MulAdd(vec *Vector3, scalar float32) *Vector3
- func (self *Vector3) MulAddV(vec, mulVec *Vector3) *Vector3
- func (self *Vector3) MulM3(matrix *Matrix3) *Vector3
- func (self *Vector3) MulQ(quat *Quaternion) *Vector3
- func (self *Vector3) Nor() *Vector3
- func (self *Vector3) Prj(matrix *Matrix4) *Vector3
- func (self *Vector3) Rot(matrix *Matrix4) *Vector3
- func (self *Vector3) Rotate(degrees, axisX, axisY, axisZ float32) *Vector3
- func (self *Vector3) RotateRad(radians, axisX, axisY, axisZ float32) *Vector3
- func (self *Vector3) RotateRadV(axis *Vector3, radians float32) *Vector3
- func (self *Vector3) RotateV(axis *Vector3, degrees float32) *Vector3
- func (self *Vector3) Scl(vx, vy, vz float32) *Vector3
- func (self *Vector3) SclScalar(scalar float32) *Vector3
- func (self *Vector3) SclV(other *Vector3) *Vector3
- func (self *Vector3) Set(x, y, z float32) *Vector3
- func (self *Vector3) SetLength(length float32) *Vector3
- func (self *Vector3) SetLength2(len2 float32) *Vector3
- func (self *Vector3) SetV(vector *Vector3) *Vector3
- func (self *Vector3) SetVZ(vector *Vector2, z float32) *Vector3
- func (self *Vector3) SetValues(values []float32) *Vector3
- func (self *Vector3) SetZero() *Vector3
- func (self *Vector3) Slerp(target *Vector3, alpha float32) *Vector3
- func (self *Vector3) String() string
- func (self *Vector3) Sub(x, y, z float32) *Vector3
- func (self *Vector3) SubV(a_vec *Vector3) *Vector3
- func (self *Vector3) SubValue(value float32) *Vector3
- func (self *Vector3) TraMul(matrix *Matrix4) *Vector3
- func (self *Vector3) TraMulM3(matrix *Matrix3) *Vector3
- func (self *Vector3) Unrotate(matrix *Matrix4) *Vector3
- func (self *Vector3) Untransform(matrix *Matrix4) *Vector3
Constants ¶
const ( M3_00 = 0 M3_01 = 3 M3_02 = 6 M3_10 = 1 M3_11 = 4 M3_12 = 7 M3_20 = 2 M3_21 = 5 M3_22 = 8 )
const ( // XX: Typically the unrotated X component for scaling, also the cosine of the angle when rotated on the Y and/or Z axis. On // Vector3 multiplication this value is multiplied with the source X component and added to the target X component. M4_00 = 0 // XY: Typically the negative sine of the angle when rotated on the Z axis. On Vector3 multiplication this value is multiplied // with the source Y component and added to the target X component. M4_01 = 4 // XZ: Typically the sine of the angle when rotated on the Y axis. On Vector3 multiplication this value is multiplied with the // source Z component and added to the target X component. M4_02 = 8 // XW: Typically the translation of the X component. On Vector3 multiplication this value is added to the target X component. M4_03 = 12 // YX: Typically the sine of the angle when rotated on the Z axis. On Vector3 multiplication this value is multiplied with the // source X component and added to the target Y component. M4_10 = 1 // YY: Typically the unrotated Y component for scaling, also the cosine of the angle when rotated on the X and/or Z axis. On // Vector3 multiplication this value is multiplied with the source Y component and added to the target Y component. M4_11 = 5 // YZ: Typically the negative sine of the angle when rotated on the X axis. On Vector3 multiplication this value is multiplied // with the source Z component and added to the target Y component. M4_12 = 9 // YW: Typically the translation of the Y component. On Vector3 multiplication this value is added to the target Y component. M4_13 = 13 // ZX: Typically the negative sine of the angle when rotated on the Y axis. On Vector3 multiplication this value is multiplied // with the source X component and added to the target Z component. M4_20 = 2 // ZY: Typical the sine of the angle when rotated on the X axis. On Vector3 multiplication this value is multiplied with the // source Y component and added to the target Z component. M4_21 = 6 // ZZ: Typically the unrotated Z component for scaling, also the cosine of the angle when rotated on the X and/or Y axis. On // Vector3 multiplication this value is multiplied with the source Z component and added to the target Z component. M4_22 = 10 // ZW: Typically the translation of the Z component. On Vector3 multiplication this value is added to the target Z component. M4_23 = 14 // WX: Typically the value zero. On Vector3 multiplication this value is ignored. M4_30 = 3 // WY: Typically the value zero. On Vector3 multiplication this value is ignored. M4_31 = 7 // WZ: Typically the value zero. On Vector3 multiplication this value is ignored. M4_32 = 11 // WW: Typically the value one. On Vector3 multiplication this value is ignored. M4_33 = 15 )
Variables ¶
var ( XV2 = NewVector2(1, 0) YV2 = NewVector2(0, 1) ZeroV2 = NewVector2(0, 0) )
var ( XV3 = NewVector3(1, 0, 0) YV3 = NewVector3(0, 1, 0) ZV3 = NewVector3(0, 0, 1) ZeroV3 = NewVector3(0, 0, 0) )
Functions ¶
func Dot ¶
Get the dot product between the two quaternions (commutative). param x1 the x component of the first quaternion param y1 the y component of the first quaternion param z1 the z component of the first quaternion param w1 the w component of the first quaternion param x2 the x component of the second quaternion param y2 the y component of the second quaternion param z2 the z component of the second quaternion param w2 the w component of the second quaternion return the dot product between the first and second quaternion.
func MulM3 ¶
Multiplies matrix a with matrix b in the following manner: mul(A, B) => A := AB mata The float array representing the first matrix. Must have at least 9 elements. matb The float array representing the second matrix. Must have at least 9 elements.
func MulM4 ¶
JNI TO GO Multiplies the matrix mata with matrix matb, storing the result in mata. The arrays are assumed to hold 4x4 column major matrices as you can get from {@link Matrix4#val}. This is the same as {@link Matrix4#mul(Matrix4)}.
param mata the first matrix. param matb the second matrix. public static native void mul (float[] mata, float[] matb) /*-{ }; /* matrix4_mul(mata, matb);
Types ¶
type Affine2 ¶
type Affine2 struct {
// contains filtered or unexported fields
}
A specialized 3x3 matrix that can represent sequences of 2D translations, scales, flips, rotations, and shears. <a href="http://en.wikipedia.org/wiki/Affine_transformation">Affine transformations</a> preserve straight lines, and parallel lines remain parallel after the transformation. Operations on affine matrices are faster because the last row can always be assumed (0, 0, 1).
func NewAffine2Copy ¶
Constructs a matrix from the given affine matrix. @param other The affine matrix to copy. This matrix will not be modified.
func (*Affine2) Det ¶
Calculates the determinant of the matrix. return The determinant of this matrix.
func (*Affine2) GetTranslation ¶
Get the x-y translation component of the matrix. param position Output vector. return Filled position.
func (*Affine2) Idt ¶
Sets this matrix to the identity matrix return This matrix for the purpose of chaining operations.
func (*Affine2) Inv ¶
Inverts this matrix given that the determinant is != 0. return This matrix for the purpose of chaining operations. @throws GdxRuntimeException if the matrix is singular (not invertible)
func (*Affine2) IsIdt ¶
Check if this is an indentity matrix. return True if scale is 1 and rotation is 0.
func (*Affine2) IsTranslation ¶
Check if the this is a plain translation matrix. return True if scale is 1 and rotation is 0.
func (*Affine2) Mul ¶
Postmultiplies this matrix with the provided matrix and stores the result in this matrix. For example: A.mul(B) results in A := AB param other Matrix to multiply by. return This matrix for the purpose of chaining operations together.
func (*Affine2) PreMulA ¶
Premultiplies this matrix with the provided matrix and stores the result in this matrix. For example: A.preMul(B) results in A := BA param other The other Matrix to multiply by return This matrix for the purpose of chaining operations.
func (*Affine2) PreRotate ¶
Premultiplies this matrix with a (counter-clockwise) rotation matrix. param degrees The angle in degrees return This matrix for the purpose of chaining.
func (*Affine2) PreRotateRad ¶
Premultiplies this matrix with a (counter-clockwise) rotation matrix. param radians The angle in radians return This matrix for the purpose of chaining.
func (*Affine2) PreScale ¶
Premultiplies this matrix with a scale matrix. param scaleX The scale in the x-axis. param scaleY The scale in the y-axis. return This matrix for the purpose of chaining.
func (*Affine2) PreScaleV ¶
Premultiplies this matrix with a scale matrix. param scale The scale vector. return This matrix for the purpose of chaining.
func (*Affine2) PreShear ¶
Premultiplies this matrix by a shear matrix. param shearX The shear in x direction. param shearY The shear in y direction. return This matrix for the purpose of chaining.
func (*Affine2) PreShearV ¶
Premultiplies this matrix by a shear matrix. param shear The shear vector. return This matrix for the purpose of chaining.
func (*Affine2) PreTranslate ¶
Premultiplies this matrix by a translation matrix. param x The x-component of the translation vector. param y The y-component of the translation vector. return This matrix for the purpose of chaining.
func (*Affine2) PreTranslateV ¶
Premultiplies this matrix by a translation matrix. param trn The translation vector. return This matrix for the purpose of chaining.
func (*Affine2) Rotate ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. param degrees The angle in degrees return This matrix for the purpose of chaining.
func (*Affine2) RotateRad ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. param radians The angle in radians return This matrix for the purpose of chaining.
func (*Affine2) Scale ¶
Postmultiplies this matrix with a scale matrix. param scaleX The scale in the x-axis. param scaleY The scale in the y-axis. return This matrix for the purpose of chaining.
func (*Affine2) ScaleV ¶
Postmultiplies this matrix with a scale matrix. param scale The scale vector. return This matrix for the purpose of chaining.
func (*Affine2) Set ¶
Copies the values from the provided affine matrix to this matrix. param other The affine matrix to copy. return This matrix for the purposes of chaining.
func (*Affine2) SetM3 ¶
Copies the values from the provided matrix to this matrix. param matrix The matrix to copy, assumed to be an affine transformation. return This matrix for the purposes of chaining.
func (*Affine2) SetM4 ¶
Copies the 2D transformation components from the provided 4x4 matrix. The values are mapped as follows:
[ M00 M01 M03 ] [ M10 M11 M13 ] [ 0 0 1 ]
param matrix The source matrix, assumed to be an affine transformation within XY plane. This matrix will not be modified. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToProduct ¶
Sets this matrix to the product of two matrices. param l Left matrix. param r Right matrix. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToRotation ¶
Sets this matrix to a rotation matrix that will rotate any vector in counter-clockwise direction around the z-axis. param cos The angle cosine. param sin The angle sine. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToRotationRad ¶
Sets this matrix to a rotation matrix that will rotate any vector in counter-clockwise direction around the z-axis. param radians The angle in radians. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToScaling ¶
Sets this matrix to a scaling matrix. param scaleX The scale in x. param scaleY The scale in y. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToScalingV ¶
Sets this matrix to a scaling matrix. param scale The scale vector. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToShearing ¶
Sets this matrix to a shearing matrix. param shearX The shear in x direction. param shearY The shear in y direction. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToShearingV ¶
Sets this matrix to a shearing matrix. param shear The shear vector. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTranslation ¶
Sets this matrix to a translation matrix. param x The translation in x param y The translation in y return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTranslationV ¶
Sets this matrix to a translation matrix. param trn The translation vector. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTrnRotRadScl ¶
Sets this matrix to a concatenation of translation, rotation and scale. It is a more efficient form for: <code>idt().translate(x, y).rotateRad(radians).scale(scaleX, scaleY)</code> param x The translation in x. param y The translation in y. param radians The angle in radians. param scaleX The scale in y. param scaleY The scale in x. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTrnRotRadSclV ¶
Sets this matrix to a concatenation of translation, rotation and scale. It is a more efficient form for: <code>idt().translate(trn).rotateRad(radians).scale(scale)</code> param trn The translation vector. param radians The angle in radians. param scale The scale vector. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTrnRotScl ¶
Sets this matrix to a concatenation of translation, rotation and scale. It is a more efficient form for: <code>idt().translate(x, y).rotate(degrees).scale(scaleX, scaleY)</code> param x The translation in x. param y The translation in y. param degrees The angle in degrees. param scaleX The scale in y. param scaleY The scale in x. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTrnRotSclV ¶
Sets this matrix to a concatenation of translation, rotation and scale. It is a more efficient form for: <code>idt().translate(trn).rotate(degrees).scale(scale)</code> param trn The translation vector. param degrees The angle in degrees. param scale The scale vector. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTrnScl ¶
Sets this matrix to a concatenation of translation and scale. It is a more efficient form for: <code>idt().translate(x, y).scale(scaleX, scaleY)</code> param x The translation in x. param y The translation in y. param scaleX The scale in y. param scaleY The scale in x. return This matrix for the purpose of chaining operations.
func (*Affine2) SetToTrnSclV ¶
Sets this matrix to a concatenation of translation and scale. It is a more efficient form for: idt().translate(trn).scale(scale)</code> param trn The translation vector. param scale The scale vector. return This matrix for the purpose of chaining operations.
func (*Affine2) Shear ¶
Postmultiplies this matrix by a shear matrix. param shearX The shear in x direction. param shearY The shear in y direction. return This matrix for the purpose of chaining.
func (*Affine2) ShearV ¶
Postmultiplies this matrix by a shear matrix. param shear The shear vector. return This matrix for the purpose of chaining.
func (*Affine2) Translate ¶
Postmultiplies this matrix by a translation matrix. param x The x-component of the translation vector. param y The y-component of the translation vector. return This matrix for the purpose of chaining.
func (*Affine2) TranslateV ¶
Postmultiplies this matrix by a translation matrix. param trn The translation vector. return This matrix for the purpose of chaining.
type IVector ¶
type IVector interface { /** @return a copy of this vector */ Copy() interface{} /** @return The euclidean length */ Len() float32 /** This method is faster than {@link Vector#len()} because it avoids calculating a square root. It is useful for comparisons, * but not for getting exact lengths, as the return value is the square of the actual length. * @return The squared euclidean length */ Len2() float32 /** Limits the length of this vector, based on the desired maximum length. * @param limit desired maximum length for this vector * @return this vector for chaining */ Limit(limit float32) interface{} /** Limits the length of this vector, based on the desired maximum length squared. * <p /> * This method is slightly faster than limit(). * @param limit2 squared desired maximum length for this vector * @return this vector for chaining * @see #len2() */ Limit2(limit2 float32) interface{} /** Sets the length of this vector. Does nothing is this vector is zero. * @param len desired length for this vector * @return this vector for chaining */ SetLength(length float32) interface{} /** Sets the length of this vector, based on the square of the desired length. Does nothing is this vector is zero. * <p /> * This method is slightly faster than setLength(). * @param len2 desired square of the length for this vector * @return this vector for chaining * @see #len2() */ SetLength2(length2 float32) interface{} /** Clamps this vector's length to given min and max values * @param min Min length * @param max Max length * @return This vector for chaining */ Clamp(min, max float32) interface{} /** Sets this vector from the given vector * @param v The vector * @return This vector for chaining */ SetV(v interface{}) interface{} /** Subtracts the given vector from this vector. * @param v The vector * @return This vector for chaining */ SubV(v interface{}) interface{} /** Normalizes this vector. Does nothing if it is zero. * @return This vector for chaining */ Nor() interface{} /** Adds the given vector to this vector * @param v The vector * @return This vector for chaining */ AddV(v interface{}) interface{} /** @param v The other vector * @return The dot product between this and the other vector */ DotV(v interface{}) float32 /** Scales this vector by a scalar * @param scalar The scalar * @return This vector for chaining */ SclScalar(scalar float32) interface{} /** Scales this vector by another vector * @return This vector for chaining */ SclV(v interface{}) interface{} /** @param v The other vector * @return the distance between this and the other vector */ DstV(v interface{}) float32 /** This method is faster than {@link Vector#dst(Vector)} because it avoids calculating a square root. It is useful for * comparisons, but not for getting accurate distances, as the return value is the square of the actual distance. * @param v The other vector * @return the squared distance between this and the other vector */ Dst2V(v interface{}) float32 /** Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored * in this vector. * @param target The target vector * @param alpha The interpolation coefficient * @return This vector for chaining. */ Lerp(target interface{}, alpha float32) interface{} /** Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation * method. the result is stored in this vector. * @param target The target vector * @param alpha The interpolation coefficient * @param interpolator An Interpolation object describing the used interpolation method * @return This vector for chaining. */ Interpolate(target interface{}, alpha float32, interpolation Interpolation) interface{} /** @return Whether this vector is a unit length vector */ IsUnit() bool /** @return Whether this vector is a unit length vector within the given margin. */ IsUnitMargin(margin float32) bool /** @return Whether this vector is a zero vector */ IsZero() bool /** @return Whether the length of this vector is smaller than the given margin */ IsZeroMargin(margin float32) bool /** @return true if this vector is in line with the other vector (either in the same or the opposite direction) */ IsOnLine(other interface{}) bool /** @return true if this vector is in line with the other vector (either in the same or the opposite direction) */ IsOnLineEpsilon(other interface{}, epsilon float32) /** @return true if this vector is collinear with the other vector ({@link #isOnLine(Vector, float)} && * {@link #hasSameDirection(Vector)}). */ IsCollinearEpsilon(other interface{}, epsilon float32) bool /** @return true if this vector is collinear with the other vector ({@link #isOnLine(Vector)} && * {@link #hasSameDirection(Vector)}). */ IsCollinear(other interface{}) bool /** @return true if this vector is opposite collinear with the other vector ({@link #isOnLine(Vector, float)} && * {@link #hasOppositeDirection(Vector)}). */ IsCollinearOppositeEpsilon(other interface{}, epsilon float32) bool /** @return true if this vector is opposite collinear with the other vector ({@link #isOnLine(Vector)} && * {@link #hasOppositeDirection(Vector)}). */ IsCollinearOpposite(other interface{}) bool /** @return Whether this vector is perpendicular with the other vector. True if the dot product is 0. */ IsPerpendicular(v interface{}) bool /** @return Whether this vector is perpendicular with the other vector. True if the dot product is 0. * @param epsilon a positive small number close to zero */ IsPerpendicularEpsilon(vector interface{}, epsilon float32) bool /** @return Whether this vector has similar direction compared to the other vector. True if the normalized dot product is > 0. */ HasSameDirection(v interface{}) bool /** @return Whether this vector has opposite direction compared to the other vector. True if the normalized dot product is < 0. */ HasOppositeDirection(v interface{}) bool /** Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. * @param other * @param epsilon * @return whether the vectors have fuzzy equality. */ EpsilonEqualsV(other interface{}, epsilon float32) bool /** First scale a supplied vector, then add it to this vector. * @param v addition vector * @param scalar for scaling the addition vector */ MulAddScalar(v interface{}, scalar float32) interface{} /** First scale a supplied vector, then add it to this vector. * @param v addition vector * @param mulVec vector by whose values the addition vector will be scaled */ MulAdd(v interface{}, mulVec interface{}) interface{} /** Sets the components of this vector to 0 * @return This vector for chaining */ SetZero() interface{} }
* Encapsulates a general vector. Allows chaining operations by returning a reference to itself in all modification methods. See
- {@link Vector2} and {@link Vector3} for specific implementations.
- @author Xoppa
type Matrix3 ¶
type Matrix3 struct {
// contains filtered or unexported fields
}
A 3x3 http://en.wikipedia.org/wiki/Row-major_order#Column-major_order column major matrix; useful for 2D transforms.
func NewMatrix ¶
Constructs a matrix from the given float array. The array must have at least 9 elements; the first 9 will be copied. values The float array to copy. Remember that this matrix is in href="http://en.wikipedia.org/wiki/Row-major_order#Column-major_order olumn major order. (The float array is not modified.)
func NewMatrixCopy ¶
func NewMatrixEmpty ¶
func NewMatrixEmpty() *Matrix3
func (*Matrix3) GetRotation ¶
func (*Matrix3) GetRotationRad ¶
func (*Matrix3) GetTranslation ¶
func (*Matrix3) GetValues ¶
Get the values in this matrix. return The float values that make up this matrix in column-major order.
func (*Matrix3) Idt ¶
Sets this matrix to the identity matrix return This matrix for the purpose of chaining operations.
func (*Matrix3) Inv ¶
Inverts this matrix given that the determinant is != 0. return This matrix for the purpose of chaining operations. panics if the matrix is singular (not invertible)
func (*Matrix3) Mul ¶
Postmultiplies this matrix with the provided matrix and stores the result in this matrix. For example: A.mul(B) results in A := AB m Matrix to multiply by. return This matrix for the purpose of chaining operations together.
func (*Matrix3) MulLeft ¶
Premultiplies this matrix with the provided matrix and stores the result in this matrix. For example: A.mulLeft(B) results in A := BA m The other Matrix to multiply by return This matrix for the purpose of chaining operations.
func (*Matrix3) Rotate ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. degrees The angle in degrees return This matrix for the purpose of chaining.
func (*Matrix3) RotateRad ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. radians The angle in radians return This matrix for the purpose of chaining.
func (*Matrix3) Scale ¶
Postmultiplies this matrix with a scale matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. scaleX The scale in the x-axis. scaleY The scale in the y-axis. return This matrix for the purpose of chaining.
func (*Matrix3) ScaleV ¶
Postmultiplies this matrix with a scale matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. scale The vector to scale the matrix by. return This matrix for the purpose of chaining.
func (*Matrix3) Scl ¶
Scale the matrix in the both the x and y components by the scalar value. scale The single value that will be used to scale both the x and y components. return This matrix for the purpose of chaining methods together.
func (*Matrix3) SclV ¶
Scale this matrix using the x and y components of the vector but leave the rest of the matrix alone. scale The {@link Vector3} to use to scale this matrix. return This matrix for the purpose of chaining methods together.
func (*Matrix3) SclV3 ¶
Scale this matrix using the x and y components of the vector but leave the rest of the matrix alone. scale The {@link Vector3} to use to scale this matrix. The z component will be ignored. return This matrix for the purpose of chaining methods together.
func (*Matrix3) Set ¶
Sets the matrix to the given matrix as a float array. The float array must have at least 9 elements; the first 9 will be copied. values The matrix, in float form, that is to be copied. Remember that this matrix is in http://en.wikipedia.org/wiki/Row-major_order#Column-major_order column major order. return This matrix for the purpose of chaining methods together.
func (*Matrix3) SetA ¶
Copies the values from the provided affine matrix to this matrix. The last row is set to (0, 0, 1). affine The affine matrix to copy. return This matrix for the purposes of chaining.
func (*Matrix3) SetM3 ¶
Copies the values from the provided matrix to this matrix. mat The matrix to copy. return This matrix for the purposes of chaining.
func (*Matrix3) SetM4 ¶
Sets this 3x3 matrix to the top left 3x3 corner of the provided 4x4 matrix. mat The matrix whose top left corner will be copied. This matrix will not be modified. return This matrix for the purpose of chaining operations.
func (*Matrix3) SetToRotation ¶
Sets this matrix to a rotation matrix that will rotate any vector in counter-clockwise direction around the z-axis. degrees the angle in degrees. return This matrix for the purpose of chaining operations.
func (*Matrix3) SetToRotationAxis ¶
func (*Matrix3) SetToRotationAxisDeg ¶
func (*Matrix3) SetToRotationRad ¶
Sets this matrix to a rotation matrix that will rotate any vector in counter-clockwise direction around the z-axis. radians the angle in radians. return This matrix for the purpose of chaining operations.
func (*Matrix3) SetToScaling ¶
Sets this matrix to a scaling matrix. scaleX the scale in x scaleY the scale in y return This matrix for the purpose of chaining operations.
func (*Matrix3) SetToScalingV ¶
Sets this matrix to a scaling matrix. scale The scale vector. return This matrix for the purpose of chaining operations.
func (*Matrix3) SetToTranslation ¶
Sets this matrix to a translation matrix. x the translation in x y the translation in y return This matrix for the purpose of chaining operations.
func (*Matrix3) SetToTranslationV ¶
Sets this matrix to a translation matrix. translation The translation vector. return This matrix for the purpose of chaining operations.
func (*Matrix3) Translate ¶
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. x The x-component of the translation vector. y The y-component of the translation vector. return This matrix for the purpose of chaining.
func (*Matrix3) TranslateV ¶
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. translation The translation vector. return This matrix for the purpose of chaining.
func (*Matrix3) Transpose ¶
Transposes the current matrix. return This matrix for the purpose of chaining methods together.
func (*Matrix3) Trn ¶
Adds a translational component to the matrix in the 3rd column. The other columns are untouched. x The x-component of the translation vector. y The y-component of the translation vector. return This matrix for the purpose of chaining.
func (*Matrix3) TrnV ¶
Adds a translational component to the matrix in the 3rd column. The other columns are untouched. vector The translation vector. return This matrix for the purpose of chaining.
type Matrix4 ¶
type Matrix4 struct {
// contains filtered or unexported fields
}
Encapsulates a <a href="http://en.wikipedia.org/wiki/Row-major_order#Column-major_order">column major</a> 4 by 4 matrix. Like the {@link Vector3} class it allows the chaining of methods by returning a reference to itself. For example: Matrix4 mat = new Matrix4().trn(position).mul(camera.combined);
func NewMatrix4 ¶
Constructs a matrix from the given float array. The array must have at least 16 elements; the first 16 will be copied. param values The float array to copy. Remember that this matrix is in http://en.wikipedia.org/wiki/Row-major_order column major order. (The float array is not modified)
func NewMatrix4Copy ¶
Constructs a matrix from the given matrix. param matrix The matrix to copy. (This matrix is not modified)
func NewMatrix4Q ¶
func NewMatrix4Q(quaternion *Quaternion) *Matrix4
Constructs a rotation matrix from the given {@link Quaternion}. param quaternion The quaternion to be copied. (The quaternion is not modified)
func NewMatrix4V ¶
func NewMatrix4V(position *Vector3, rotation *Quaternion, scale *Vector3) *Matrix4
Construct a matrix from the given translation, rotation and scale. param position The translation param rotation The rotation, must be normalized param scale The scale
func (*Matrix4) Avg ¶
Averages the given transform with this one and stores the result in this matrix. Translations and scales are lerped while rotations are slerped. param other The other transform param w Weight of this transform; weight of the other transform is (1 - w)
func (*Matrix4) AvgM4 ¶
Averages the given transforms and stores the result in this matrix. Translations and scales are lerped while rotations are slerped. Does not destroy the data contained in t. param t List of transforms
func (*Matrix4) AvgM4W ¶
Averages the given transforms with the given weights and stores the result in this matrix. Translations and scales are lerped while rotations are slerped. Does not destroy the data contained in t or w; Sum of w_i must be equal to 1, or unexpected results will occur. param t List of transforms param w List of weights
func (*Matrix4) Extract4x3Matrix ¶
Copies the 4x3 upper-left sub-matrix into float array. The destination array is supposed to be a column major matrix. param dst the destination matrix
func (*Matrix4) GetRotation ¶
func (self *Matrix4) GetRotation(rotation *Quaternion, normalizeAxes bool) *Quaternion
Gets the rotation of this matrix. param rotation The {@link Quaternion} to receive the rotation param normalizeAxes True to normalize the axes, necessary when the matrix might also include scaling. return The provided {@link Quaternion} for chaining.
func (*Matrix4) GetRotationQ ¶
func (self *Matrix4) GetRotationQ(rotation *Quaternion) *Quaternion
Gets the rotation of this matrix. param rotation The {@link Quaternion} to receive the rotation @return The provided {@link Quaternion} for chaining.
func (*Matrix4) GetScale ¶
param scale The vector which will receive the (non-negative) scale components on each axis. return The provided vector for chaining.
func (*Matrix4) GetScaleXSquared ¶
@return the squared scale factor on the X axis
func (*Matrix4) GetScaleYSquared ¶
@return the squared scale factor on the Y axis
func (*Matrix4) GetScaleZSquared ¶
@return the squared scale factor on the Z axis
func (*Matrix4) GetTranslation ¶
func (*Matrix4) Inv ¶
Inverts the matrix. Stores the result in this matrix. @throws RuntimeException if the matrix is singular (not invertible)
func (*Matrix4) Lerp ¶
Linearly interpolates between this matrix and the given matrix mixing by alpha param matrix the matrix param alpha the alpha value in the range [0,1]
func (*Matrix4) MulLeft ¶
Premultiplies this matrix with the given matrix, storing the result in this matrix. For example:
A.mulLeft(B) results in A := BA.
param matrix The other matrix to multiply by.
func (*Matrix4) MulM4 ¶
Postmultiplies this matrix with the given matrix, storing the result in this matrix. For example:
A.mul(B) results in A := AB.
param matrix The other matrix to multiply by.
func (*Matrix4) RotateAxis ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale param axisX The x-axis component of the vector to rotate around. param axisY The y-axis component of the vector to rotate around. param axisZ The z-axis component of the vector to rotate around. param degrees The angle in degrees
func (*Matrix4) RotateQ ¶
func (self *Matrix4) RotateQ(rotation *Quaternion) *Matrix4
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.
param rotation
func (*Matrix4) RotateRad ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.
param axis The vector axis to rotate around. param radians The angle in radians.
func (*Matrix4) RotateRadAxis ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale param axisX The x-axis component of the vector to rotate around. param axisY The y-axis component of the vector to rotate around. param axisZ The z-axis component of the vector to rotate around. param radians The angle in radians
func (*Matrix4) RotateV3 ¶
Postmultiplies this matrix by the rotation between two vectors. param v1 The base vector param v2 The target vector
func (*Matrix4) RotateV3Axis ¶
Postmultiplies this matrix with a (counter-clockwise) rotation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale.
param axis The vector axis to rotate around. param degrees The angle in degrees.
func (*Matrix4) Scale ¶
Postmultiplies this matrix with a scale matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. param scaleX The scale in the x-axis. param scaleY The scale in the y-axis. param scaleZ The scale in the z-axis.
func (*Matrix4) Set ¶
Sets the matrix to a rotation matrix representing the translation and quaternion. param tX The X component of the translation that is to be used to set this matrix. param tY The Y component of the translation that is to be used to set this matrix. param tZ The Z component of the translation that is to be used to set this matrix. param qX The X component of the quaternion that is to be used to set this matrix. param qY The Y component of the quaternion that is to be used to set this matrix. param qZ The Z component of the quaternion that is to be used to set this matrix. param qW The W component of the quaternion that is to be used to set this matrix. param scaleX The X component of the scaling that is to be used to set this matrix. param scaleY The Y component of the scaling that is to be used to set this matrix. param scaleZ The Z component of the scaling that is to be used to set this matrix.
func (*Matrix4) SetA2 ¶
Sets this matrix to the given affine matrix. The values are mapped as follows:
[ M4_00 M4_01 0 M4_02 ] [ M4_10 M4_11 0 M4_12 ] [ 0 0 1 0 ] [ 0 0 0 1 ]
param affine the affine matrix
func (*Matrix4) SetAsAffine ¶
Assumes that this matrix is a 2D affine transformation, copying only the relevant components. The values are mapped as follows:
[ M4_00 M4_01 _ M4_02 ] [ M4_10 M4_11 _ M4_12 ] [ _ _ _ _ ] [ _ _ _ _ ]
param affine the source matrix
func (*Matrix4) SetAsAffineM4 ¶
Assumes that both matrices are 2D affine transformations, copying only the relevant components. The copied values are:
[ M4_00 M4_01 _ M4_03 ] [ M4_10 M4_11 _ M4_13 ] [ _ _ _ _ ] [ _ _ _ _ ]
param mat the source matrix
func (*Matrix4) SetFromEulerAngles ¶
Sets this matrix to a rotation matrix from the given euler angles. param yaw the yaw in degrees param pitch the pitch in degrees param roll the roll in degrees
func (*Matrix4) SetFromEulerAnglesRad ¶
Sets this matrix to a rotation matrix from the given euler angles. param yaw the yaw in radians param pitch the pitch in radians param roll the roll in radians
func (*Matrix4) SetM3 ¶
Sets this matrix to the given 3x3 matrix. The third column of this matrix is set to (0,0,1,0). param mat the matrix
func (*Matrix4) SetM4 ¶
Sets the matrix to the given matrix. param matrix The matrix that is to be copied. (The given matrix is not modified)
func (*Matrix4) SetQ ¶
func (self *Matrix4) SetQ(quaternion *Quaternion) *Matrix4
Sets the matrix to a rotation matrix representing the quaternion. param quaternion The quaternion that is to be used to set this matrix.
func (*Matrix4) SetQR ¶
Sets the matrix to a rotation matrix representing the quaternion. param qX The X component of the quaternion that is to be used to set this matrix. param qY The Y component of the quaternion that is to be used to set this matrix. param qZ The Z component of the quaternion that is to be used to set this matrix. param qW The W component of the quaternion that is to be used to set this matrix.
func (*Matrix4) SetTQ ¶
Sets the matrix to a rotation matrix representing the translation and quaternion. param tX The X component of the translation that is to be used to set this matrix. param tY The Y component of the translation that is to be used to set this matrix. param tZ The Z component of the translation that is to be used to set this matrix. param qX The X component of the quaternion that is to be used to set this matrix. param qY The Y component of the quaternion that is to be used to set this matrix. param qZ The Z component of the quaternion that is to be used to set this matrix. param qW The W component of the quaternion that is to be used to set this matrix.
func (*Matrix4) SetToLookAt ¶
Sets the matrix to a look at matrix with a direction and an up vector. Multiply with a translation matrix to get a camera model view matrix.
param direction The direction vector param up The up vector
func (*Matrix4) SetToLookAtPos ¶
Sets this matrix to a look at matrix with the given position, target and up vector.
param position the position param target the target param up the up vector
func (*Matrix4) SetToOrtho ¶
Sets the matrix to an orthographic projection like glOrtho (http://www.opengl.org/sdk/docs/man/xhtml/glOrtho.xml) following the OpenGL equivalent
param left The left clipping plane param right The right clipping plane param bottom The bottom clipping plane param top The top clipping plane param near The near clipping plane param far The far clipping plane
func (*Matrix4) SetToOrtho2D ¶
Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height. The near plane is set to 0, the far plane is set to 1.
param x The x-coordinate of the origin param y The y-coordinate of the origin param width The width param height The height
func (*Matrix4) SetToOrtho2DNear ¶
Sets this matrix to an orthographic projection matrix with the origin at (x,y) extending by width and height, having a near and far plane.
param x The x-coordinate of the origin param y The y-coordinate of the origin param width The width param height The height param near The near plane param far The far plane
func (*Matrix4) SetToProjectionLeft ¶
Sets the matrix to a projection matrix with a near/far plane, and left, bottom, right and top specifying the points on the near plane that are mapped to the lower left and upper right corners of the viewport. This allows to create projection matrix with off-center vanishing point.
param left param right param bottom param top param near The near plane param far The far plane
func (*Matrix4) SetToProjectionNear ¶
Sets the matrix to a projection matrix with a near- and far plane, a field of view in degrees and an aspect ratio. Note that the field of view specified is the angle in degrees for the height, the field of view for the width will be calculated according to the aspect ratio.
param near The near plane param far The far plane param fovy The field of view of the height in degrees param aspectRatio The "width over height" aspect ratio
func (*Matrix4) SetToRotation ¶
Set the matrix to a rotation matrix between two vectors. param x1 The base vectors x value param y1 The base vectors y value param z1 The base vectors z value param x2 The target vector x value param y2 The target vector y value param z2 The target vector z value
func (*Matrix4) SetToRotationAxis ¶
Sets the matrix to a rotation matrix around the given axis.
param axisX The x-component of the axis param axisY The y-component of the axis param axisZ The z-component of the axis param degrees The angle in degrees
func (*Matrix4) SetToRotationRad ¶
Sets the matrix to a rotation matrix around the given axis.
param axisX The x-component of the axis param axisY The y-component of the axis param axisZ The z-component of the axis param radians The angle in radians
func (*Matrix4) SetToRotationRadV3 ¶
Sets the matrix to a rotation matrix around the given axis.
param axis The axis param radians The angle in radians
func (*Matrix4) SetToRotationV ¶
Set the matrix to a rotation matrix between two vectors. param v1 The base vector param v2 The target vector
func (*Matrix4) SetToRotationV3 ¶
Sets the matrix to a rotation matrix around the given axis.
param axis The axis param degrees The angle in degrees
func (*Matrix4) SetToScaling ¶
Sets this matrix to a scaling matrix
param x The x-component of the scaling vector param y The y-component of the scaling vector param z The z-component of the scaling vector.
func (*Matrix4) SetToScalingV3 ¶
Sets this matrix to a scaling matrix param vector The scaling vector.
func (*Matrix4) SetToTranslation ¶
Sets this matrix to a translation matrix, overwriting it first by an identity matrix and then setting the 4th column to the translation vector.
param x The x-component of the translation vector. param y The y-component of the translation vector. param z The z-component of the translation vector.
func (*Matrix4) SetToTranslationAndScaling ¶
func (self *Matrix4) SetToTranslationAndScaling(translationX, tY, tZ, scalingX, scalingY, scalingZ float32) *Matrix4
Sets this matrix to a translation and scaling matrix by first overwriting it with an identity and then setting the translation vector in the 4th column and the scaling vector in the diagonal.
param tX The x-component of the translation vector param tY The y-component of the translation vector param tZ The z-component of the translation vector param scalingX The x-component of the scaling vector param scalingY The x-component of the scaling vector param scalingZ The x-component of the scaling vector
func (*Matrix4) SetToTranslationAndScalingV3 ¶
Sets this matrix to a translation and scaling matrix by first overwriting it with an identity and then setting the translation vector in the 4th column and the scaling vector in the diagonal.
param translation The translation vector param scaling The scaling vector
func (*Matrix4) SetToTranslationV3 ¶
Sets this matrix to a translation matrix, overwriting it first by an identity matrix and then setting the 4th column to the translation vector.
param vector The translation vector
func (*Matrix4) SetToWorld ¶
func (*Matrix4) SetTranslation ¶
Sets the 4th column to the translation vector.
param x The X coordinate of the translation vector param y The Y coordinate of the translation vector param z The Z coordinate of the translation vector
func (*Matrix4) SetTranslationV3 ¶
Sets the 4th column to the translation vector.
param vector The translation vector
func (*Matrix4) SetV ¶
func (self *Matrix4) SetV(position *Vector3, orientation *Quaternion) *Matrix4
Set this matrix to the specified translation and rotation. param position The translation param orientation The rotation, must be normalized
func (*Matrix4) SetVAxis ¶
Sets the four columns of the matrix which correspond to the x-, y- and z-axis of the vector space this matrix creates as well as the 4th column representing the translation of any point that is multiplied by this matrix. param xAxis The x-axis. param yAxis The y-axis. param zAxis The z-axis. param pos The translation vector.
func (*Matrix4) SetVRS ¶
func (self *Matrix4) SetVRS(p *Vector3, orient *Quaternion, scale *Vector3) *Matrix4
Set this matrix to the specified translation, rotation and scale. param p The translation param orient The rotation, must be normalized param scale The scale
func (*Matrix4) SetValues ¶
Sets the matrix to the given matrix as a float array. The float array must have at least 16 elements; the first 16 will be copied. param values The matrix, in float form, that is to be copied. Remember that this matrix is in http://en.wikipedia.org/wiki/Row-major_order column major order.
func (*Matrix4) ToNormalMatrix ¶
removes the translational part and transposes the matrix.
func (*Matrix4) Translate ¶
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' 1.x glTranslate/glRotate/glScale. param x Translation in the x-axis. param y Translation in the y-axis. param z Translation in the z-axis.
func (*Matrix4) TranslateV ¶
@off JNI #include <memory.h> #include <stdio.h> #include <string.h>
#define M4_00 0 #define M4_01 4 #define M4_02 8 #define M4_03 12 #define M4_10 1 #define M4_11 5 #define M4_12 9 #define M4_13 13 #define M4_20 2 #define M4_21 6 #define M4_22 10 #define M4_23 14 #define M4_30 3 #define M4_31 7 #define M4_32 11 #define M4_33 15
static inline void matrix4_mul(float* mata, float* matb) *Matrix4 { float tmp[16]; tmp[M4_00] = mata[M4_00] * matb[M4_00] + mata[M4_01] * matb[M4_10] + mata[M4_02] * matb[M4_20] + mata[M4_03] * matb[M4_30]; tmp[M4_01] = mata[M4_00] * matb[M4_01] + mata[M4_01] * matb[M4_11] + mata[M4_02] * matb[M4_21] + mata[M4_03] * matb[M4_31]; tmp[M4_02] = mata[M4_00] * matb[M4_02] + mata[M4_01] * matb[M4_12] + mata[M4_02] * matb[M4_22] + mata[M4_03] * matb[M4_32]; tmp[M4_03] = mata[M4_00] * matb[M4_03] + mata[M4_01] * matb[M4_13] + mata[M4_02] * matb[M4_23] + mata[M4_03] * matb[M4_33]; tmp[M4_10] = mata[M4_10] * matb[M4_00] + mata[M4_11] * matb[M4_10] + mata[M4_12] * matb[M4_20] + mata[M4_13] * matb[M4_30]; tmp[M4_11] = mata[M4_10] * matb[M4_01] + mata[M4_11] * matb[M4_11] + mata[M4_12] * matb[M4_21] + mata[M4_13] * matb[M4_31]; tmp[M4_12] = mata[M4_10] * matb[M4_02] + mata[M4_11] * matb[M4_12] + mata[M4_12] * matb[M4_22] + mata[M4_13] * matb[M4_32]; tmp[M4_13] = mata[M4_10] * matb[M4_03] + mata[M4_11] * matb[M4_13] + mata[M4_12] * matb[M4_23] + mata[M4_13] * matb[M4_33]; tmp[M4_20] = mata[M4_20] * matb[M4_00] + mata[M4_21] * matb[M4_10] + mata[M4_22] * matb[M4_20] + mata[M4_23] * matb[M4_30]; tmp[M4_21] = mata[M4_20] * matb[M4_01] + mata[M4_21] * matb[M4_11] + mata[M4_22] * matb[M4_21] + mata[M4_23] * matb[M4_31]; tmp[M4_22] = mata[M4_20] * matb[M4_02] + mata[M4_21] * matb[M4_12] + mata[M4_22] * matb[M4_22] + mata[M4_23] * matb[M4_32]; tmp[M4_23] = mata[M4_20] * matb[M4_03] + mata[M4_21] * matb[M4_13] + mata[M4_22] * matb[M4_23] + mata[M4_23] * matb[M4_33]; tmp[M4_30] = mata[M4_30] * matb[M4_00] + mata[M4_31] * matb[M4_10] + mata[M4_32] * matb[M4_20] + mata[M4_33] * matb[M4_30]; tmp[M4_31] = mata[M4_30] * matb[M4_01] + mata[M4_31] * matb[M4_11] + mata[M4_32] * matb[M4_21] + mata[M4_33] * matb[M4_31]; tmp[M4_32] = mata[M4_30] * matb[M4_02] + mata[M4_31] * matb[M4_12] + mata[M4_32] * matb[M4_22] + mata[M4_33] * matb[M4_32]; tmp[M4_33] = mata[M4_30] * matb[M4_03] + mata[M4_31] * matb[M4_13] + mata[M4_32] * matb[M4_23] + mata[M4_33] * matb[M4_33]; memcpy(mata, tmp, sizeof(float) * 16); }
static inline float matrix4_det(float* val) *Matrix4 { return val[M4_30] * val[M4_21] * val[M4_12] * val[M4_03] - val[M4_20] * val[M4_31] * val[M4_12] * val[M4_03] - val[M4_30] * val[M4_11] * val[M4_22] * val[M4_03] + val[M4_10] * val[M4_31] * val[M4_22] * val[M4_03] + val[M4_20] * val[M4_11] * val[M4_32] * val[M4_03] - val[M4_10] * val[M4_21] * val[M4_32] * val[M4_03] - val[M4_30] * val[M4_21] * val[M4_02] * val[M4_13] + val[M4_20] * val[M4_31] * val[M4_02] * val[M4_13] + val[M4_30] * val[M4_01] * val[M4_22] * val[M4_13] - val[M4_00] * val[M4_31] * val[M4_22] * val[M4_13] - val[M4_20] * val[M4_01] * val[M4_32] * val[M4_13] + val[M4_00] * val[M4_21] * val[M4_32] * val[M4_13] + val[M4_30] * val[M4_11] * val[M4_02] * val[M4_23] - val[M4_10] * val[M4_31] * val[M4_02] * val[M4_23] - val[M4_30] * val[M4_01] * val[M4_12] * val[M4_23] + val[M4_00] * val[M4_31] * val[M4_12] * val[M4_23] + val[M4_10] * val[M4_01] * val[M4_32] * val[M4_23] - val[M4_00] * val[M4_11] * val[M4_32] * val[M4_23] - val[M4_20] * val[M4_11] * val[M4_02] * val[M4_33] + val[M4_10] * val[M4_21] * val[M4_02] * val[M4_33] + val[M4_20] * val[M4_01] * val[M4_12] * val[M4_33] - val[M4_00] * val[M4_21] * val[M4_12] * val[M4_33] - val[M4_10] * val[M4_01] * val[M4_22] * val[M4_33] + val[M4_00] * val[M4_11] * val[M4_22] * val[M4_33]; }
static inline bool matrix4_inv(float* val) *Matrix4 { float tmp[16]; float l_det = matrix4_det(val); if (l_det == 0) return false; tmp[M4_00] = val[M4_12] * val[M4_23] * val[M4_31] - val[M4_13] * val[M4_22] * val[M4_31] + val[M4_13] * val[M4_21] * val[M4_32] - val[M4_11] * val[M4_23] * val[M4_32] - val[M4_12] * val[M4_21] * val[M4_33] + val[M4_11] * val[M4_22] * val[M4_33]; tmp[M4_01] = val[M4_03] * val[M4_22] * val[M4_31] - val[M4_02] * val[M4_23] * val[M4_31] - val[M4_03] * val[M4_21] * val[M4_32] + val[M4_01] * val[M4_23] * val[M4_32] + val[M4_02] * val[M4_21] * val[M4_33] - val[M4_01] * val[M4_22] * val[M4_33]; tmp[M4_02] = val[M4_02] * val[M4_13] * val[M4_31] - val[M4_03] * val[M4_12] * val[M4_31] + val[M4_03] * val[M4_11] * val[M4_32] - val[M4_01] * val[M4_13] * val[M4_32] - val[M4_02] * val[M4_11] * val[M4_33] + val[M4_01] * val[M4_12] * val[M4_33]; tmp[M4_03] = val[M4_03] * val[M4_12] * val[M4_21] - val[M4_02] * val[M4_13] * val[M4_21] - val[M4_03] * val[M4_11] * val[M4_22] + val[M4_01] * val[M4_13] * val[M4_22] + val[M4_02] * val[M4_11] * val[M4_23] - val[M4_01] * val[M4_12] * val[M4_23]; tmp[M4_10] = val[M4_13] * val[M4_22] * val[M4_30] - val[M4_12] * val[M4_23] * val[M4_30] - val[M4_13] * val[M4_20] * val[M4_32] + val[M4_10] * val[M4_23] * val[M4_32] + val[M4_12] * val[M4_20] * val[M4_33] - val[M4_10] * val[M4_22] * val[M4_33]; tmp[M4_11] = val[M4_02] * val[M4_23] * val[M4_30] - val[M4_03] * val[M4_22] * val[M4_30] + val[M4_03] * val[M4_20] * val[M4_32] - val[M4_00] * val[M4_23] * val[M4_32] - val[M4_02] * val[M4_20] * val[M4_33] + val[M4_00] * val[M4_22] * val[M4_33]; tmp[M4_12] = val[M4_03] * val[M4_12] * val[M4_30] - val[M4_02] * val[M4_13] * val[M4_30] - val[M4_03] * val[M4_10] * val[M4_32] + val[M4_00] * val[M4_13] * val[M4_32] + val[M4_02] * val[M4_10] * val[M4_33] - val[M4_00] * val[M4_12] * val[M4_33]; tmp[M4_13] = val[M4_02] * val[M4_13] * val[M4_20] - val[M4_03] * val[M4_12] * val[M4_20] + val[M4_03] * val[M4_10] * val[M4_22] - val[M4_00] * val[M4_13] * val[M4_22] - val[M4_02] * val[M4_10] * val[M4_23] + val[M4_00] * val[M4_12] * val[M4_23]; tmp[M4_20] = val[M4_11] * val[M4_23] * val[M4_30] - val[M4_13] * val[M4_21] * val[M4_30] + val[M4_13] * val[M4_20] * val[M4_31] - val[M4_10] * val[M4_23] * val[M4_31] - val[M4_11] * val[M4_20] * val[M4_33] + val[M4_10] * val[M4_21] * val[M4_33]; tmp[M4_21] = val[M4_03] * val[M4_21] * val[M4_30] - val[M4_01] * val[M4_23] * val[M4_30] - val[M4_03] * val[M4_20] * val[M4_31] + val[M4_00] * val[M4_23] * val[M4_31] + val[M4_01] * val[M4_20] * val[M4_33] - val[M4_00] * val[M4_21] * val[M4_33]; tmp[M4_22] = val[M4_01] * val[M4_13] * val[M4_30] - val[M4_03] * val[M4_11] * val[M4_30] + val[M4_03] * val[M4_10] * val[M4_31] - val[M4_00] * val[M4_13] * val[M4_31] - val[M4_01] * val[M4_10] * val[M4_33] + val[M4_00] * val[M4_11] * val[M4_33]; tmp[M4_23] = val[M4_03] * val[M4_11] * val[M4_20] - val[M4_01] * val[M4_13] * val[M4_20] - val[M4_03] * val[M4_10] * val[M4_21] + val[M4_00] * val[M4_13] * val[M4_21] + val[M4_01] * val[M4_10] * val[M4_23] - val[M4_00] * val[M4_11] * val[M4_23]; tmp[M4_30] = val[M4_12] * val[M4_21] * val[M4_30] - val[M4_11] * val[M4_22] * val[M4_30] - val[M4_12] * val[M4_20] * val[M4_31] + val[M4_10] * val[M4_22] * val[M4_31] + val[M4_11] * val[M4_20] * val[M4_32] - val[M4_10] * val[M4_21] * val[M4_32]; tmp[M4_31] = val[M4_01] * val[M4_22] * val[M4_30] - val[M4_02] * val[M4_21] * val[M4_30] + val[M4_02] * val[M4_20] * val[M4_31] - val[M4_00] * val[M4_22] * val[M4_31] - val[M4_01] * val[M4_20] * val[M4_32] + val[M4_00] * val[M4_21] * val[M4_32]; tmp[M4_32] = val[M4_02] * val[M4_11] * val[M4_30] - val[M4_01] * val[M4_12] * val[M4_30] - val[M4_02] * val[M4_10] * val[M4_31] + val[M4_00] * val[M4_12] * val[M4_31] + val[M4_01] * val[M4_10] * val[M4_32] - val[M4_00] * val[M4_11] * val[M4_32]; tmp[M4_33] = val[M4_01] * val[M4_12] * val[M4_20] - val[M4_02] * val[M4_11] * val[M4_20] + val[M4_02] * val[M4_10] * val[M4_21] - val[M4_00] * val[M4_12] * val[M4_21] - val[M4_01] * val[M4_10] * val[M4_22] + val[M4_00] * val[M4_11] * val[M4_22]; float inv_det = 1.0f / l_det; self.val[M4_00] = tmp[M4_00] * inv_det; self.val[M4_01] = tmp[M4_01] * inv_det; self.val[M4_02] = tmp[M4_02] * inv_det; self.val[M4_03] = tmp[M4_03] * inv_det; self.val[M4_10] = tmp[M4_10] * inv_det; self.val[M4_11] = tmp[M4_11] * inv_det; self.val[M4_12] = tmp[M4_12] * inv_det; self.val[M4_13] = tmp[M4_13] * inv_det; self.val[M4_20] = tmp[M4_20] * inv_det; self.val[M4_21] = tmp[M4_21] * inv_det; self.val[M4_22] = tmp[M4_22] * inv_det; self.val[M4_23] = tmp[M4_23] * inv_det; self.val[M4_30] = tmp[M4_30] * inv_det; self.val[M4_31] = tmp[M4_31] * inv_det; self.val[M4_32] = tmp[M4_32] * inv_det; self.val[M4_33] = tmp[M4_33] * inv_det; return true; }
static inline void matrix4_mulVec(float* mat, float* vec) *Matrix4 { float x = vec[0] * mat[M4_00] + vec[1] * mat[M4_01] + vec[2] * mat[M4_02] + mat[M4_03]; float y = vec[0] * mat[M4_10] + vec[1] * mat[M4_11] + vec[2] * mat[M4_12] + mat[M4_13]; float z = vec[0] * mat[M4_20] + vec[1] * mat[M4_21] + vec[2] * mat[M4_22] + mat[M4_23]; vec[0] = x; vec[1] = y; vec[2] = z; }
static inline void matrix4_proj(float* mat, float* vec) *Matrix4 { float inv_w = 1.0f / (vec[0] * mat[M4_30] + vec[1] * mat[M4_31] + vec[2] * mat[M4_32] + mat[M4_33]); float x = (vec[0] * mat[M4_00] + vec[1] * mat[M4_01] + vec[2] * mat[M4_02] + mat[M4_03]) * inv_w; float y = (vec[0] * mat[M4_10] + vec[1] * mat[M4_11] + vec[2] * mat[M4_12] + mat[M4_13]) * inv_w; float z = (vec[0] * mat[M4_20] + vec[1] * mat[M4_21] + vec[2] * mat[M4_22] + mat[M4_23]) * inv_w; vec[0] = x; vec[1] = y; vec[2] = z; }
static inline void matrix4_rot(float* mat, float* vec) *Matrix4 { float x = vec[0] * mat[M4_00] + vec[1] * mat[M4_01] + vec[2] * mat[M4_02]; float y = vec[0] * mat[M4_10] + vec[1] * mat[M4_11] + vec[2] * mat[M4_12]; float z = vec[0] * mat[M4_20] + vec[1] * mat[M4_21] + vec[2] * mat[M4_22]; vec[0] = x; vec[1] = y; vec[2] = z; }
// Multiplies the vector with the given matrix. The matrix array is assumed to hold a 4x4 column major matrix as you can get
- from {@link Matrix4#val}. The vector array is assumed to hold a 3-component vector, with x being the first element, y being
- the second and z being the last component. The result is stored in the vector array. This is the same as
- {@link Vector3#mul(Matrix4)}.
// param mat the matrix // param vec the vector. public static native void mulVec (float[] mat, float[] vec) /*-{ }; /*
matrix4_mulVec(mat, vec);
// Multiplies the vectors with the given matrix. The matrix array is assumed to hold a 4x4 column major matrix as you can get
- from {@link Matrix4#val}. The vectors array is assumed to hold 3-component vectors. Offset specifies the offset into the
- array where the x-component of the first vector is located. The numVecs parameter specifies the number of vectors stored in
- the vectors array. The stride parameter specifies the number of floats between subsequent vectors and must be >= 3. This is
- the same as {@link Vector3#mul(Matrix4)} applied to multiple vectors. *
// param mat the matrix // param vecs the vectors // param offset the offset into the vectors array // param numVecs the number of vectors // param stride the stride between vectors in floats public static native void mulVec (float[] mat, float[] vecs, int offset, int numVecs, int stride) /*-{ }; /*
float* vecPtr = vecs + offset; for(int i = 0; i < numVecs; i++) *Matrix4 { matrix4_mulVec(mat, vecPtr); vecPtr += stride; }
// Multiplies the vector with the given matrix, performing a division by w. The matrix array is assumed to hold a 4x4 column
- major matrix as you can get from {@link Matrix4#val}. The vector array is assumed to hold a 3-component vector, with x being
- the first element, y being the second and z being the last component. The result is stored in the vector array. This is the
- same as {@link Vector3#prj(Matrix4)}.
// param mat the matrix // param vec the vector. public static native void prj (float[] mat, float[] vec) /*-{ }; /*
matrix4_proj(mat, vec);
// Multiplies the vectors with the given matrix, , performing a division by w. The matrix array is assumed to hold a 4x4 column
- major matrix as you can get from {@link Matrix4#val}. The vectors array is assumed to hold 3-component vectors. Offset
- specifies the offset into the array where the x-component of the first vector is located. The numVecs parameter specifies
- the number of vectors stored in the vectors array. The stride parameter specifies the number of floats between subsequent
- vectors and must be >= 3. This is the same as {@link Vector3#prj(Matrix4)} applied to multiple vectors. *
// param mat the matrix // param vecs the vectors // param offset the offset into the vectors array // param numVecs the number of vectors // param stride the stride between vectors in floats public static native void prj (float[] mat, float[] vecs, int offset, int numVecs, int stride) /*-{ }; /*
float* vecPtr = vecs + offset; for(int i = 0; i < numVecs; i++) *Matrix4 { matrix4_proj(mat, vecPtr); vecPtr += stride; }
// Multiplies the vector with the top most 3x3 sub-matrix of the given matrix. The matrix array is assumed to hold a 4x4 column
- major matrix as you can get from {@link Matrix4#val}. The vector array is assumed to hold a 3-component vector, with x being
- the first element, y being the second and z being the last component. The result is stored in the vector array. This is the
- same as {@link Vector3#rot(Matrix4)}.
// param mat the matrix // param vec the vector. public static native void rot (float[] mat, float[] vec) /*-{ }; /*
matrix4_rot(mat, vec);
// Multiplies the vectors with the top most 3x3 sub-matrix of the given matrix. The matrix array is assumed to hold a 4x4
- column major matrix as you can get from {@link Matrix4#val}. The vectors array is assumed to hold 3-component vectors.
- Offset specifies the offset into the array where the x-component of the first vector is located. The numVecs parameter
- specifies the number of vectors stored in the vectors array. The stride parameter specifies the number of floats between
- subsequent vectors and must be >= 3. This is the same as {@link Vector3#rot(Matrix4)} applied to multiple vectors. *
// param mat the matrix // param vecs the vectors // param offset the offset into the vectors array // param numVecs the number of vectors // param stride the stride between vectors in floats public static native void rot (float[] mat, float[] vecs, int offset, int numVecs, int stride) /*-{ }; /*
float* vecPtr = vecs + offset; for(int i = 0; i < numVecs; i++) *Matrix4 { matrix4_rot(mat, vecPtr); vecPtr += stride; }
// Computes the inverse of the given matrix. The matrix array is assumed to hold a 4x4 column major matrix as you can get from
- {@link Matrix4#val}.
// param values the matrix values.
- @return false in case the inverse could not be calculated, true otherwise.
public static native boolean inv (float[] values) /*-{ }; /*
return matrix4_inv(values);
// Computes the determinante of the given matrix. The matrix array is assumed to hold a 4x4 column major matrix as you can get
- from {@link Matrix4#val}.
// param values the matrix values.
- @return the determinante.
public static native float det (float[] values) /*-{ }; /*
return matrix4_det(values);
// @on
Postmultiplies this matrix by a translation matrix. Postmultiplication is also used by OpenGL ES' glTranslate/glRotate/glScale param translation
type Path ¶
type Path interface { DerivativeAt(out interface{}, t float32) interface{} // return The value of the path at t where 0<=t<=1 ValueAt(out interface{}, t float32) interface{} // return The approximated value (between 0 and 1) on the path which is closest to the specified value. Note that the // implementation of this method might be optimized for speed against precision, see {@link #locate(Object)} for a more // precise (but more intensive) method. Approximate(v interface{}) float32 // return The precise location (between 0 and 1) on the path which is closest to the specified value. Note that the // implementation of this method might be CPU intensive, see {@link #approximate(Object)} for a faster (but less // recise) method. Locate(v interface{}) float32 ApproxLength(samples int) float32 }
Interface that specifies a path of type T within the window 0.0<=t<=1.0.
type Quaternion ¶
type Quaternion struct {
// contains filtered or unexported fields
}
func NewQuaternion ¶
func NewQuaternion(x, y, z, w float32) *Quaternion
Constructor, sets the four components of the quaternion.
func NewQuaternionAxis ¶
func NewQuaternionAxis(axis *Vector3, angle float32) *Quaternion
Constructor, sets the quaternion from the given axis vector and the angle around that axis in degrees. param axis The axis param angle The angle in degrees.
func NewQuaternionCopy ¶
func NewQuaternionCopy(quaternion *Quaternion) *Quaternion
Constructor, sets the quaternion components from the given quaternion. param quaternion The quaternion to copy.
func NewQuaternionEmpty ¶
func NewQuaternionEmpty() *Quaternion
func (*Quaternion) Add ¶
func (self *Quaternion) Add(qx, qy, qz, qw float32) *Quaternion
Add the x,y,z,w components of the passed in quaternion to the ones of this quaternion
func (*Quaternion) AddQ ¶
func (self *Quaternion) AddQ(quaternion *Quaternion) *Quaternion
Add the x,y,z,w components of the passed in quaternion to the ones of this quaternion
func (*Quaternion) Conjugate ¶
func (self *Quaternion) Conjugate() *Quaternion
Conjugate the quaternion.
func (*Quaternion) Copy ¶
func (self *Quaternion) Copy() *Quaternion
return a copy of this quaternion
func (*Quaternion) Dot ¶
func (self *Quaternion) Dot(x, y, z, w float32) float32
Get the dot product between this and the other quaternion (commutative). param x the x component of the other quaternion param y the y component of the other quaternion param z the z component of the other quaternion param w the w component of the other quaternion
return the dot product of this and the other quaternion.
func (*Quaternion) DotQ ¶
func (self *Quaternion) DotQ(other *Quaternion) float32
Get the dot product between this and the other quaternion (commutative). param other the other quaternion. return the dot product of this and the other quaternion.
func (*Quaternion) Exp ¶
func (self *Quaternion) Exp(alpha float32) *Quaternion
Calculates (this quaternion)^alpha where alpha is a real number and stores the result in this quaternion. See http://en.wikipedia.org/wiki/Quaternion#Exponential.2C_logarithm.2C_and_power param alpha Exponent
func (*Quaternion) GetAngle ¶
func (self *Quaternion) GetAngle() float32
Get the angle in degrees of the rotation this quaternion represents. Use {@link #getAxisAngle(Vector3)} to get both the axis and the angle of this rotation. Use {@link #getAngleAround(Vector3)} to get the angle around a specific axis. return the angle in degrees of the rotation
func (*Quaternion) GetAngleAround ¶
func (self *Quaternion) GetAngleAround(axisX, axisY, axisZ float32) float32
Get the angle in degrees of the rotation around the specified axis. The axis must be normalized. param axisX the x component of the normalized axis for which to get the angle param axisY the y component of the normalized axis for which to get the angle param axisZ the z component of the normalized axis for which to get the angle return the angle in degrees of the rotation around the specified axis
func (*Quaternion) GetAngleAroundRad ¶
func (self *Quaternion) GetAngleAroundRad(axisX, axisY, axisZ float32) float32
Get the angle in radians of the rotation around the specified axis. The axis must be normalized. param axisX the x component of the normalized axis for which to get the angle param axisY the y component of the normalized axis for which to get the angle param axisZ the z component of the normalized axis for which to get the angle return the angle in radians of the rotation around the specified axis
func (*Quaternion) GetAngleAroundRadV ¶
func (self *Quaternion) GetAngleAroundRadV(axis *Vector3) float32
Get the angle in radians of the rotation around the specified axis. The axis must be normalized. param axis the normalized axis for which to get the angle return the angle in radians of the rotation around the specified axis
func (*Quaternion) GetAngleAroundV ¶
func (self *Quaternion) GetAngleAroundV(axis *Vector3) float32
Get the angle in degrees of the rotation around the specified axis. The axis must be normalized. param axis the normalized axis for which to get the angle return the angle in degrees of the rotation around the specified axis
func (*Quaternion) GetAngleRad ¶
func (self *Quaternion) GetAngleRad() float32
Get the angle in radians of the rotation this quaternion represents. Does not normalize the quaternion. Use {@link #getAxisAngleRad(Vector3)} to get both the axis and the angle of this rotation. Use {@link #getAngleAroundRad(Vector3)} to get the angle around a specific axis. return the angle in radians of the rotation
func (*Quaternion) GetAxisAngle ¶
func (self *Quaternion) GetAxisAngle(axis *Vector3) float32
Get the axis angle representation of the rotation in degrees. The supplied vector will receive the axis (x, y and z values) of the rotation and the value returned is the angle in degrees around that axis. Note that this method will alter the supplied vector, the existing value of the vector is ignored. </p> This will normalize this quaternion if needed. The received axis is a unit vector. However, if this is an identity quaternion (no rotation), then the length of the axis may be zero.
param axis vector which will receive the axis return the angle in degrees @see <a href="http://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation">wikipedia</a> @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle">calculation</a>
func (*Quaternion) GetAxisAngleRad ¶
func (self *Quaternion) GetAxisAngleRad(axis *Vector3) float32
Get the axis-angle representation of the rotation in radians. The supplied vector will receive the axis (x, y and z values) of the rotation and the value returned is the angle in radians around that axis. Note that this method will alter the supplied vector, the existing value of the vector is ignored. </p> This will normalize this quaternion if needed. The received axis is a unit vector. However, if this is an identity quaternion (no rotation), then the length of the axis may be zero.
param axis vector which will receive the axis return the angle in radians @see <a href="http://en.wikipedia.org/wiki/Axis%E2%80%93angle_representation">wikipedia</a> @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle">calculation</a>
func (*Quaternion) GetGimbalPole ¶
func (self *Quaternion) GetGimbalPole() int
Get the pole of the gimbal lock, if any. return positive (+1) for north pole, negative (-1) for south pole, zero (0) when no gimbal lock
func (*Quaternion) GetPitch ¶
func (self *Quaternion) GetPitch() float32
Get the pitch euler angle in degrees, which is the rotation around the x axis. Requires that this quaternion is normalized. return the rotation around the x axis in degrees (between -90 and +90)
func (*Quaternion) GetPitchRad ¶
func (self *Quaternion) GetPitchRad() float32
Get the pitch euler angle in radians, which is the rotation around the x axis. Requires that this quaternion is normalized. return the rotation around the x axis in radians (between -(PI/2) and +(PI/2))
func (*Quaternion) GetRoll ¶
func (self *Quaternion) GetRoll() float32
Get the roll euler angle in degrees, which is the rotation around the z axis. Requires that this quaternion is normalized. return the rotation around the z axis in degrees (between -180 and +180)
func (*Quaternion) GetRollRad ¶
func (self *Quaternion) GetRollRad() float32
Get the roll euler angle in radians, which is the rotation around the z axis. Requires that this quaternion is normalized. return the rotation around the z axis in radians (between -PI and +PI)
func (*Quaternion) GetSwingTwist ¶
func (self *Quaternion) GetSwingTwist(axisX, axisY, axisZ float32, swing, twist *Quaternion)
Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an axis perpendicular to the specified axis.
The swing and twist rotation can be used to reconstruct the original quaternion: this = swing * twist
param axisX the X component of the normalized axis for which to get the swing and twist rotation param axisY the Y component of the normalized axis for which to get the swing and twist rotation param axisZ the Z component of the normalized axis for which to get the swing and twist rotation param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis param twist will receive the twist rotation: the rotation around the specified axis @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a>
func (*Quaternion) GetSwingTwistV ¶
func (self *Quaternion) GetSwingTwistV(axis *Vector3, swing, twist *Quaternion)
Get the swing rotation and twist rotation for the specified axis. The twist rotation represents the rotation around the specified axis. The swing rotation represents the rotation of the specified axis itself, which is the rotation around an axis perpendicular to the specified axis.
The swing and twist rotation can be used to reconstruct the original quaternion: this = swing * twist
param axis the normalized axis for which to get the swing and twist rotation param swing will receive the swing rotation: the rotation around an axis perpendicular to the specified axis param twist will receive the twist rotation: the rotation around the specified axis @see <a href="http://www.euclideanspace.com/maths/geometry/rotations/for/decomposition">calculation</a>
func (*Quaternion) GetYaw ¶
func (self *Quaternion) GetYaw() float32
Get the yaw euler angle in degrees, which is the rotation around the y axis. Requires that this quaternion is normalized. return the rotation around the y axis in degrees (between -180 and +180)
func (*Quaternion) GetYawRad ¶
func (self *Quaternion) GetYawRad() float32
Get the yaw euler angle in radians, which is the rotation around the y axis. Requires that this quaternion is normalized. return the rotation around the y axis in radians (between -PI and +PI)
func (*Quaternion) Idt ¶
func (self *Quaternion) Idt() *Quaternion
Sets the quaternion to an identity Quaternio
func (*Quaternion) IsIdentity ¶
func (self *Quaternion) IsIdentity() bool
return If this quaternion is an identity Quaternion
func (*Quaternion) IsIdentityTolerance ¶
func (self *Quaternion) IsIdentityTolerance(tolerance float32) bool
return If this quaternion is an identity Quaternion
func (*Quaternion) Len ¶
func (self *Quaternion) Len() float32
return the euclidean length of this quaternion
func (*Quaternion) Len2 ¶
func (self *Quaternion) Len2() float32
return the length of this quaternion without square root
func (*Quaternion) Mul ¶
func (self *Quaternion) Mul(x, y, z, w float32) *Quaternion
Multiplies this quaternion with another one in the form of this = this * other param x the x component of the other quaternion to multiply with param y the y component of the other quaternion to multiply with param z the z component of the other quaternion to multiply with param w the w component of the other quaternion to multiply with
func (*Quaternion) MulLeft ¶
func (self *Quaternion) MulLeft(x, y, z, w float32) *Quaternion
Multiplies this quaternion with another one in the form of this = other * this param x the x component of the other quaternion to multiply with param y the y component of the other quaternion to multiply with param z the z component of the other quaternion to multiply with param w the w component of the other quaternion to multiply with
func (*Quaternion) MulLeftQ ¶
func (self *Quaternion) MulLeftQ(other *Quaternion) *Quaternion
Multiplies this quaternion with another one in the form of this = other * this param other Quaternion to multiply with
func (*Quaternion) MulQ ¶
func (self *Quaternion) MulQ(other *Quaternion) *Quaternion
Multiplies this quaternion with another one in the form of this = this * other param other Quaternion to multiply with
func (*Quaternion) MulScalar ¶
func (self *Quaternion) MulScalar(scalar float32) *Quaternion
Multiplies the components of this quaternion with the given scalar. param scalar the scalar.
func (*Quaternion) Nor ¶
func (self *Quaternion) Nor() *Quaternion
Normalizes this quaternion to unit length
func (*Quaternion) Set ¶
func (self *Quaternion) Set(x, y, z, w float32) *Quaternion
Sets the components of the quaternion param x The x-component param y The y-component param z The z-component param w The w-component
func (*Quaternion) SetEulerAngles ¶
func (self *Quaternion) SetEulerAngles(yaw, pitch, roll float32) *Quaternion
Sets the quaternion to the given euler angles in degrees. param yaw the rotation around the y axis in degrees param pitch the rotation around the x axis in degrees param roll the rotation around the z axis degrees return this quaternion
func (*Quaternion) SetEulerAnglesRad ¶
func (self *Quaternion) SetEulerAnglesRad(yaw, pitch, roll float32) *Quaternion
Sets the quaternion to the given euler angles in radians. param yaw the rotation around the y axis in radians param pitch the rotation around the x axis in radians param roll the rotation around the z axis in radians return this quaternion
func (*Quaternion) SetFromAxes ¶
func (self *Quaternion) SetFromAxes(xx, xy, xz, yx, yy, yz, zx, zy, zz float32) *Quaternion
Sets the Quaternion from the given x-, y- and z-axis which have to be orthonormal. Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z.
param xx x-axis x-coordinate param xy x-axis y-coordinate param xz x-axis z-coordinate param yx y-axis x-coordinate param yy y-axis y-coordinate param yz y-axis z-coordinate param zx z-axis x-coordinate param zy z-axis y-coordinate param zz z-axis z-coordinate
func (*Quaternion) SetFromAxesNormalize ¶
func (self *Quaternion) SetFromAxesNormalize(normalizeAxes bool, xx, xy, xz, yx, yy, yz, zx, zy, zz float32) *Quaternion
Sets the Quaternion from the given x-, y- and z-axis. Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ which in turn took it from Graphics Gem code at ftp://ftp.cis.upenn.edu/pub/graphics/shoemake/quatut.ps.Z.
param normalizeAxes whether to normalize the axes (necessary when they contain scaling) param xx x-axis x-coordinate param xy x-axis y-coordinate param xz x-axis z-coordinate param yx y-axis x-coordinate param yy y-axis y-coordinate param yz y-axis z-coordinate param zx z-axis x-coordinate param zy z-axis y-coordinate param zz z-axis z-coordinate
func (*Quaternion) SetFromAxis ¶
func (self *Quaternion) SetFromAxis(x, y, z, degrees float32) *Quaternion
Sets the quaternion components from the given axis and angle around that axis. param x X direction of the axis param y Y direction of the axis param z Z direction of the axis param degrees The angle in degrees
func (*Quaternion) SetFromAxisRad ¶
func (self *Quaternion) SetFromAxisRad(x, y, z, radians float32) *Quaternion
Sets the quaternion components from the given axis and angle around that axis. param x X direction of the axis param y Y direction of the axis param z Z direction of the axis param radians The angle in radians
func (*Quaternion) SetFromAxisRadV3 ¶
func (self *Quaternion) SetFromAxisRadV3(axis *Vector3, radians float32) *Quaternion
Sets the quaternion components from the given axis and angle around that axis. param axis The axis param radians The angle in radians
func (*Quaternion) SetFromAxisV3 ¶
func (self *Quaternion) SetFromAxisV3(axis *Vector3, degrees float32) *Quaternion
todo : the setFromAxis(v3,float) method should replace the set(v3,float) method Sets the quaternion components from the given axis and angle around that axis.
param axis The axis param degrees The angle in degrees
func (*Quaternion) SetFromCross ¶
func (self *Quaternion) SetFromCross(x1, y1, z1, x2, y2, z2 float32) *Quaternion
Set this quaternion to the rotation between two vectors. param x1 The base vectors x value, which should be normalized. param y1 The base vectors y value, which should be normalized. param z1 The base vectors z value, which should be normalized. param x2 The target vector x value, which should be normalized. param y2 The target vector y value, which should be normalized. param z2 The target vector z value, which should be normalized.
func (*Quaternion) SetFromCrossV3 ¶
func (self *Quaternion) SetFromCrossV3(v1, v2 *Vector3) *Quaternion
Set this quaternion to the rotation between two vectors. param v1 The base vector, which should be normalized. param v2 The target vector, which should be normalized.
func (*Quaternion) SetFromMatrixM3 ¶
func (self *Quaternion) SetFromMatrixM3(matrix *Matrix3) *Quaternion
Sets the Quaternion from the given rotation matrix, which must not contain scaling.
func (*Quaternion) SetFromMatrixM3Normalize ¶
func (self *Quaternion) SetFromMatrixM3Normalize(normalizeAxes bool, matrix *Matrix3) *Quaternion
Sets the Quaternion from the given matrix, optionally removing any scaling.
func (*Quaternion) SetFromMatrixM4 ¶
func (self *Quaternion) SetFromMatrixM4(matrix *Matrix4) *Quaternion
Sets the Quaternion from the given rotation matrix, which must not contain scaling.
func (*Quaternion) SetFromMatrixM4Normalize ¶
func (self *Quaternion) SetFromMatrixM4Normalize(normalizeAxes bool, matrix *Matrix4) *Quaternion
Sets the Quaternion from the given matrix, optionally removing any scaling.
func (*Quaternion) SetQ ¶
func (self *Quaternion) SetQ(quaternion *Quaternion) *Quaternion
Sets the quaternion components from the given quaternion. param quaternion The quaternion.
func (*Quaternion) SetV3 ¶
func (self *Quaternion) SetV3(axis *Vector3, angle float32) *Quaternion
Sets the quaternion components from the given axis and angle around that axis. param axis The axis param angle The angle in degrees
func (*Quaternion) Slerp ¶
func (self *Quaternion) Slerp(end *Quaternion, alpha float32) *Quaternion
Spherical linear interpolation between this quaternion and the other quaternion, based on the alpha value in the range [0,1]. Taken from. Taken from Bones framework for JPCT, see http://www.aptalkarga.com/bones/ param end the end quaternion param alpha alpha in the range [0,1
func (*Quaternion) SlerpQ ¶
func (self *Quaternion) SlerpQ(q []*Quaternion) *Quaternion
Spherical linearly interpolates multiple quaternions and stores the result in this Quaternion. Will not destroy the data previously inside the elements of q. result = (q_1^w_1)*(q_2^w_2)* ... *(q_n^w_n) where w_i=1/n. param q List of quaternions
func (*Quaternion) SlerpW ¶
func (self *Quaternion) SlerpW(q []*Quaternion, w []float32) *Quaternion
Spherical linearly interpolates multiple quaternions by the given weights and stores the result in this Quaternion. Will not destroy the data previously inside the elements of q or w. result = (q_1^w_1)*(q_2^w_2)* ... *(q_n^w_n) where the sum of w_i is 1. Lists must be equal in length. param q List of quaternions param w List of weights
func (*Quaternion) String ¶
func (self *Quaternion) String() string
func (*Quaternion) ToMatrix ¶
func (self *Quaternion) ToMatrix(matrix [16]float32)
TODO : the matrix4 set(quaternion) doesnt set the last row+col of the matrix to 0,0,0,1 so... that's why there is this method Fills a 4x4 matrix with the rotation matrix represented by this quaternion.
param matrix Matrix to fill
func (*Quaternion) Transform ¶
func (self *Quaternion) Transform(v *Vector3) *Vector3
TODO : this would better fit into the vector3 class Transforms the given vector using this quaternion param v Vector to transform
type Vector2 ¶
type Vector2 struct {
X, Y float32
}
Encapsulates a 2D vector. Allows chaining methods by returning a reference to itself Implements IVector
func NewVector2 ¶
Constructs a vector with the given components
func NewVector2Copy ¶
Constructs a vector from the given vector
func (*Vector2) Angle ¶
@return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis (typically counter-clockwise) and between 0 and 360.
func (*Vector2) AngleRad ¶
@return the angle in radians of this vector (point) relative to the x-axis. Angles are towards the positive y-axis. (typically counter-clockwise)
func (*Vector2) AngleRadVector2 ¶
@return the angle in radians of this vector (point) relative to the given vector. Angles are towards the positive y-axis. (typically counter-clockwise.)
func (*Vector2) AngleVector2 ¶
@return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the positive y-axis (typically counter-clockwise.) between -180 and +180
func (*Vector2) EpsilonEquals ¶
Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. @return whether the vectors are the same
func (*Vector2) EpsilonEqualsV ¶
func (*Vector2) HasOppositeDirection ¶
func (*Vector2) HasSameDirection ¶
func (*Vector2) Interpolate ¶
func (*Vector2) IsCollinear ¶
func (*Vector2) IsCollinearEpsilon ¶
func (*Vector2) IsCollinearOpposite ¶
func (*Vector2) IsCollinearOppositeEpsilon ¶
func (*Vector2) IsOnLineEpsilon ¶
func (*Vector2) IsPerpendicular ¶
func (*Vector2) IsPerpendicularEpsilon ¶
func (*Vector2) IsUnitMargin ¶
func (*Vector2) IsZeroMargin ¶
func (*Vector2) MulAddScalar ¶
func (*Vector2) Rotate ¶
Rotates the *Vector2 by the given angle, counter-clockwise assuming the y-axis points up. @param degrees the angle in degrees */
func (*Vector2) Rotate90 ¶
Rotates the *Vector2 by 90 degrees in the specified direction, where >= 0 is counter-clockwise and < 0 is clockwise.
func (*Vector2) RotateRad ¶
Rotates the *Vector2 by the given angle, counter-clockwise assuming the y-axis points up. @param radians the angle in radians
func (*Vector2) SetAngle ¶
Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise). @param degrees The angle in degrees to set.
func (*Vector2) SetAngleRad ¶
Sets the angle of the vector in radians relative to the x-axis, towards the positive y-axis (typically counter-clockwise). @param radians The angle in radians to set.
func (*Vector2) SetLength2 ¶
type Vector3 ¶
type Vector3 struct {
X, Y, Z float32
}
Encapsulates a 3D vector. Allows chaining operations by returning a reference to itself in all modification methods. Implements IVector
func NewVector3 ¶
Creates a vector with the given components
func NewVector3Copy ¶
Creates a vector from the given vector vector The vector
func NewVector3VZ ¶
Creates a vector from the given vector and z-component vector The vector z The z-component
func NewVector3Values ¶
Creates a vector from the given array. The array must have at least 3 elements. values The array
func (*Vector3) Add ¶
Adds the given vector to this component x The x-component of the other vector y The y-component of the other vector z The z-component of the other vector.
func (*Vector3) AddValue ¶
Adds the given value to all three components of the vector. value The value
func (*Vector3) Crs ¶
Sets this vector to the cross product between it and the other vector. x The x-component of the other vector y The y-component of the other vector z The z-component of the other vector
func (*Vector3) CrsV ¶
Sets this vector to the cross product between it and the other vector. vector The other vector
func (*Vector3) Dot ¶
Returns the dot product between this and the given vector. x The x-component of the other vector y The y-component of the other vector z The z-component of the other vector return The dot product
func (*Vector3) Dst2V3 ¶
Returns the squared distance between this point and the given point x The x-component of the other point y The y-component of the other point z The z-component of the other point return The squared distance
func (*Vector3) EpsilonEquals ¶
Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. return whether the vectors are the same.
func (*Vector3) EpsilonEqualsV ¶
func (*Vector3) HasOppositeDirection ¶
func (*Vector3) HasSameDirection ¶
func (*Vector3) Idt ¶
@param vector The other vector return Whether this and the other vector are equal
func (*Vector3) Interpolate ¶
func (self *Vector3) Interpolate(target *Vector3, alpha float32, interpolator interpolation.Interpolation) *Vector3
func (*Vector3) IsCollinear ¶
func (*Vector3) IsCollinearEpsilon ¶
func (*Vector3) IsCollinearOpposite ¶
func (*Vector3) IsCollinearOppositeEpsilon ¶
func (*Vector3) IsOnLineEpsilon ¶
func (*Vector3) IsPerpendicular ¶
func (*Vector3) IsPerpendicularEpsilon ¶
func (*Vector3) IsUnitMargin ¶
func (*Vector3) IsZeroMargin ¶
func (*Vector3) Mul ¶
Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.
func (*Vector3) Mul4x3 ¶
Left-multiplies the vector by the given 4x3 column major matrix. The matrix should be composed by a 3x3 matrix representing rotation and scale plus a 1x3 matrix representing the translation.
func (*Vector3) MulQ ¶
func (self *Vector3) MulQ(quat *Quaternion) *Vector3
Multiplies the vector by the given {@link Quaternion}.
func (*Vector3) Prj ¶
Multiplies this vector by the given matrix dividing by w, assuming the fourth (w) component of the vector is 1. This is mostly used to project/unproject vectors via a perspective projection matrix.
func (*Vector3) Rot ¶
Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling.
func (*Vector3) Rotate ¶
Rotates this vector by the given angle in degrees around the given axis. degrees the angle in degrees axisX the x-component of the axis axisY the y-component of the axis axisZ the z-component of the axis
func (*Vector3) RotateRad ¶
Rotates this vector by the given angle in radians around the given axis. radians the angle in radians axisX the x-component of the axis axisY the y-component of the axis axisZ the z-component of the axis
func (*Vector3) RotateRadV ¶
Rotates this vector by the given angle in radians around the given axis. axis the axis radians the angle in radians
func (*Vector3) RotateV ¶
Rotates this vector by the given angle in degrees around the given axis. axis the axis degrees the angle in degrees
func (*Vector3) Set ¶
Sets the vector to the given components x The x-component y The y-component z The z-component return this vector for chaining
func (*Vector3) SetLength2 ¶
func (*Vector3) SetVZ ¶
Sets the components of the given vector and z-component vector The vector z The z-component
func (*Vector3) SetValues ¶
Sets the components from the array. The array must have at least 3 elements values The array return this vector for chaining
func (*Vector3) Slerp ¶
Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored in this vector. target The target vector alpha The interpolation coefficient.
func (*Vector3) TraMul ¶
Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1.
func (*Vector3) Unrotate ¶
Multiplies this vector by the transpose of the first three columns of the matrix. Note: only works for translation and rotation, does not work for scaling. For those, use {@link #rot(Matrix4)} with {@link Matrix4#inv()}.
func (*Vector3) Untransform ¶
Translates this vector in the direction opposite to the translation of the matrix and the multiplies this vector by the transpose of the first three columns of the matrix. Note: only works for translation and rotation, does not work for scaling. For those, use {@link #mul(Matrix4)} with {@link Matrix4#inv()}.