vector

package
v0.0.0-...-e7bc4dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
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
)
View Source
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

View Source
var (
	XV2    = NewVector2(1, 0)
	YV2    = NewVector2(0, 1)
	ZeroV2 = NewVector2(0, 0)
)
View Source
var (
	XV3    = NewVector3(1, 0, 0)
	YV3    = NewVector3(0, 1, 0)
	ZV3    = NewVector3(0, 0, 1)
	ZeroV3 = NewVector3(0, 0, 0)
)

Functions

func Dot

func Dot(x1, y1, z1, w1, x2, y2, z2, w2 float32) float32

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 DotV2

func DotV2(x1, y1, x2, y2 float32) float32

func DotV3

func DotV3(x1, y1, z1, x2, y2, z2 float32) float32

return The dot product between the two vectors

func Dst2V2

func Dst2V2(x1, y1, x2, y2 float32) float32

func Dst2V3

func Dst2V3(x1, y1, z1, x2, y2, z2 float32) float32

return the squared distance between the given points

func DstV2

func DstV2(x1, y1, x2, y2 float32) float32

func DstV3

func DstV3(x1, y1, z1, x2, y2, z2 float32) float32

return The euclidean distance between the two specified vectors

func Len2Q

func Len2Q(x, y, z, w float32) float32

func Len2V2

func Len2V2(x, y float32) float32

func Len2V3

func Len2V3(x, y, z float32) float32

return The squared euclidean length

func LenQ

func LenQ(x, y, z, w float32) float32

return the euclidean length of the specified quaternion

func LenV2

func LenV2(x, y float32) float32

func LenV3

func LenV3(x, y, z float32) float32

return The euclidean length

func MulM3

func MulM3(mata [9]float32, matb [9]float32)

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

func MulM4(mata [16]float32, matb [16]float32)

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

func NewAffine2Copy(other *Affine2) *Affine2

Constructs a matrix from the given affine matrix. @param other The affine matrix to copy. This matrix will not be modified.

func NewAffine2Empty

func NewAffine2Empty() *Affine2

Constructs an identity matrix.

func (*Affine2) ApplyTo

func (self *Affine2) ApplyTo(point *Vector2)

Applies the affine transformation on a vector.

func (*Affine2) Det

func (self *Affine2) Det() float32

Calculates the determinant of the matrix. return The determinant of this matrix.

func (*Affine2) GetTranslation

func (self *Affine2) GetTranslation(position *Vector2) *Vector2

Get the x-y translation component of the matrix. param position Output vector. return Filled position.

func (*Affine2) Idt

func (self *Affine2) Idt() *Affine2

Sets this matrix to the identity matrix return This matrix for the purpose of chaining operations.

func (*Affine2) Inv

func (self *Affine2) Inv() *Affine2

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

func (self *Affine2) IsIdt() bool

Check if this is an indentity matrix. return True if scale is 1 and rotation is 0.

func (*Affine2) IsTranslation

func (self *Affine2) IsTranslation() bool

Check if the this is a plain translation matrix. return True if scale is 1 and rotation is 0.

func (*Affine2) Mul

func (self *Affine2) Mul(other *Affine2) *Affine2

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

func (self *Affine2) PreMulA(other *Affine2) *Affine2

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

func (self *Affine2) PreRotate(degrees float32) *Affine2

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

func (self *Affine2) PreRotateRad(radians float32) *Affine2

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

func (self *Affine2) PreScale(scaleX, scaleY float32) *Affine2

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

func (self *Affine2) PreScaleV(scale *Vector2) *Affine2

Premultiplies this matrix with a scale matrix. param scale The scale vector. return This matrix for the purpose of chaining.

func (*Affine2) PreShear

func (self *Affine2) PreShear(shearX, shearY float32) *Affine2

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

func (self *Affine2) PreShearV(shear *Vector2) *Affine2

Premultiplies this matrix by a shear matrix. param shear The shear vector. return This matrix for the purpose of chaining.

func (*Affine2) PreTranslate

func (self *Affine2) PreTranslate(x, y float32) *Affine2

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

func (self *Affine2) PreTranslateV(trn *Vector2) *Affine2

Premultiplies this matrix by a translation matrix. param trn The translation vector. return This matrix for the purpose of chaining.

func (*Affine2) Rotate

func (self *Affine2) Rotate(degrees float32) *Affine2

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

func (self *Affine2) RotateRad(radians float32) *Affine2

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

func (self *Affine2) Scale(scaleX, scaleY float32) *Affine2

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

func (self *Affine2) ScaleV(scale *Vector2) *Affine2

Postmultiplies this matrix with a scale matrix. param scale The scale vector. return This matrix for the purpose of chaining.

func (*Affine2) Set

func (self *Affine2) Set(other *Affine2) *Affine2

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

func (self *Affine2) SetM3(matrix *Matrix3) *Affine2

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

func (self *Affine2) SetM4(matrix *Matrix4) *Affine2

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

func (self *Affine2) SetToProduct(l, r *Affine2) *Affine2

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

func (self *Affine2) SetToRotation(cos, sin float32) *Affine2

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

func (self *Affine2) SetToRotationRad(radians float32) *Affine2

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

func (self *Affine2) SetToScaling(scaleX, scaleY float32) *Affine2

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

func (self *Affine2) SetToScalingV(scale *Vector2) *Affine2

Sets this matrix to a scaling matrix. param scale The scale vector. return This matrix for the purpose of chaining operations.

func (*Affine2) SetToShearing

func (self *Affine2) SetToShearing(shearX, shearY float32) *Affine2

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

func (self *Affine2) SetToShearingV(shear *Vector2) *Affine2

Sets this matrix to a shearing matrix. param shear The shear vector. return This matrix for the purpose of chaining operations.

func (*Affine2) SetToTranslation

func (self *Affine2) SetToTranslation(x, y float32) *Affine2

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

func (self *Affine2) SetToTranslationV(trn *Vector2) *Affine2

Sets this matrix to a translation matrix. param trn The translation vector. return This matrix for the purpose of chaining operations.

func (*Affine2) SetToTrnRotRadScl

func (self *Affine2) SetToTrnRotRadScl(x, y, radians, scaleX, scaleY float32) *Affine2

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

func (self *Affine2) SetToTrnRotRadSclV(trn *Vector2, radians float32, scale *Vector2) *Affine2

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

func (self *Affine2) SetToTrnRotScl(x, y, degrees, scaleX, scaleY float32) *Affine2

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

func (self *Affine2) SetToTrnRotSclV(trn *Vector2, degrees float32, scale *Vector2) *Affine2

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

func (self *Affine2) SetToTrnScl(x, y, scaleX, scaleY float32) *Affine2

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

func (self *Affine2) SetToTrnSclV(trn, scale *Vector2) *Affine2

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

func (self *Affine2) Shear(shearX, shearY float32) *Affine2

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

func (self *Affine2) ShearV(shear *Vector2) *Affine2

Postmultiplies this matrix by a shear matrix. param shear The shear vector. return This matrix for the purpose of chaining.

func (*Affine2) String

func (self *Affine2) String() string

func (*Affine2) Translate

func (self *Affine2) Translate(x, y float32) *Affine2

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

func (self *Affine2) TranslateV(trn *Vector2) *Affine2

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

func NewMatrix(values [9]float32) *Matrix3

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 NewMatrixCopy(other *Matrix3) *Matrix3

func NewMatrixEmpty

func NewMatrixEmpty() *Matrix3

func (*Matrix3) Det

func (self *Matrix3) Det() float32

return The determinant of this matrix

func (*Matrix3) GetRotation

func (self *Matrix3) GetRotation() float32

func (*Matrix3) GetRotationRad

func (self *Matrix3) GetRotationRad() float32

func (*Matrix3) GetScale

func (self *Matrix3) GetScale(scale *Vector2) *Vector2

func (*Matrix3) GetTranslation

func (self *Matrix3) GetTranslation(position *Vector2) *Vector2

func (*Matrix3) GetValues

func (self *Matrix3) GetValues() [9]float32

Get the values in this matrix. return The float values that make up this matrix in column-major order.

func (*Matrix3) Idt

func (self *Matrix3) Idt() *Matrix3

Sets this matrix to the identity matrix return This matrix for the purpose of chaining operations.

func (*Matrix3) Inv

func (self *Matrix3) Inv() *Matrix3

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

func (self *Matrix3) Mul(m *Matrix3) *Matrix3

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

func (self *Matrix3) MulLeft(m *Matrix3) *Matrix3

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

func (self *Matrix3) Rotate(degrees float32) *Matrix3

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

func (self *Matrix3) RotateRad(radians float32) *Matrix3

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

func (self *Matrix3) Scale(scaleX, scaleY float32) *Matrix3

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

func (self *Matrix3) ScaleV(scale *Vector2) *Matrix3

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

func (self *Matrix3) Scl(scale float32) *Matrix3

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

func (self *Matrix3) SclV(scale *Vector2) *Matrix3

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

func (self *Matrix3) SclV3(scale *Vector3) *Matrix3

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

func (self *Matrix3) Set(values [9]float32) *Matrix3

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

func (self *Matrix3) SetA(affine *Affine2) *Matrix3

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

func (self *Matrix3) SetM3(mat *Matrix3) *Matrix3

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

func (self *Matrix3) SetM4(mat *Matrix4) *Matrix3

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

func (self *Matrix3) SetToRotation(degrees float32) *Matrix3

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 (self *Matrix3) SetToRotationAxis(axis *Vector3, cos, sin float32) *Matrix3

func (*Matrix3) SetToRotationAxisDeg

func (self *Matrix3) SetToRotationAxisDeg(axis *Vector3, degrees float32) *Matrix3

func (*Matrix3) SetToRotationRad

func (self *Matrix3) SetToRotationRad(radians float32) *Matrix3

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

func (self *Matrix3) SetToScaling(scaleX, scaleY float32) *Matrix3

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

func (self *Matrix3) SetToScalingV(scale *Vector2) *Matrix3

Sets this matrix to a scaling matrix. scale The scale vector. return This matrix for the purpose of chaining operations.

func (*Matrix3) SetToTranslation

func (self *Matrix3) SetToTranslation(x, y float32) *Matrix3

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

func (self *Matrix3) SetToTranslationV(translation *Vector2) *Matrix3

Sets this matrix to a translation matrix. translation The translation vector. return This matrix for the purpose of chaining operations.

func (*Matrix3) String

func (self *Matrix3) String() string

func (*Matrix3) Translate

func (self *Matrix3) Translate(x, y float32) *Matrix3

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

func (self *Matrix3) TranslateV(translation *Vector2) *Matrix3

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

func (self *Matrix3) Transpose() *Matrix3

Transposes the current matrix. return This matrix for the purpose of chaining methods together.

func (*Matrix3) Trn

func (self *Matrix3) Trn(x, y float32) *Matrix3

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

func (self *Matrix3) TrnV(vector *Vector2) *Matrix3

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.

func (*Matrix3) TrnV3

func (self *Matrix3) TrnV3(vector *Vector3) *Matrix3

Adds a translational component to the matrix in the 3rd column. The other columns are untouched. vector The translation vector. (The z-component of the vector is ignored because this is a 3x3 matrix) 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

func NewMatrix4(values [16]float32) *Matrix4

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

func NewMatrix4Copy(matrix *Matrix4) *Matrix4

Constructs a matrix from the given matrix. param matrix The matrix to copy. (This matrix is not modified)

func NewMatrix4Empty

func NewMatrix4Empty() *Matrix4

Constructs an identity matrix

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

func (self *Matrix4) Avg(other *Matrix4, w float32) *Matrix4

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

func (self *Matrix4) AvgM4(t []*Matrix4) *Matrix4

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

func (self *Matrix4) AvgM4W(t []*Matrix4, w []float32) *Matrix4

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) Copy

func (self *Matrix4) Copy() *Matrix4

@return a copy of this matrix

func (*Matrix4) Det

func (self *Matrix4) Det() float32

@return The determinant of this matrix

func (*Matrix4) Det3x3

func (self *Matrix4) Det3x3() float32

@return The determinant of the 3x3 upper left matrix

func (*Matrix4) Extract4x3Matrix

func (self *Matrix4) Extract4x3Matrix(dst []float32)

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

func (self *Matrix4) GetScale(scale *Vector3) *Vector3

param scale The vector which will receive the (non-negative) scale components on each axis. return The provided vector for chaining.

func (*Matrix4) GetScaleX

func (self *Matrix4) GetScaleX() float32

@return the scale factor on the X axis (non-negative)

func (*Matrix4) GetScaleXSquared

func (self *Matrix4) GetScaleXSquared() float32

@return the squared scale factor on the X axis

func (*Matrix4) GetScaleY

func (self *Matrix4) GetScaleY() float32

@return the scale factor on the Y axis (non-negative)

func (*Matrix4) GetScaleYSquared

func (self *Matrix4) GetScaleYSquared() float32

@return the squared scale factor on the Y axis

func (*Matrix4) GetScaleZ

func (self *Matrix4) GetScaleZ() float32

@return the scale factor on the X axis (non-negative)

func (*Matrix4) GetScaleZSquared

func (self *Matrix4) GetScaleZSquared() float32

@return the squared scale factor on the Z axis

func (*Matrix4) GetTranslation

func (self *Matrix4) GetTranslation(position *Vector3) *Vector3

func (*Matrix4) GetValues

func (self *Matrix4) GetValues() [16]float32

@return the backing float array

func (*Matrix4) Idt

func (self *Matrix4) Idt() *Matrix4

Sets the matrix to an identity matrix.

func (*Matrix4) Inv

func (self *Matrix4) Inv() *Matrix4

Inverts the matrix. Stores the result in this matrix. @throws RuntimeException if the matrix is singular (not invertible)

func (*Matrix4) Lerp

func (self *Matrix4) Lerp(matrix *Matrix4, alpha float32) *Matrix4

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

func (self *Matrix4) MulLeft(matrix *Matrix4) *Matrix4

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

func (self *Matrix4) MulM4(matrix *Matrix4) *Matrix4

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

func (self *Matrix4) RotateAxis(axisX, axisY, axisZ, degrees float32) *Matrix4

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

func (self *Matrix4) RotateRad(axis *Vector3, radians float32) *Matrix4

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

func (self *Matrix4) RotateRadAxis(axisX, axisY, axisZ, radians float32) *Matrix4

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

func (self *Matrix4) RotateV3(v1, v2 *Vector3) *Matrix4

Postmultiplies this matrix by the rotation between two vectors. param v1 The base vector param v2 The target vector

func (*Matrix4) RotateV3Axis

func (self *Matrix4) RotateV3Axis(axis *Vector3, degrees float32) *Matrix4

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

func (self *Matrix4) Scale(scaleX, scaleY, scaleZ float32) *Matrix4

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) Scl

func (self *Matrix4) Scl(x, y, z float32) *Matrix4

func (*Matrix4) SclV

func (self *Matrix4) SclV(scale *Vector3) *Matrix4

func (*Matrix4) SclValue

func (self *Matrix4) SclValue(scale float32) *Matrix4

func (*Matrix4) Set

func (self *Matrix4) Set(tX, tY, tZ, qX, qY, qZ, qW, scaleX, scaleY, scaleZ float32) *Matrix4

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

func (self *Matrix4) SetA2(affine *Affine2) *Matrix4

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

func (self *Matrix4) SetAsAffine(affine *Affine2) *Matrix4

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

func (self *Matrix4) SetAsAffineM4(mat *Matrix4) *Matrix4

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

func (self *Matrix4) SetFromEulerAngles(yaw, pitch, roll float32) *Matrix4

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

func (self *Matrix4) SetFromEulerAnglesRad(yaw, pitch, roll float32) *Matrix4

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

func (self *Matrix4) SetM3(mat *Matrix3) *Matrix4

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

func (self *Matrix4) SetM4(matrix *Matrix4) *Matrix4

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

func (self *Matrix4) SetQR(qX, qY, qZ, qW float32) *Matrix4

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

func (self *Matrix4) SetTQ(tX, tY, tZ, qX, qY, qZ, qW float32) *Matrix4

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

func (self *Matrix4) SetToLookAt(direction, up *Vector3) *Matrix4

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

func (self *Matrix4) SetToLookAtPos(position, target, up *Vector3) *Matrix4

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

func (self *Matrix4) SetToOrtho(left, right, bottom, top, near, far float32) *Matrix4

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

func (self *Matrix4) SetToOrtho2D(x, y, width, height float32) *Matrix4

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

func (self *Matrix4) SetToOrtho2DNear(x, y, width, height, near, far float32) *Matrix4

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

func (self *Matrix4) SetToProjectionLeft(left, right, bottom, top, near, far float32) *Matrix4

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

func (self *Matrix4) SetToProjectionNear(near, far, fovy, aspectRatio float32) *Matrix4

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

func (self *Matrix4) SetToRotation(x1, y1, z1, x2, y2, z2 float32) *Matrix4

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

func (self *Matrix4) SetToRotationAxis(axisX, axisY, axisZ, degrees float32) *Matrix4

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

func (self *Matrix4) SetToRotationRad(axisX, axisY, axisZ, radians float32) *Matrix4

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

func (self *Matrix4) SetToRotationRadV3(axis *Vector3, radians float32) *Matrix4

Sets the matrix to a rotation matrix around the given axis.

param axis The axis param radians The angle in radians

func (*Matrix4) SetToRotationV

func (self *Matrix4) SetToRotationV(v1, v2 *Vector3) *Matrix4

Set the matrix to a rotation matrix between two vectors. param v1 The base vector param v2 The target vector

func (*Matrix4) SetToRotationV3

func (self *Matrix4) SetToRotationV3(axis *Vector3, degrees float32) *Matrix4

Sets the matrix to a rotation matrix around the given axis.

param axis The axis param degrees The angle in degrees

func (*Matrix4) SetToScaling

func (self *Matrix4) SetToScaling(x, y, z float32) *Matrix4

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

func (self *Matrix4) SetToScalingV3(vector *Vector3) *Matrix4

Sets this matrix to a scaling matrix param vector The scaling vector.

func (*Matrix4) SetToTranslation

func (self *Matrix4) SetToTranslation(x, y, z float32) *Matrix4

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

func (self *Matrix4) SetToTranslationAndScalingV3(translation, scaling *Vector3) *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 translation The translation vector param scaling The scaling vector

func (*Matrix4) SetToTranslationV3

func (self *Matrix4) SetToTranslationV3(vector *Vector3) *Matrix4

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 (self *Matrix4) SetToWorld(position, forward, up *Vector3) *Matrix4

func (*Matrix4) SetTranslation

func (self *Matrix4) SetTranslation(x, y, z float32) *Matrix4

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

func (self *Matrix4) SetTranslationV3(vector *Vector3) *Matrix4

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

func (self *Matrix4) SetVAxis(xAxis, yAxis, zAxis, pos *Vector3) *Matrix4

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

func (self *Matrix4) SetValues(values [16]float32) *Matrix4

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) String

func (self *Matrix4) String() string

func (*Matrix4) ToNormalMatrix

func (self *Matrix4) ToNormalMatrix() *Matrix4

removes the translational part and transposes the matrix.

func (*Matrix4) Tra

func (self *Matrix4) Tra() *Matrix4

Transposes the matrix.

func (*Matrix4) Translate

func (self *Matrix4) Translate(x, y, z float32) *Matrix4

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

func (self *Matrix4) TranslateV(translation *Vector3) *Matrix4

@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

func (*Matrix4) Trn

func (self *Matrix4) Trn(x, y, z float32) *Matrix4

Adds a translational component to the matrix in the 4th column. The other columns are untouched. 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) TrnV

func (self *Matrix4) TrnV(vector *Vector3) *Matrix4

Adds a translational component to the matrix in the 4th column. The other columns are untouched. param vector The translation vector to add to the current matrix. (This vector is not modified)

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

func NewVector2(x, y float32) *Vector2

Constructs a vector with the given components

func NewVector2Copy

func NewVector2Copy(v *Vector2) *Vector2

Constructs a vector from the given vector

func NewVector2Empty

func NewVector2Empty() *Vector2

Constructs a new vector at (0,0)

func (*Vector2) Add

func (self *Vector2) Add(x, y float32) *Vector2

Adds the given components to this vector

func (*Vector2) AddV

func (self *Vector2) AddV(v *Vector2) *Vector2

func (*Vector2) Angle

func (self *Vector2) Angle() float32

@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

func (self *Vector2) AngleRad() float32

@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

func (self *Vector2) AngleRadVector2(reference *Vector2) float32

@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

func (self *Vector2) AngleVector2(reference *Vector2) float32

@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) Clamp

func (self *Vector2) Clamp(min, max float32) *Vector2

func (*Vector2) Copy

func (self *Vector2) Copy() *Vector2

func (*Vector2) Crs

func (self *Vector2) Crs(x, y float32) float32

Calculates the 2D cross product between this and the given vector.

func (*Vector2) CrsV

func (self *Vector2) CrsV(v *Vector2) float32

Calculates the 2D cross product between this and the given vector

func (*Vector2) Dot

func (self *Vector2) Dot(ox, oy float32) float32

func (*Vector2) DotV

func (self *Vector2) DotV(v *Vector2) float32

func (*Vector2) Dst

func (self *Vector2) Dst(x, y float32) float32

func (*Vector2) Dst2

func (self *Vector2) Dst2(x, y float32) float32

func (*Vector2) Dst2V

func (self *Vector2) Dst2V(v *Vector2) float32

func (*Vector2) DstV

func (self *Vector2) DstV(v *Vector2) float32

func (*Vector2) EpsilonEquals

func (self *Vector2) EpsilonEquals(x, y, epsilon float32) bool

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 (self *Vector2) EpsilonEqualsV(other *Vector2, epsilon float32) bool

func (*Vector2) Equals

func (self *Vector2) Equals(v *Vector2) bool

func (*Vector2) HasOppositeDirection

func (self *Vector2) HasOppositeDirection(v *Vector2) bool

func (*Vector2) HasSameDirection

func (self *Vector2) HasSameDirection(v *Vector2) bool

func (*Vector2) HashCode

func (self *Vector2) HashCode() int

func (*Vector2) Interpolate

func (self *Vector2) Interpolate(target *Vector2, alpha float32, interpolation Interpolation) *Vector2

func (*Vector2) IsCollinear

func (self *Vector2) IsCollinear(other *Vector2) bool

func (*Vector2) IsCollinearEpsilon

func (self *Vector2) IsCollinearEpsilon(other *Vector2, epsilon float32) bool

func (*Vector2) IsCollinearOpposite

func (self *Vector2) IsCollinearOpposite(other *Vector2) bool

func (*Vector2) IsCollinearOppositeEpsilon

func (self *Vector2) IsCollinearOppositeEpsilon(other *Vector2, epsilon float32) bool

func (*Vector2) IsOnLine

func (self *Vector2) IsOnLine(other *Vector2) bool

func (*Vector2) IsOnLineEpsilon

func (self *Vector2) IsOnLineEpsilon(other *Vector2, epsilon float32) bool

func (*Vector2) IsPerpendicular

func (self *Vector2) IsPerpendicular(v *Vector2) bool

func (*Vector2) IsPerpendicularEpsilon

func (self *Vector2) IsPerpendicularEpsilon(vector *Vector2, epsilon float32) bool

func (*Vector2) IsUnit

func (self *Vector2) IsUnit() bool

func (*Vector2) IsUnitMargin

func (self *Vector2) IsUnitMargin(margin float32) bool

func (*Vector2) IsZero

func (self *Vector2) IsZero() bool

func (*Vector2) IsZeroMargin

func (self *Vector2) IsZeroMargin(margin float32) bool

func (*Vector2) Len

func (self *Vector2) Len() float32

func (*Vector2) Len2

func (self *Vector2) Len2() float32

func (*Vector2) Lerp

func (self *Vector2) Lerp(target *Vector2, alpha float32) *Vector2

func (*Vector2) Limit

func (self *Vector2) Limit(limit float32) *Vector2

func (*Vector2) Limit2

func (self *Vector2) Limit2(limit2 float32) *Vector2

func (*Vector2) Mul

func (self *Vector2) Mul(mat Matrix3) *Vector2

Left-multiplies this vector by the given matrix

func (*Vector2) MulAdd

func (self *Vector2) MulAdd(v *Vector2, mulVec *Vector2) *Vector2

func (*Vector2) MulAddScalar

func (self *Vector2) MulAddScalar(v *Vector2, scalar float32) *Vector2

func (*Vector2) Nor

func (self *Vector2) Nor() *Vector2

func (*Vector2) Rotate

func (self *Vector2) Rotate(degrees float32) *Vector2

Rotates the *Vector2 by the given angle, counter-clockwise assuming the y-axis points up. @param degrees the angle in degrees */

func (*Vector2) Rotate90

func (self *Vector2) Rotate90(dir int) *Vector2

Rotates the *Vector2 by 90 degrees in the specified direction, where >= 0 is counter-clockwise and < 0 is clockwise.

func (*Vector2) RotateRad

func (self *Vector2) RotateRad(radians float32) *Vector2

Rotates the *Vector2 by the given angle, counter-clockwise assuming the y-axis points up. @param radians the angle in radians

func (*Vector2) Scl

func (self *Vector2) Scl(x, y float32) *Vector2

Multiplies this vector by a scalar

func (*Vector2) SclScalar

func (self *Vector2) SclScalar(scalar float32) *Vector2

func (*Vector2) SclV

func (self *Vector2) SclV(v *Vector2) *Vector2

func (*Vector2) Set

func (self *Vector2) Set(x, y float32) *Vector2

Sets the components of this vector

func (*Vector2) SetAngle

func (self *Vector2) SetAngle(degrees float32) *Vector2

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

func (self *Vector2) SetAngleRad(radians float32) *Vector2

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) SetLength

func (self *Vector2) SetLength(length float32) *Vector2

func (*Vector2) SetLength2

func (self *Vector2) SetLength2(len2 float32) *Vector2

func (*Vector2) SetV

func (self *Vector2) SetV(v *Vector2) *Vector2

func (*Vector2) SetZero

func (self *Vector2) SetZero() *Vector2

func (*Vector2) String

func (self *Vector2) String() string

func (*Vector2) Sub

func (self *Vector2) Sub(x, y float32) *Vector2

Substracts the other vector from this vector.

func (*Vector2) SubV

func (self *Vector2) SubV(v *Vector2) *Vector2

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

func NewVector3(x, y, z float32) *Vector3

Creates a vector with the given components

func NewVector3Copy

func NewVector3Copy(v *Vector3) *Vector3

Creates a vector from the given vector vector The vector

func NewVector3Empty

func NewVector3Empty() *Vector3

Constructs a vector at (0,0,0)

func NewVector3VZ

func NewVector3VZ(vector *Vector2, z float32) *Vector3

Creates a vector from the given vector and z-component vector The vector z The z-component

func NewVector3Values

func NewVector3Values(values []float32) *Vector3

Creates a vector from the given array. The array must have at least 3 elements. values The array

func (*Vector3) Add

func (self *Vector3) Add(x, y, z float32) *Vector3

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) AddV

func (self *Vector3) AddV(vector *Vector3) *Vector3

func (*Vector3) AddValue

func (self *Vector3) AddValue(value float32) *Vector3

Adds the given value to all three components of the vector. value The value

func (*Vector3) Clamp

func (self *Vector3) Clamp(min, max float32) *Vector3

func (*Vector3) Copy

func (self *Vector3) Copy() *Vector3

func (*Vector3) Crs

func (self *Vector3) Crs(x, y, z float32) *Vector3

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

func (self *Vector3) CrsV(vector *Vector3) *Vector3

Sets this vector to the cross product between it and the other vector. vector The other vector

func (*Vector3) Dot

func (self *Vector3) Dot(x, y, z float32) float32

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) DotV

func (self *Vector3) DotV(vector *Vector3) float32

func (*Vector3) Dst

func (self *Vector3) Dst(x, y, z float32) float32

return the distance between this point and the given point

func (*Vector3) Dst2V

func (self *Vector3) Dst2V(point *Vector3) float32

func (*Vector3) Dst2V3

func (self *Vector3) Dst2V3(x, y, z float32) float32

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) DstV

func (self *Vector3) DstV(vector *Vector3) float32

func (*Vector3) EpsilonEquals

func (self *Vector3) EpsilonEquals(x, y, z, epsilon float32) bool

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 (self *Vector3) EpsilonEqualsV(other *Vector3, epsilon float32) bool

func (*Vector3) HasOppositeDirection

func (self *Vector3) HasOppositeDirection(vector *Vector3) bool

func (*Vector3) HasSameDirection

func (self *Vector3) HasSameDirection(vector *Vector3) bool

func (*Vector3) Idt

func (self *Vector3) Idt(vector *Vector3) bool

@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 (self *Vector3) IsCollinear(other *Vector3) bool

func (*Vector3) IsCollinearEpsilon

func (self *Vector3) IsCollinearEpsilon(other *Vector3, epsilon float32) bool

func (*Vector3) IsCollinearOpposite

func (self *Vector3) IsCollinearOpposite(other *Vector3) bool

func (*Vector3) IsCollinearOppositeEpsilon

func (self *Vector3) IsCollinearOppositeEpsilon(other *Vector3, epsilon float32) bool

func (*Vector3) IsOnLine

func (self *Vector3) IsOnLine(other *Vector3) bool

func (*Vector3) IsOnLineEpsilon

func (self *Vector3) IsOnLineEpsilon(other *Vector3, epsilon float32) bool

func (*Vector3) IsPerpendicular

func (self *Vector3) IsPerpendicular(vector *Vector3) bool

func (*Vector3) IsPerpendicularEpsilon

func (self *Vector3) IsPerpendicularEpsilon(vector *Vector3, epsilon float32) bool

func (*Vector3) IsUnit

func (self *Vector3) IsUnit() bool

func (*Vector3) IsUnitMargin

func (self *Vector3) IsUnitMargin(margin float32) bool

func (*Vector3) IsZero

func (self *Vector3) IsZero() bool

func (*Vector3) IsZeroMargin

func (self *Vector3) IsZeroMargin(margin float32) bool

func (*Vector3) Len

func (self *Vector3) Len() float32

func (*Vector3) Len2

func (self *Vector3) Len2() float32

func (*Vector3) Lerp

func (self *Vector3) Lerp(target *Vector3, alpha float32) *Vector3

func (*Vector3) Limit

func (self *Vector3) Limit(limit float32) *Vector3

func (*Vector3) Limit2

func (self *Vector3) Limit2(limit2 float32) *Vector3

func (*Vector3) Mul

func (self *Vector3) Mul(matrix *Matrix4) *Vector3

Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1.

func (*Vector3) Mul4x3

func (self *Vector3) Mul4x3(matrix []float32) *Vector3

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) MulAdd

func (self *Vector3) MulAdd(vec *Vector3, scalar float32) *Vector3

func (*Vector3) MulAddV

func (self *Vector3) MulAddV(vec, mulVec *Vector3) *Vector3

func (*Vector3) MulM3

func (self *Vector3) MulM3(matrix *Matrix3) *Vector3

Left-multiplies the vector by the given matrix.

func (*Vector3) MulQ

func (self *Vector3) MulQ(quat *Quaternion) *Vector3

Multiplies the vector by the given {@link Quaternion}.

func (*Vector3) Nor

func (self *Vector3) Nor() *Vector3

func (*Vector3) Prj

func (self *Vector3) Prj(matrix *Matrix4) *Vector3

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

func (self *Vector3) Rot(matrix *Matrix4) *Vector3

Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling.

func (*Vector3) Rotate

func (self *Vector3) Rotate(degrees, axisX, axisY, axisZ float32) *Vector3

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

func (self *Vector3) RotateRad(radians, axisX, axisY, axisZ float32) *Vector3

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

func (self *Vector3) RotateRadV(axis *Vector3, radians float32) *Vector3

Rotates this vector by the given angle in radians around the given axis. axis the axis radians the angle in radians

func (*Vector3) RotateV

func (self *Vector3) RotateV(axis *Vector3, degrees float32) *Vector3

Rotates this vector by the given angle in degrees around the given axis. axis the axis degrees the angle in degrees

func (*Vector3) Scl

func (self *Vector3) Scl(vx, vy, vz float32) *Vector3

Scales this vector by the given values

func (*Vector3) SclScalar

func (self *Vector3) SclScalar(scalar float32) *Vector3

func (*Vector3) SclV

func (self *Vector3) SclV(other *Vector3) *Vector3

func (*Vector3) Set

func (self *Vector3) Set(x, y, z float32) *Vector3

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) SetLength

func (self *Vector3) SetLength(length float32) *Vector3

func (*Vector3) SetLength2

func (self *Vector3) SetLength2(len2 float32) *Vector3

func (*Vector3) SetV

func (self *Vector3) SetV(vector *Vector3) *Vector3

func (*Vector3) SetVZ

func (self *Vector3) SetVZ(vector *Vector2, z float32) *Vector3

Sets the components of the given vector and z-component vector The vector z The z-component

func (*Vector3) SetValues

func (self *Vector3) SetValues(values []float32) *Vector3

Sets the components from the array. The array must have at least 3 elements values The array return this vector for chaining

func (*Vector3) SetZero

func (self *Vector3) SetZero() *Vector3

func (*Vector3) Slerp

func (self *Vector3) Slerp(target *Vector3, alpha float32) *Vector3

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) String

func (self *Vector3) String() string

func (*Vector3) Sub

func (self *Vector3) Sub(x, y, z float32) *Vector3

Subtracts the other vector from this vector.

func (*Vector3) SubV

func (self *Vector3) SubV(a_vec *Vector3) *Vector3

func (*Vector3) SubValue

func (self *Vector3) SubValue(value float32) *Vector3

Subtracts the given value from all components of this vector

func (*Vector3) TraMul

func (self *Vector3) TraMul(matrix *Matrix4) *Vector3

Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1.

func (*Vector3) TraMulM3

func (self *Vector3) TraMulM3(matrix *Matrix3) *Vector3

Multiplies the vector by the transpose of the given matrix.

func (*Vector3) Unrotate

func (self *Vector3) Unrotate(matrix *Matrix4) *Vector3

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

func (self *Vector3) Untransform(matrix *Matrix4) *Vector3

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()}.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL