engine: github.com/g3n/engine/math32 Index | Files

package math32

import "github.com/g3n/engine/math32"

Package math32 implements basic math functions which operate directly on float32 numbers without casting and contains types of common entities used in 3D Graphics such as vectors, matrices, quaternions and others.

Index

Package Files

array.go box2.go box3.go color.go color4.go frustum.go line3.go math.go matrix3.go matrix4.go plane.go quaternion.go ray.go sphere.go spline.go triangle.go vector2.go vector3.go vector4.go

Constants

const Pi = math.Pi

Variables

var Infinity = float32(math.Inf(1))

func Abs Uses

func Abs(v float32) float32

func Acos Uses

func Acos(v float32) float32

func Asin Uses

func Asin(v float32) float32

func Atan Uses

func Atan(v float32) float32

func Atan2 Uses

func Atan2(y, x float32) float32

func Ceil Uses

func Ceil(v float32) float32

func Clamp Uses

func Clamp(x, a, b float32) float32

Clamp clamps x to the provided closed interval [a, b]

func ClampInt Uses

func ClampInt(x, a, b int) int

ClampInt clamps x to the provided closed interval [a, b]

func ContainsPoint Uses

func ContainsPoint(point, a, b, c *Vector3) bool

ContainsPoint returns whether a triangle contains a point.

func Cos Uses

func Cos(v float32) float32

func DegToRad Uses

func DegToRad(degrees float32) float32

DegToRad converts a number from degrees to radians

func Floor Uses

func Floor(v float32) float32

func Inf Uses

func Inf(sign int) float32

func IsNaN Uses

func IsNaN(v float32) bool

func Max Uses

func Max(a, b float32) float32

func Min Uses

func Min(a, b float32) float32

func Mod Uses

func Mod(a, b float32) float32

func NaN Uses

func NaN() float32

func Pow Uses

func Pow(a, b float32) float32

func RadToDeg Uses

func RadToDeg(radians float32) float32

RadToDeg converts a number from radians to degrees

func Round Uses

func Round(v float32) float32

func Sin Uses

func Sin(v float32) float32

func Sqrt Uses

func Sqrt(v float32) float32

func Tan Uses

func Tan(v float32) float32

type ArrayF32 Uses

type ArrayF32 []float32

ArrayF32 is a slice of float32 with additional convenience methods

func NewArrayF32 Uses

func NewArrayF32(size, capacity int) ArrayF32

NewArrayF32 creates a returns a new array of floats with the specified initial size and capacity

func (*ArrayF32) Append Uses

func (a *ArrayF32) Append(v ...float32)

Append appends any number of values to the array

func (*ArrayF32) AppendColor Uses

func (a *ArrayF32) AppendColor(v ...*Color)

AppendColor appends any number of Color to the array

func (*ArrayF32) AppendColor4 Uses

func (a *ArrayF32) AppendColor4(v ...*Color4)

AppendColor4 appends any number of Color4 to the array

func (*ArrayF32) AppendVector2 Uses

func (a *ArrayF32) AppendVector2(v ...*Vector2)

AppendVector2 appends any number of Vector2 to the array

func (*ArrayF32) AppendVector3 Uses

func (a *ArrayF32) AppendVector3(v ...*Vector3)

AppendVector3 appends any number of Vector3 to the array

func (*ArrayF32) AppendVector4 Uses

func (a *ArrayF32) AppendVector4(v ...*Vector4)

AppendVector4 appends any number of Vector4 to the array

func (*ArrayF32) Bytes Uses

func (a *ArrayF32) Bytes() int

Bytes returns the size of the array in bytes

func (ArrayF32) GetColor Uses

func (a ArrayF32) GetColor(pos int, v *Color)

GetColor stores in the specified Color the values from the array starting at the specified pos

func (ArrayF32) GetColor4 Uses

func (a ArrayF32) GetColor4(pos int, v *Color4)

GetColor4 stores in the specified Color the values from the array starting at the specified pos

func (ArrayF32) GetMatrix4 Uses

func (a ArrayF32) GetMatrix4(pos int, m *Matrix4)

GetMatrix4 stores in the specified Matrix4 the values from the array starting at the specified pos.

func (ArrayF32) GetVector2 Uses

func (a ArrayF32) GetVector2(pos int, v *Vector2)

GetVector2 stores in the specified Vector2 the values from the array starting at the specified pos.

func (ArrayF32) GetVector3 Uses

func (a ArrayF32) GetVector3(pos int, v *Vector3)

GetVector3 stores in the specified Vector3 the values from the array starting at the specified pos.

func (ArrayF32) GetVector4 Uses

func (a ArrayF32) GetVector4(pos int, v *Vector4)

GetVector4 stores in the specified Vector4 the values from the array starting at the specified pos.

func (*ArrayF32) Len Uses

func (a *ArrayF32) Len() int

Len returns the number of float32 elements in the array It is equivalent to Size()

func (ArrayF32) Set Uses

func (a ArrayF32) Set(pos int, v ...float32)

Set sets the values of the array starting at the specified pos from the specified values

func (ArrayF32) SetColor Uses

func (a ArrayF32) SetColor(pos int, v *Color)

SetColor sets the values of the array at the specified pos from the RGB values of the specified Color

func (ArrayF32) SetColor4 Uses

func (a ArrayF32) SetColor4(pos int, v *Color4)

SetColor4 sets the values of the array at the specified pos from the RGBA values of specified Color4

func (ArrayF32) SetVector2 Uses

func (a ArrayF32) SetVector2(pos int, v *Vector2)

SetVector2 sets the values of the array at the specified pos from the XY values of the specified Vector2

func (ArrayF32) SetVector3 Uses

func (a ArrayF32) SetVector3(pos int, v *Vector3)

SetVector3 sets the values of the array at the specified pos from the XYZ values of the specified Vector3

func (ArrayF32) SetVector4 Uses

func (a ArrayF32) SetVector4(pos int, v *Vector4)

SetVector4 sets the values of the array at the specified pos from the XYZ values of the specified Vector4

func (*ArrayF32) Size Uses

func (a *ArrayF32) Size() int

Size returns the number of float32 elements in the array

type ArrayU32 Uses

type ArrayU32 []uint32

ArrayU32 is a slice of uint32 with additional convenience methods

func NewArrayU32 Uses

func NewArrayU32(size, capacity int) ArrayU32

NewArrayU32 creates a returns a new array of uint32 with the specified initial size and capacity

func (*ArrayU32) Append Uses

func (a *ArrayU32) Append(v ...uint32)

Append appends n elements to the array updating the slice if necessary

func (*ArrayU32) Bytes Uses

func (a *ArrayU32) Bytes() int

Bytes returns the size of the array in bytes

func (*ArrayU32) Len Uses

func (a *ArrayU32) Len() int

Len returns the number of float32 elements in the array

func (*ArrayU32) Size Uses

func (a *ArrayU32) Size() int

Size returns the number of float32 elements in the array

type Box2 Uses

type Box2 struct {
    // contains filtered or unexported fields
}

Box2 represents a 2D bounding box defined by two points: the point with minimum coordinates and the point with maximum coordinates.

func NewBox2 Uses

func NewBox2(min, max *Vector2) *Box2

NewBox2 creates and returns a pointer to a new Box2 defined by its minimum and maximum coordinates.

func (*Box2) Center Uses

func (b *Box2) Center(optionalTarget *Vector2) *Vector2

Center calculates the center point of this bounding box and stores its pointer to optionalTarget, if not nil, and also returns it.

func (*Box2) ClampPoint Uses

func (b *Box2) ClampPoint(point *Vector2, optionalTarget *Vector2) *Vector2

ClampPoint calculates a new point which is the specified point clamped inside this box. Stores the pointer to this new point into optionaTarget, if not nil, and also returns it.

func (*Box2) ContainsBox Uses

func (b *Box2) ContainsBox(other *Box2) bool

ContainsBox returns if this bounding box contains other box.

func (*Box2) ContainsPoint Uses

func (b *Box2) ContainsPoint(point *Vector2) bool

ContainsPoint returns if this bounding box contains the specified point.

func (*Box2) Copy Uses

func (b *Box2) Copy(box *Box2) *Box2

Copy copy other to this bounding box. Returns pointer to this updated bounding box.

func (*Box2) DistanceToPoint Uses

func (b *Box2) DistanceToPoint(point *Vector2) float32

DistanceToPoint returns the distance from this box to the specified point.

func (*Box2) Empty Uses

func (b *Box2) Empty() bool

Empty returns if this bounding box is empty.

func (*Box2) Equals Uses

func (b *Box2) Equals(other *Box2) bool

Equals returns if this box is equal to other

func (*Box2) ExpandByPoint Uses

func (b *Box2) ExpandByPoint(point *Vector2) *Box2

ExpandByPoint may expand this bounding box to include the specified point. Returns pointer to this updated bounding box.

func (*Box2) ExpandByScalar Uses

func (b *Box2) ExpandByScalar(scalar float32) *Box2

ExpandByScalar expands this bounding box by the specified scalar. Returns pointer to this updated bounding box.

func (*Box2) ExpandByVector Uses

func (b *Box2) ExpandByVector(vector *Vector2) *Box2

ExpandByVector expands this bounding box by the specified vector. Returns pointer to this updated bounding box.

func (*Box2) Intersect Uses

func (b *Box2) Intersect(other *Box2) *Box2

Intersect sets this box to the intersection with other box. Returns pointer to this updated bounding box.

func (*Box2) IsIntersectionBox Uses

func (b *Box2) IsIntersectionBox(other *Box2) bool

IsIntersectionBox returns if other box intersects this one.

func (*Box2) MakeEmpty Uses

func (b *Box2) MakeEmpty() *Box2

MakeEmpty set this bounding box to empty. Returns pointer to this updated bounding box.

func (*Box2) Set Uses

func (b *Box2) Set(min, max *Vector2) *Box2

Set sets this bounding box minimum and maximum coordinates. Returns pointer to this updated bounding box.

func (*Box2) SetFromCenterAndSize Uses

func (b *Box2) SetFromCenterAndSize(center, size *Vector2) *Box2

SetFromCenterAndSize set this bounding box from a center point and size. Size is a vector from the minimum point to the maximum point. Returns pointer to this updated bounding box.

func (*Box2) SetFromPoints Uses

func (b *Box2) SetFromPoints(points []*Vector2) *Box2

SetFromPoints set this bounding box from the specified array of points. Returns pointer to this updated bounding box.

func (*Box2) Size Uses

func (b *Box2) Size(optionalTarget *Vector2) *Vector2

Size calculates the size of this bounding box: the vector from its minimum point to its maximum point. Store pointer to the calculated size into optionalTarget, if not nil, and also returns it.

func (*Box2) Translate Uses

func (b *Box2) Translate(offset *Vector2) *Box2

Translate translates the position of this box by offset. Returns pointer to this updated box.

func (*Box2) Union Uses

func (b *Box2) Union(other *Box2) *Box2

Union set this box to the union with other box. Returns pointer to this updated bounding box.

type Box3 Uses

type Box3 struct {
    Min Vector3
    Max Vector3
}

Box3 represents a 3D bounding box defined by two points: the point with minimum coordinates and the point with maximum coordinates.

func NewBox3 Uses

func NewBox3(min, max *Vector3) *Box3

NewBox3 creates and returns a pointer to a new Box3 defined by its minimum and maximum coordinates.

func (*Box3) ApplyMatrix4 Uses

func (b *Box3) ApplyMatrix4(m *Matrix4) *Box3

ApplyMatrix4 applies the specified matrix to the vertices of this bounding box. Returns pointer to this updated bounding box.

func (*Box3) Center Uses

func (b *Box3) Center(optionalTarget *Vector3) *Vector3

Center calculates the center point of this bounding box and stores its pointer to optionalTarget, if not nil, and also returns it.

func (*Box3) ClampPoint Uses

func (b *Box3) ClampPoint(point *Vector3, optionalTarget *Vector3) *Vector3

ClampPoint calculates a new point which is the specified point clamped inside this box. Stores the pointer to this new point into optionaTarget, if not nil, and also returns it.

func (*Box3) Clone Uses

func (b *Box3) Clone() *Box3

Clone creates and returns a pointer to copy of this bounding box

func (*Box3) ContainsBox Uses

func (b *Box3) ContainsBox(box *Box3) bool

ContainsBox returns if this bounding box contains other box.

func (*Box3) ContainsPoint Uses

func (b *Box3) ContainsPoint(point *Vector3) bool

ContainsPoint returns if this bounding box contains the specified point.

func (*Box3) Copy Uses

func (b *Box3) Copy(other *Box3) *Box3

Copy copy other to this bounding box. Returns pointer to this updated bounding box.

func (*Box3) DistanceToPoint Uses

func (b *Box3) DistanceToPoint(point *Vector3) float32

DistanceToPoint returns the distance from this box to the specified point.

func (*Box3) Empty Uses

func (b *Box3) Empty() bool

Empty returns if this bounding box is empty.

func (*Box3) Equals Uses

func (b *Box3) Equals(other *Box3) bool

Equals returns if this box is equal to other

func (*Box3) ExpandByPoint Uses

func (b *Box3) ExpandByPoint(point *Vector3) *Box3

ExpandByPoint may expand this bounding box to include the specified point. Returns pointer to this updated bounding box.

func (*Box3) ExpandByScalar Uses

func (b *Box3) ExpandByScalar(scalar float32) *Box3

ExpandByScalar expands this bounding box by the specified scalar. Returns pointer to this updated bounding box.

func (*Box3) ExpandByVector Uses

func (b *Box3) ExpandByVector(vector *Vector3) *Box3

ExpandByVector expands this bounding box by the specified vector. Returns pointer to this updated bounding box.

func (*Box3) GetBoundingSphere Uses

func (b *Box3) GetBoundingSphere(optionalTarget *Sphere) *Sphere

GetBoundingSphere creates a bounding sphere to this bounding box. Store its pointer into optionalTarget, if not nil, and also returns it.

func (*Box3) Intersect Uses

func (b *Box3) Intersect(other *Box3) *Box3

Intersect sets this box to the intersection with other box. Returns pointer to this updated bounding box.

func (*Box3) IsIntersectionBox Uses

func (b *Box3) IsIntersectionBox(other *Box3) bool

IsIntersectionBox returns if other box intersects this one.

func (*Box3) MakeEmpty Uses

func (b *Box3) MakeEmpty() *Box3

MakeEmpty set this bounding box to empty. Returns pointer to this updated bounding box.

func (*Box3) Set Uses

func (b *Box3) Set(min, max *Vector3) *Box3

Set sets this bounding box minimum and maximum coordinates. Returns pointer to this updated bounding box.

func (*Box3) SetFromCenterAndSize Uses

func (b *Box3) SetFromCenterAndSize(center, size *Vector3) *Box3

SetFromCenterAndSize set this bounding box from a center point and size. Size is a vector from the minimum point to the maximum point. Returns pointer to this updated bounding box.

func (*Box3) SetFromPoints Uses

func (b *Box3) SetFromPoints(points []Vector3) *Box3

SetFromPoints set this bounding box from the specified array of points. Returns pointer to this updated bounding box.

func (*Box3) Size Uses

func (b *Box3) Size(optionalTarget *Vector3) *Vector3

Size calculates the size of this bounding box: the vector from its minimum point to its maximum point. Store pointer to the calculated size into optionalTarget, if not nil, and also returns it.

func (*Box3) Translate Uses

func (b *Box3) Translate(offset *Vector3) *Box3

Translate translates the position of this box by offset. Returns pointer to this updated box.

func (*Box3) Union Uses

func (b *Box3) Union(other *Box3) *Box3

Union set this box to the union with other box. Returns pointer to this updated bounding box.

type Color Uses

type Color struct {
    R   float32
    G   float32
    B   float32
}

Color describes an RGB color

func ColorName Uses

func ColorName(name string) Color

ColorName returns a Color with the specified standard web color name (case insensitive). Returns black color if the specified color name not found

func IsColorName Uses

func IsColorName(name string) (Color, bool)

IsColorName returns if the specified name is valid color name

func NewColor Uses

func NewColor(name string) *Color

NewColor creates and returns a pointer to a new Color with the specified web standard color name (case insensitive). Returns nil if the color name not found

func NewColorHex Uses

func NewColorHex(color uint) *Color

NewColorHex creates and returns a pointer to a new color with its RGB components from the specified hex value

func (*Color) Add Uses

func (c *Color) Add(other *Color) *Color

Add adds to each RGB component of this color the correspondent component of other color Returns pointer to this updated color

func (*Color) AddColors Uses

func (c *Color) AddColors(color1, color2 *Color) *Color

AddColors adds to each RGB component of this color the correspondent component of color1 and color2 Returns pointer to this updated color

func (*Color) AddScalar Uses

func (c *Color) AddScalar(s float32) *Color

AddScalar adds the specified scalar value to each RGB component of this color Returns pointer to this updated color

func (*Color) Equals Uses

func (c *Color) Equals(other *Color) bool

Equals returns if this color is equal to other

func (*Color) Lerp Uses

func (c *Color) Lerp(color *Color, alpha float32) *Color

Lerp linear sets this color as the linear interpolation of itself with the specified color for the specified alpha. Returns pointer to this updated color

func (*Color) Multiply Uses

func (c *Color) Multiply(other *Color) *Color

Multiply multiplies each RGB component of this color by other Returns pointer to this updated color

func (*Color) MultiplyScalar Uses

func (c *Color) MultiplyScalar(v float32) *Color

MultiplyScalar multiplies each RGB component of this color by the specified scalar. Returns pointer to this updated color

func (*Color) Set Uses

func (c *Color) Set(r, g, b float32) *Color

Set sets this color individual R,G,B components

func (*Color) SetHex Uses

func (c *Color) SetHex(value uint) *Color

SetHex sets the color RGB components from the specified integer interpreted as a color hex number

func (*Color) SetName Uses

func (c *Color) SetName(name string) *Color

SetName sets the color RGB components from the specified standard web color name

type Color4 Uses

type Color4 struct {
    R   float32
    G   float32
    B   float32
    A   float32
}

Color4 describes an RGBA color

func Color4Name Uses

func Color4Name(name string, alpha ...float32) Color4

Color4Name returns a Color4 with the specified standard web color name and an optional alpha channel value.

func NewColor4 Uses

func NewColor4(name string, alpha ...float32) *Color4

NewColor4 creates and returns a pointer to a new Color4 with the specified standard web color name (case insensitive) and an optional alpha channel value. Returns nil if the specified color name not found

func (*Color4) Add Uses

func (c *Color4) Add(other *Color4) *Color4

Add adds to each RGBA component of this color the correspondent component of other color Returns pointer to this updated color

func (*Color4) FromColor Uses

func (c *Color4) FromColor(other *Color, alpha float32)

FromColor sets this Color4 fields from Color and an alpha

func (*Color4) MultiplyScalar Uses

func (c *Color4) MultiplyScalar(v float32) *Color4

MultiplyScalar multiplies each RGBA component of this color by the specified scalar. Returns pointer to this updated color

func (*Color4) Set Uses

func (c *Color4) Set(r, g, b, a float32) *Color4

Set sets this color individual R,G,B,A components Returns pointer to this updated color

func (*Color4) SetHex Uses

func (c *Color4) SetHex(value uint) *Color4

SetHex sets the color RGB components from the specified integer interpreted as a color hex number Alpha component is not modified Returns pointer to this updated color

func (*Color4) SetName Uses

func (c *Color4) SetName(name string) *Color4

SetName sets the color RGB components from the specified standard web color name Returns pointer to this updated color

func (*Color4) ToColor Uses

func (c *Color4) ToColor() Color

ToColor returns a Color with this Color4 RGB components

type Frustum Uses

type Frustum struct {
    // contains filtered or unexported fields
}

Frustum represents a frustum

func NewFrustum Uses

func NewFrustum(p0, p1, p2, p3, p4, p5 *Plane) *Frustum

NewFrustum returns a pointer to a new Frustum object

func NewFrustumFromMatrix Uses

func NewFrustumFromMatrix(m *Matrix4) *Frustum

NewFrustumFromMatrix creates and returns a Frustum based on the provided matrix

func (*Frustum) Clone Uses

func (f *Frustum) Clone() *Frustum

Clone returns a pointer to a new Frustum object with the same planes as the original

func (*Frustum) ContainsPoint Uses

func (f *Frustum) ContainsPoint(point *Vector3) bool

ContainsPoint determines whether the frustum contains the specified point

func (*Frustum) Copy Uses

func (f *Frustum) Copy(frustum *Frustum) *Frustum

Copy modifies the receiver frustum to match the provided frustum

func (*Frustum) IntersectsBox Uses

func (f *Frustum) IntersectsBox(box *Box3) bool

IntersectsBox determines whether the specified box is intersecting the frustum

func (*Frustum) IntersectsSphere Uses

func (f *Frustum) IntersectsSphere(sphere *Sphere) bool

IntersectsSphere determines whether the specified sphere is intersecting the frustum

func (*Frustum) Set Uses

func (f *Frustum) Set(p0, p1, p2, p3, p4, p5 *Plane) *Frustum

Set sets the frustum's planes

func (*Frustum) SetFromMatrix Uses

func (f *Frustum) SetFromMatrix(m *Matrix4) *Frustum

SetFromMatrix sets the frustum's planes based on the specified Matrix4

type Line3 Uses

type Line3 struct {
    // contains filtered or unexported fields
}

Line3 represents a 3D line segment defined by a start and an end point.

func NewLine3 Uses

func NewLine3(start, end *Vector3) *Line3

NewLine3 creates and returns a pointer to a new Line3 with the specified start and end points.

func (*Line3) ApplyMatrix4 Uses

func (l *Line3) ApplyMatrix4(matrix *Matrix4) *Line3

ApplyMatrix4 applies the specified matrix to this line segment start and end points. Returns pointer to this updated line segment.

func (*Line3) Center Uses

func (l *Line3) Center(optionalTarget *Vector3) *Vector3

Center calculates this line segment center point. Store its pointer into optionalTarget, if not nil, and also returns it.

func (*Line3) Clone Uses

func (l *Line3) Clone() *Line3

Clone creates and returns a pointer to a copy of this line segment.

func (*Line3) Copy Uses

func (l *Line3) Copy(other *Line3) *Line3

Copy copy other line segment to this one. Returns pointer to this updated line segment.

func (*Line3) Delta Uses

func (l *Line3) Delta(optionalTarget *Vector3) *Vector3

Delta calculates the vector from the start to end point of this line segment. Store its pointer in optionalTarget, if not nil, and also returns it.

func (*Line3) Distance Uses

func (l *Line3) Distance() float32

Distance returns the distance from the start point to the end point.

func (*Line3) DistanceSq Uses

func (l *Line3) DistanceSq() float32

DistanceSq returns the square of the distance from the start point to the end point.

func (*Line3) Equals Uses

func (l *Line3) Equals(other *Line3) bool

Equals returns if this line segement is equal to other.

func (*Line3) Set Uses

func (l *Line3) Set(start, end *Vector3) *Line3

Set sets this line segment start and end points. Returns pointer to this updated line segment.

type Matrix3 Uses

type Matrix3 [9]float32

Matrix3 is 3x3 matrix organized internally as column matrix

func NewMatrix3 Uses

func NewMatrix3() *Matrix3

NewMatrix3 creates and returns a pointer to a new Matrix3 initialized as the identity matrix.

func (*Matrix3) ApplyToVector3Array Uses

func (m *Matrix3) ApplyToVector3Array(array []float32, offset int, length int) []float32

ApplyToVector3Array multiplies length vectors in the array starting at offset by this matrix. Returns pointer to the updated array. This matrix is unchanged.

func (*Matrix3) Clone Uses

func (m *Matrix3) Clone() *Matrix3

Clone creates and returns a pointer to a copy of this matrix.

func (*Matrix3) Copy Uses

func (m *Matrix3) Copy(src *Matrix3) *Matrix3

Copy copies src matrix into this one. Returns the pointer to this updated matrix.

func (*Matrix3) Determinant Uses

func (m *Matrix3) Determinant() float32

Determinant calculates and returns the determinant of this matrix.

func (*Matrix3) FromArray Uses

func (m *Matrix3) FromArray(array []float32, offset int) *Matrix3

FromArray set this matrix array starting at offset. Returns pointer to this updated matrix.

func (*Matrix3) GetInverse Uses

func (m *Matrix3) GetInverse(src *Matrix3) error

GetInverse sets this matrix to the inverse of the src matrix. If the src matrix cannot be inverted returns error and sets this matrix to the identity matrix.

func (*Matrix3) GetNormalMatrix Uses

func (m *Matrix3) GetNormalMatrix(src *Matrix4) error

GetNormalMatrix set this matrix to the matrix to transform the normal vectors from the src matrix to transform the vertices. If the src matrix cannot be inverted returns error.

func (*Matrix3) Identity Uses

func (m *Matrix3) Identity() *Matrix3

Identity sets this matrix as the identity matrix. Returns the pointer to this updated matrix.

func (*Matrix3) MakeRotationFromQuaternion Uses

func (m *Matrix3) MakeRotationFromQuaternion(q *Quaternion) *Matrix3

MakeRotationFromQuaternion sets this matrix as a rotation matrix from the specified quaternion. Returns pointer to this updated matrix.

func (*Matrix3) Multiply Uses

func (m *Matrix3) Multiply(other *Matrix3) *Matrix3

Multiply multiply this matrix by the other matrix Returns pointer to this updated matrix.

func (*Matrix3) MultiplyMatrices Uses

func (m *Matrix3) MultiplyMatrices(a, b *Matrix3) *Matrix3

MultiplyMatrices multiply matrix a by b storing the result in this matrix. Returns pointer to this updated matrix.

func (*Matrix3) MultiplyScalar Uses

func (m *Matrix3) MultiplyScalar(s float32) *Matrix3

MultiplyScalar multiplies each of this matrix's components by the specified scalar. Returns pointer to this updated matrix.

func (*Matrix3) ScaleColumns Uses

func (m *Matrix3) ScaleColumns(v *Vector3) *Matrix3

ScaleColumns multiplies the matrix columns by the vector components. This can be used when multiplying this matrix by a diagonal matrix if we store the diagonal components as a vector. Returns pointer to this updated matrix.

func (*Matrix3) Set Uses

func (m *Matrix3) Set(n11, n12, n13, n21, n22, n23, n31, n32, n33 float32) *Matrix3

Set sets all the elements of the matrix row by row starting at row1, column1, row1, column2, row1, column3 and so forth. Returns the pointer to this updated Matrix.

func (*Matrix3) SetFromMatrix4 Uses

func (m *Matrix3) SetFromMatrix4(src *Matrix4) *Matrix3

SetFromMatrix4 sets the matrix elements based on a Matrix4.

func (*Matrix3) ToArray Uses

func (m *Matrix3) ToArray(array []float32, offset int) []float32

ToArray copies this matrix to array starting at offset. Returns pointer to the updated array.

func (*Matrix3) Transpose Uses

func (m *Matrix3) Transpose() *Matrix3

Transpose transposes this matrix. Returns pointer to this updated matrix.

func (*Matrix3) Zero Uses

func (m *Matrix3) Zero() *Matrix3

Zero sets this matrix as the zero matrix. Returns the pointer to this updated matrix.

type Matrix4 Uses

type Matrix4 [16]float32

Matrix4 is 4x4 matrix organized internally as column matrix.

func NewMatrix4 Uses

func NewMatrix4() *Matrix4

NewMatrix4 creates and returns a pointer to a new Matrix4 initialized as the identity matrix.

func (*Matrix4) ApplyToVector3Array Uses

func (m *Matrix4) ApplyToVector3Array(array []float32, offset int, length int) []float32

ApplyToVector3Array multiplies length vectors in the array starting at offset by this matrix. Returns pointer to the updated array. This matrix is unchanged.

func (*Matrix4) Clone Uses

func (m *Matrix4) Clone() *Matrix4

Clone creates and returns a pointer to a copy of this matrix.

func (*Matrix4) Compose Uses

func (m *Matrix4) Compose(position *Vector3, quaternion *Quaternion, scale *Vector3) *Matrix4

Compose sets this matrix to a transformation matrix for the specified position, rotation specified by the quaternion and scale. Returns pointer to this updated matrix.

func (*Matrix4) Copy Uses

func (m *Matrix4) Copy(src *Matrix4) *Matrix4

Copy copies src matrix into this one. Returns pointer to this updated matrix.

func (*Matrix4) CopyPosition Uses

func (m *Matrix4) CopyPosition(src *Matrix4) *Matrix4

CopyPosition copies the position elements of the src matrix into this one. Returns pointer to this updated matrix.

func (*Matrix4) Decompose Uses

func (m *Matrix4) Decompose(position *Vector3, quaternion *Quaternion, scale *Vector3) *Matrix4

Decompose updates the position vector, quaternion and scale from this transformation matrix. Returns pointer to this unchanged matrix.

func (*Matrix4) Determinant Uses

func (m *Matrix4) Determinant() float32

Determinant calculates and returns the determinat of this matrix.

func (*Matrix4) ExtractBasis Uses

func (m *Matrix4) ExtractBasis(xAxis, yAxis, zAxis *Vector3) *Matrix4

ExtractBasis updates the specified vectors with the basis vectors of this matrix. Returns pointer to this unchanged matrix.

func (*Matrix4) ExtractRotation Uses

func (m *Matrix4) ExtractRotation(src *Matrix4) *Matrix4

ExtractRotation set this matrix as rotation matrix from the src transformation matrix. Returns pointer to this updated matrix.

func (*Matrix4) FromArray Uses

func (m *Matrix4) FromArray(array []float32, offset int) *Matrix4

FromArray set this matrix elements from the array starting at offset. Returns pointer to this updated matrix.

func (*Matrix4) GetInverse Uses

func (m *Matrix4) GetInverse(src *Matrix4) error

GetInverse sets this matrix to the inverse of the src matrix. If the src matrix cannot be inverted returns error and sets this matrix to the identity matrix.

func (*Matrix4) GetMaxScaleOnAxis Uses

func (m *Matrix4) GetMaxScaleOnAxis() float32

GetMaxScaleOnAxis returns the maximum scale value of the 3 axes.

func (*Matrix4) Identity Uses

func (m *Matrix4) Identity() *Matrix4

Identity sets this matrix as the identity matrix. Returns pointer to this updated matrix.

func (*Matrix4) LookAt Uses

func (m *Matrix4) LookAt(eye, target, up *Vector3) *Matrix4

LookAt sets this matrix as view transform matrix with origin at eye, looking at target and using the up vector. Returns pointer to this updated matrix.

func (*Matrix4) MakeBasis Uses

func (m *Matrix4) MakeBasis(xAxis, yAxis, zAxis *Vector3) *Matrix4

MakeBasis sets this matrix basis vectors from the specified vectors. Returns pointer to this updated matrix.

func (*Matrix4) MakeFrustum Uses

func (m *Matrix4) MakeFrustum(left, right, bottom, top, near, far float32) *Matrix4

MakeFrustum sets this matrix to a projection frustum matrix bounded by the specified planes. Returns pointer to this updated matrix.

func (*Matrix4) MakeOrthographic Uses

func (m *Matrix4) MakeOrthographic(left, right, top, bottom, near, far float32) *Matrix4

MakeOrthographic sets this matrix to an orthographic projection matrix bounded by the specified planes. Returns pointer to this updated matrix.

func (*Matrix4) MakePerspective Uses

func (m *Matrix4) MakePerspective(fov, aspect, near, far float32) *Matrix4

MakePerspective sets this matrix to a perspective projection matrix with the specified field of view in degrees, aspect ratio (width/height) and near and far planes. Returns pointer to this updated matrix.

func (*Matrix4) MakeRotationAxis Uses

func (m *Matrix4) MakeRotationAxis(axis *Vector3, angle float32) *Matrix4

MakeRotationAxis sets this matrix to a rotation matrix of the specified angle around the specified axis. Returns pointer to this updated matrix.

func (*Matrix4) MakeRotationFromEuler Uses

func (m *Matrix4) MakeRotationFromEuler(euler *Vector3) *Matrix4

MakeRotationFromEuler set this a matrix as a rotation matrix from the specified euler angles. Returns pointer to this updated matrix.

func (*Matrix4) MakeRotationFromQuaternion Uses

func (m *Matrix4) MakeRotationFromQuaternion(q *Quaternion) *Matrix4

MakeRotationFromQuaternion sets this matrix as a rotation matrix from the specified quaternion. Returns pointer to this updated matrix.

func (*Matrix4) MakeRotationX Uses

func (m *Matrix4) MakeRotationX(theta float32) *Matrix4

MakeRotationX sets this matrix to a rotation matrix of angle theta around the X axis. Returns pointer to this updated matrix.

func (*Matrix4) MakeRotationY Uses

func (m *Matrix4) MakeRotationY(theta float32) *Matrix4

MakeRotationY sets this matrix to a rotation matrix of angle theta around the Y axis. Returns pointer to this updated matrix.

func (*Matrix4) MakeRotationZ Uses

func (m *Matrix4) MakeRotationZ(theta float32) *Matrix4

MakeRotationZ sets this matrix to a rotation matrix of angle theta around the Z axis. Returns pointer to this updated matrix.

func (*Matrix4) MakeScale Uses

func (m *Matrix4) MakeScale(x, y, z float32) *Matrix4

MakeScale sets this matrix to a scale transformation matrix using the specified x, y and z values. Returns pointer to this updated matrix.

func (*Matrix4) MakeTranslation Uses

func (m *Matrix4) MakeTranslation(x, y, z float32) *Matrix4

MakeTranslation sets this matrix to a translation matrix from the specified x, y and z values. Returns pointer to this updated matrix.

func (*Matrix4) Multiply Uses

func (m *Matrix4) Multiply(other *Matrix4) *Matrix4

Multiply multiply this matrix by the other matrix Returns pointer to this updated matrix.

func (*Matrix4) MultiplyMatrices Uses

func (m *Matrix4) MultiplyMatrices(a, b *Matrix4) *Matrix4

MultiplyMatrices multiply matrix a by b (i.e. b*a) storing the result in this matrix. Returns pointer to this updated matrix.

func (*Matrix4) MultiplyScalar Uses

func (m *Matrix4) MultiplyScalar(s float32) *Matrix4

MultiplyScalar multiplies each element of this matrix by the specified scalar. Returns pointer to this updated matrix.

func (*Matrix4) Scale Uses

func (m *Matrix4) Scale(v *Vector3) *Matrix4

Scale multiply the first column of this matrix by the vector X component, the second column by the vector Y component and the third column by the vector Z component. The matrix fourth column is unchanged. Returns pointer to this updated matrix.

func (*Matrix4) Set Uses

func (m *Matrix4) Set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 float32) *Matrix4

Set sets all the elements of this matrix row by row starting at row1, column1, row1, column2, row1, column3 and so forth. Returns pointer to this updated Matrix.

func (*Matrix4) SetPosition Uses

func (m *Matrix4) SetPosition(v *Vector3) *Matrix4

SetPosition sets this transformation matrix position fields from the specified vector v. Returns pointer to this updated matrix.

func (*Matrix4) ToArray Uses

func (m *Matrix4) ToArray(array []float32, offset int) []float32

ToArray copies this matrix elements to array starting at offset. Returns pointer to the updated array.

func (*Matrix4) Transpose Uses

func (m *Matrix4) Transpose() *Matrix4

Transpose transposes this matrix. Returns pointer to this updated matrix.

func (*Matrix4) Zero Uses

func (m *Matrix4) Zero() *Matrix4

Zero sets this matrix as the zero matrix. Returns the pointer to this updated matrix.

type Plane Uses

type Plane struct {
    // contains filtered or unexported fields
}

Plane represents a plane in 3D space by its normal vector and a constant. When the the normal vector is the unit vector the constant is the distance from the origin.

func NewPlane Uses

func NewPlane(normal *Vector3, constant float32) *Plane

NewPlane creates and returns a new plane from a normal vector and a constant.

func (*Plane) Clone Uses

func (p *Plane) Clone(plane *Plane) *Plane

Clone creates and returns a pointer to a copy of this plane.

func (*Plane) CoplanarPoint Uses

func (p *Plane) CoplanarPoint(optionalTarget *Vector3) *Vector3

CoplanarPoint sets the optionalTarget to a point in the plane and also returns it. The point set and returned is the closest point from the origin.

func (*Plane) Copy Uses

func (p *Plane) Copy(other *Plane) *Plane

Copy sets this plane to a copy of other. Returns pointer to this updated plane.

func (*Plane) DistanceToPoint Uses

func (p *Plane) DistanceToPoint(point *Vector3) float32

DistanceToPoint returns the distance of this plane from point.

func (*Plane) DistanceToSphere Uses

func (p *Plane) DistanceToSphere(sphere *Sphere) float32

DistanceToSphere returns the distance of this place from the sphere.

func (*Plane) Equals Uses

func (p *Plane) Equals(other *Plane) bool

Equals returns if this plane is equal to other

func (*Plane) IntersectLine Uses

func (p *Plane) IntersectLine(line *Line3, optionalTarget *Vector3) *Vector3

IntersectLine calculates the point in the plane which intersets the specified line. Sets the optionalTarget, if not nil to this point, and also returns it. Returns nil if the line does not intersects the plane.

func (*Plane) IsIntersectionLine Uses

func (p *Plane) IsIntersectionLine(line *Line3) bool

IsIntersectionLine returns the line intersects this plane.

func (*Plane) Negate Uses

func (p *Plane) Negate() *Plane

Negate negates this plane normal. Returns pointer to this updated plane.

func (*Plane) Normalize Uses

func (p *Plane) Normalize() *Plane

Normalize normalizes this plane normal vector and adjusts the constant. Note: will lead to a divide by zero if the plane is invalid. Returns pointer to this updated plane.

func (*Plane) Set Uses

func (p *Plane) Set(normal *Vector3, constant float32) *Plane

Set sets this plane normal vector and constant. Returns pointer to this updated plane.

func (*Plane) SetComponents Uses

func (p *Plane) SetComponents(x, y, z, w float32) *Plane

SetComponents sets this plane normal vector components and constant. Returns pointer to this updated plane.

func (*Plane) SetFromCoplanarPoints Uses

func (p *Plane) SetFromCoplanarPoints(a, b, c *Vector3) *Plane

SetFromCoplanarPoints sets this plane from three coplanar points. Returns pointer to this updated plane.

func (*Plane) SetFromNormalAndCoplanarPoint Uses

func (p *Plane) SetFromNormalAndCoplanarPoint(normal *Vector3, point *Vector3) *Plane

SetFromNormalAndCoplanarPoint sets this plane from a normal vector and a point on the plane. Returns pointer to this updated plane.

func (*Plane) Translate Uses

func (p *Plane) Translate(offset *Vector3) *Plane

Translate translates this plane in the direction of its normal by offset. Returns pointer to this updated plane.

type Quaternion Uses

type Quaternion struct {
    X   float32
    Y   float32
    Z   float32
    W   float32
}

Quaternion is quaternion with X,Y,Z and W components.

func NewQuaternion Uses

func NewQuaternion(x, y, z, w float32) *Quaternion

NewQuaternion creates and returns a pointer to a new quaternion from the specified components.

func (*Quaternion) Clone Uses

func (q *Quaternion) Clone() *Quaternion

Clone returns a copy of this quaternion

func (*Quaternion) Conjugate Uses

func (q *Quaternion) Conjugate() *Quaternion

Conjugate sets this quaternion to its conjugate. Returns pointer to this updated quaternion.

func (*Quaternion) Copy Uses

func (q *Quaternion) Copy(other *Quaternion) *Quaternion

Copy copies the other quaternion into this one. Returns pointer to this updated quaternion.

func (*Quaternion) Dot Uses

func (q *Quaternion) Dot(other *Quaternion) float32

Dot returns the dot products of this quaternion with other.

func (*Quaternion) Equals Uses

func (q *Quaternion) Equals(other *Quaternion) bool

Equals returns if this quaternion is equal to other.

func (*Quaternion) FromArray Uses

func (q *Quaternion) FromArray(array []float32, offset int) *Quaternion

FromArray sets this quaternion's components from array starting at offset. Returns pointer to this updated quaternion.

func (*Quaternion) Inverse Uses

func (q *Quaternion) Inverse() *Quaternion

Inverse sets this quaternion to its inverse. Returns pointer to this updated quaternion.

func (*Quaternion) IsIdentity Uses

func (q *Quaternion) IsIdentity() bool

IsIdentity returns it this is an identity quaternion.

func (*Quaternion) Length Uses

func (q *Quaternion) Length() float32

Length returns the length of this quaternion

func (*Quaternion) Multiply Uses

func (q *Quaternion) Multiply(other *Quaternion) *Quaternion

Multiply sets this quaternion to the multiplication of itself by other. Returns pointer to this updated quaternion.

func (*Quaternion) MultiplyQuaternions Uses

func (q *Quaternion) MultiplyQuaternions(a, b *Quaternion) *Quaternion

MultiplyQuaternions set this quaternion to the multiplication of a by b. Returns pointer to this updated quaternion.

func (*Quaternion) Normalize Uses

func (q *Quaternion) Normalize() *Quaternion

Normalize normalizes this quaternion. Returns pointer to this updated quaternion.

func (*Quaternion) NormalizeFast Uses

func (q *Quaternion) NormalizeFast() *Quaternion

NormalizeFast approximates normalizing this quaternion. Works best when the quaternion is already almost-normalized. Returns pointer to this updated quaternion.

func (*Quaternion) Set Uses

func (q *Quaternion) Set(x, y, z, w float32) *Quaternion

Set sets this quaternion's components. Returns pointer to this updated quaternion.

func (*Quaternion) SetFromAxisAngle Uses

func (q *Quaternion) SetFromAxisAngle(axis *Vector3, angle float32) *Quaternion

SetFromAxisAngle sets this quaternion with the rotation specified by the given axis and angle. Returns pointer to this updated quaternion.

func (*Quaternion) SetFromEuler Uses

func (q *Quaternion) SetFromEuler(euler *Vector3) *Quaternion

SetFromEuler sets this quaternion from the specified vector with euler angles for each axis. It is assumed that the Euler angles are in XYZ order. Returns pointer to this updated quaternion.

func (*Quaternion) SetFromRotationMatrix Uses

func (q *Quaternion) SetFromRotationMatrix(m *Matrix4) *Quaternion

SetFromRotationMatrix sets this quaternion from the specified rotation matrix. Returns pointer to this updated quaternion.

func (*Quaternion) SetFromUnitVectors Uses

func (q *Quaternion) SetFromUnitVectors(vFrom, vTo *Vector3) *Quaternion

SetFromUnitVectors sets this quaternion to the rotation from vector vFrom to vTo. The vectors must be normalized. Returns pointer to this updated quaternion.

func (*Quaternion) SetIdentity Uses

func (q *Quaternion) SetIdentity() *Quaternion

SetIdentity sets this quanternion to the identity quaternion. Returns pointer to this updated quaternion.

func (*Quaternion) SetW Uses

func (q *Quaternion) SetW(val float32) *Quaternion

SetW sets this quaternion's W component. Returns pointer to this updated quaternion.

func (*Quaternion) SetX Uses

func (q *Quaternion) SetX(val float32) *Quaternion

SetX sets this quaternion's X component. Returns pointer to this updated quaternion.

func (*Quaternion) SetY Uses

func (q *Quaternion) SetY(val float32) *Quaternion

SetY sets this quaternion's Y component. Returns pointer to this updated quaternion.

func (*Quaternion) SetZ Uses

func (q *Quaternion) SetZ(val float32) *Quaternion

SetZ sets this quaternion's Z component. Returns pointer to this updated quaternion.

func (*Quaternion) Slerp Uses

func (q *Quaternion) Slerp(other *Quaternion, t float32) *Quaternion

Slerp sets this quaternion to another quaternion which is the spherically linear interpolation from this quaternion to other using t. Returns pointer to this updated quaternion.

func (*Quaternion) ToArray Uses

func (q *Quaternion) ToArray(array []float32, offset int) []float32

ToArray copies this quaternions's components to array starting at offset. Returns pointer to this updated array.

type Ray Uses

type Ray struct {
    // contains filtered or unexported fields
}

Ray represents an oriented 3D line segment defined by an origin point and a direction vector.

func NewRay Uses

func NewRay(origin *Vector3, direction *Vector3) *Ray

NewRay creates and returns a pointer to a Ray object with the specified origin and direction vectors. If a nil pointer is supplied for any of the parameters, the zero vector will be used.

func (*Ray) ApplyMatrix4 Uses

func (ray *Ray) ApplyMatrix4(matrix4 *Matrix4) *Ray

ApplyMatrix4 multiplies this ray origin and direction by the specified matrix4, basically transforming this ray coordinates.

func (*Ray) At Uses

func (ray *Ray) At(t float32, optionalTarget *Vector3) *Vector3

At calculates the point in the ray which is at the specified t distance from the origin along its direction. The calculated point is stored in optionalTarget, if not nil, and also returned.

func (*Ray) Clone Uses

func (ray *Ray) Clone() *Ray

Clone creates and returns a pointer to copy of this ray.

func (*Ray) ClosestPointToPoint Uses

func (ray *Ray) ClosestPointToPoint(point, optionalTarget *Vector3) *Vector3

ClosestPointToPoint calculates the point in the ray which is closest to the specified point. The calculated point is stored in optionalTarget, if not nil, and also returned.

func (*Ray) Copy Uses

func (ray *Ray) Copy(other *Ray) *Ray

Copy copies other ray into this one.

func (*Ray) Direction Uses

func (ray *Ray) Direction() Vector3

Direction returns a copy of this ray current direction.

func (*Ray) DistanceSqToPoint Uses

func (ray *Ray) DistanceSqToPoint(point *Vector3) float32

DistanceSqToPoint returns the smallest squared distance from the ray direction vector to the specified point. If the ray was pointed directly at the point this distance would be 0.

func (*Ray) DistanceSqToSegment Uses

func (ray *Ray) DistanceSqToSegment(v0, v1, optionalPointOnRay, optionalPointOnSegment *Vector3) float32

DistanceSqToSegment returns the smallest squared distance from this ray to the line segment from v0 to v1. If optionalPointOnRay Vector3 is not nil, it is set with the coordinates of the point on the ray. if optionalPointOnSegment Vector3 is not nil, it is set with the coordinates of the point on the segment.

func (*Ray) DistanceToPlane Uses

func (ray *Ray) DistanceToPlane(plane *Plane) float32

DistanceToPlane returns the distance of this ray origin to its intersection point in the plane. If the ray does not intersects the plane, returns NaN.

func (*Ray) DistanceToPoint Uses

func (ray *Ray) DistanceToPoint(point *Vector3) float32

DistanceToPoint returns the smallest distance from the ray direction vector to the specified point.

func (*Ray) Equals Uses

func (ray *Ray) Equals(other *Ray) bool

Equals returns if this ray is equal to other

func (*Ray) IntersectBox Uses

func (ray *Ray) IntersectBox(box *Box3, optionalTarget *Vector3) *Vector3

IntersectBox calculates the point which is the intersection of this ray with the specified box. The calculated point is stored in optionalTarget, it not nil, and also returned. If no intersection is found the calculated point is set to nil.

func (*Ray) IntersectPlane Uses

func (ray *Ray) IntersectPlane(plane *Plane, optionalTarget *Vector3) *Vector3

IntersectPlane calculates the point which is the intersection of this ray with the specified plane. The calculated point is stored in optionalTarget, if not nil, and also returned. If no intersection is found the calculated point is set to nil.

func (*Ray) IntersectSphere Uses

func (ray *Ray) IntersectSphere(sphere *Sphere, optionalTarget *Vector3) *Vector3

IntersectSphere calculates the point which is the intersection of this ray with the specified sphere. The calculated point is stored in optionalTarget, it not nil, and also returned. If no intersection is found the calculated point is set to nil.

func (*Ray) IntersectTriangle Uses

func (ray *Ray) IntersectTriangle(a, b, c *Vector3, backfaceCulling bool, point *Vector3) bool

IntersectTriangle returns if this ray intersects the triangle with the face defined by points a, b, c. Returns true if it intersects and sets the point parameter with the intersected point coordinates. If backfaceCulling is false it ignores the intersection if the face is not oriented in the ray direction.

func (*Ray) IsIntersectPlane Uses

func (ray *Ray) IsIntersectPlane(plane *Plane) bool

IsIntersectPlane returns if this ray intersects the specified plane.

func (*Ray) IsIntersectionBox Uses

func (ray *Ray) IsIntersectionBox(box *Box3) bool

IsIntersectionBox returns if this ray intersects the specified box.

func (*Ray) IsIntersectionSphere Uses

func (ray *Ray) IsIntersectionSphere(sphere *Sphere) bool

IsIntersectionSphere returns if this ray intersects with the specified sphere.

func (*Ray) Origin Uses

func (ray *Ray) Origin() Vector3

Origin returns a copy of this ray current origin.

func (*Ray) Recast Uses

func (ray *Ray) Recast(t float32) *Ray

Recast sets the new origin of the ray at the specified distance t from its origin along its direction.

func (*Ray) Set Uses

func (ray *Ray) Set(origin, direction *Vector3) *Ray

Set sets the origin and direction vectors of this Ray.

type Sphere Uses

type Sphere struct {
    Center Vector3 // center of the sphere
    Radius float32 // radius of the sphere
}

Sphere represents a 3D sphere defined by its center point and a radius

func NewSphere Uses

func NewSphere(center *Vector3, radius float32) *Sphere

NewSphere creates and returns a pointer to a new sphere with the specified center and radius.

func (*Sphere) ApplyMatrix4 Uses

func (s *Sphere) ApplyMatrix4(matrix *Matrix4) *Sphere

ApplyMatrix4 applies the specified matrix transform to this sphere. Returns pointer to this updated sphere.

func (*Sphere) ClampPoint Uses

func (s *Sphere) ClampPoint(point *Vector3, optionalTarget *Vector3) *Vector3

ClampPoint clamps the specified point inside the sphere. If the specified point is inside the sphere, it is the clamped point. Otherwise the clamped point is the the point in the sphere surface in the nearest of the specified point. The clamped point is stored in optionalTarget, if not nil, and returned.

func (*Sphere) ContainsPoint Uses

func (s *Sphere) ContainsPoint(point *Vector3) bool

ContainsPoint returns if this sphere contains the specified point.

func (*Sphere) Copy Uses

func (s *Sphere) Copy(other *Sphere) *Sphere

Copy copy other sphere to this one. Returns pointer to this update sphere.

func (*Sphere) DistanceToPoint Uses

func (s *Sphere) DistanceToPoint(point *Vector3) float32

DistanceToPoint returns the distance from the sphere surface to the specified point.

func (*Sphere) Empty Uses

func (s *Sphere) Empty(sphere *Sphere) bool

Empty checks if this sphere is empty (radius <= 0)

func (*Sphere) GetBoundingBox Uses

func (s *Sphere) GetBoundingBox(optionalTarget *Box3) *Box3

GetBoundingBox calculates a Box3 which bounds this sphere. Update optionalTarget with the calculated Box3, if not nil, and also returns it.

func (*Sphere) IntersectSphere Uses

func (s *Sphere) IntersectSphere(other *Sphere) bool

IntersectSphere returns if other sphere intersects this one.

func (*Sphere) Set Uses

func (s *Sphere) Set(center *Vector3, radius float32) *Sphere

Set sets the center and radius of this sphere. Returns pointer to this update sphere.

func (*Sphere) SetFromPoints Uses

func (s *Sphere) SetFromPoints(points []Vector3, optionalCenter *Vector3) *Sphere

SetFromPoints sets this sphere from the specified points array and optional center. Returns pointer to this update sphere.

func (*Sphere) Translate Uses

func (s *Sphere) Translate(offset *Vector3) *Sphere

Translate translates this sphere by the specified offset. Returns pointer to this updated sphere.

type Spline Uses

type Spline struct {
    // contains filtered or unexported fields
}

func NewSpline Uses

func NewSpline(points []Vector3) *Spline

func (*Spline) InitFromArray Uses

func (this *Spline) InitFromArray(a []float32)

type Triangle Uses

type Triangle struct {
    // contains filtered or unexported fields
}

Triangle represents a triangle made of three vertices.

func NewTriangle Uses

func NewTriangle(a, b, c *Vector3) *Triangle

NewTriangle returns a pointer to a new Triangle object.

func (*Triangle) Area Uses

func (t *Triangle) Area() float32

Area returns the triangle's area.

func (*Triangle) BarycoordFromPoint Uses

func (t *Triangle) BarycoordFromPoint(point, optionalTarget *Vector3) *Vector3

BarycoordFromPoint returns the barycentric coordinates for the specified point.

func (*Triangle) Clone Uses

func (t *Triangle) Clone(triangle *Triangle) *Triangle

Clone clones a triangle.

func (*Triangle) ContainsPoint Uses

func (t *Triangle) ContainsPoint(point *Vector3) bool

ContainsPoint returns whether the triangle contains a point.

func (*Triangle) Copy Uses

func (t *Triangle) Copy(triangle *Triangle) *Triangle

Copy modifies the receiver triangle to match the provided triangle.

func (*Triangle) Equals Uses

func (t *Triangle) Equals(triangle *Triangle) bool

Equals returns whether the triangles are equal in all their vertices.

func (*Triangle) Midpoint Uses

func (t *Triangle) Midpoint(optionalTarget *Vector3) *Vector3

Midpoint returns the triangle's midpoint.

func (*Triangle) Normal Uses

func (t *Triangle) Normal(optionalTarget *Vector3) *Vector3

Normal returns the triangle's normal.

func (*Triangle) Plane Uses

func (t *Triangle) Plane(optionalTarget *Plane) *Plane

Plane returns a Plane object aligned with the triangle.

func (*Triangle) Set Uses

func (t *Triangle) Set(a, b, c *Vector3) *Triangle

Set sets the triangle's three vertices.

func (*Triangle) SetFromPointsAndIndices Uses

func (t *Triangle) SetFromPointsAndIndices(points []*Vector3, i0, i1, i2 int) *Triangle

SetFromPointsAndIndices sets the triangle's vertices based on the specified points and indices.

type Vector2 Uses

type Vector2 struct {
    X   float32
    Y   float32
}

Vector2 is a 2D vector/point with X and Y components.

func NewVec2 Uses

func NewVec2() *Vector2

NewVec2 creates and returns a pointer to a new zero-ed Vector2.

func NewVector2 Uses

func NewVector2(x, y float32) *Vector2

NewVector2 creates and returns a pointer to a new Vector2 with the specified x and y components

func (*Vector2) Add Uses

func (v *Vector2) Add(other *Vector2) *Vector2

Add adds other vector to this one. Returns the pointer to this updated vector.

func (*Vector2) AddScalar Uses

func (v *Vector2) AddScalar(s float32) *Vector2

AddScalar adds scalar s to each component of this vector. Returns the pointer to this updated vector.

func (*Vector2) AddVectors Uses

func (v *Vector2) AddVectors(a, b *Vector2) *Vector2

AddVectors adds vectors a and b to this one. Returns the pointer to this updated vector.

func (*Vector2) Ceil Uses

func (v *Vector2) Ceil() *Vector2

Ceil applies math32.Ceil() to each of this vector's components. Returns the pointer to this updated vector.

func (*Vector2) Clamp Uses

func (v *Vector2) Clamp(min, max *Vector2) *Vector2

Clamp sets this vector components to be no less than the corresponding components of min and not greater than the corresponding components of max. Assumes min < max, if this assumption isn't true it will not operate correctly. Returns the pointer to this updated vector.

func (*Vector2) ClampScalar Uses

func (v *Vector2) ClampScalar(minVal, maxVal float32) *Vector2

ClampScalar sets this vector components to be no less than minVal and not greater than maxVal. Returns the pointer to this updated vector.

func (*Vector2) Component Uses

func (v *Vector2) Component(index int) float32

Component returns this vector component by its index: 0 for X, 1 for Y

func (*Vector2) Copy Uses

func (v *Vector2) Copy(other *Vector2) *Vector2

Copy copies other vector to this one. It is equivalent to: *v = *other. Returns the pointer to this updated vector.

func (*Vector2) DistanceTo Uses

func (v *Vector2) DistanceTo(other *Vector2) float32

DistanceTo returns the distance of this point to other.

func (*Vector2) DistanceToSquared Uses

func (v *Vector2) DistanceToSquared(other *Vector2) float32

DistanceToSquared returns the distance squared of this point to other.

func (*Vector2) Divide Uses

func (v *Vector2) Divide(other *Vector2) *Vector2

Divide divides each component of this vector by the corresponding one from other vector. Returns the pointer to this updated vector

func (*Vector2) DivideScalar Uses

func (v *Vector2) DivideScalar(scalar float32) *Vector2

DivideScalar divides each component of this vector by the scalar s. If scalar is zero, sets this vector to zero. Returns the pointer to this updated vector.

func (*Vector2) Dot Uses

func (v *Vector2) Dot(other *Vector2) float32

Dot returns the dot product of this vector with other. None of the vectors are changed.

func (*Vector2) Equals Uses

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

Equals returns if this vector is equal to other.

func (*Vector2) Floor Uses

func (v *Vector2) Floor() *Vector2

Floor applies math32.Floor() to each of this vector's components. Returns the pointer to this updated vector.

func (*Vector2) FromArray Uses

func (v *Vector2) FromArray(array []float32, offset int) *Vector2

FromArray sets this vector's components from the specified array and offset Returns the pointer to this updated vector.

func (*Vector2) InTriangle Uses

func (v *Vector2) InTriangle(p0, p1, p2 *Vector2) bool

InTriangle returns whether the vector is inside the specified triangle.

func (*Vector2) Length Uses

func (v *Vector2) Length() float32

Length returns the length of this vector.

func (*Vector2) LengthSq Uses

func (v *Vector2) LengthSq() float32

LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.

func (*Vector2) Lerp Uses

func (v *Vector2) Lerp(other *Vector2, alpha float32) *Vector2

Lerp sets each of this vector's components to the linear interpolated value of alpha between ifself and the corresponding other component. Returns the pointer to this updated vector.

func (*Vector2) Max Uses

func (v *Vector2) Max(other *Vector2) *Vector2

Max sets this vector components to the maximum value of itself and other vector. Returns the pointer to this updated vector.

func (*Vector2) Min Uses

func (v *Vector2) Min(other *Vector2) *Vector2

Min sets this vector components to the minimum values of itself and other vector. Returns the pointer to this updated vector.

func (*Vector2) Multiply Uses

func (v *Vector2) Multiply(other *Vector2) *Vector2

Multiply multiplies each component of this vector by the corresponding one from other vector. Returns the pointer to this updated vector.

func (*Vector2) MultiplyScalar Uses

func (v *Vector2) MultiplyScalar(s float32) *Vector2

MultiplyScalar multiplies each component of this vector by the scalar s. Returns the pointer to this updated vector.

func (*Vector2) Negate Uses

func (v *Vector2) Negate() *Vector2

Negate negates each of this vector's components. Returns the pointer to this updated vector.

func (*Vector2) Normalize Uses

func (v *Vector2) Normalize() *Vector2

Normalize normalizes this vector so its length will be 1. Returns the pointer to this updated vector.

func (*Vector2) Round Uses

func (v *Vector2) Round() *Vector2

Round rounds each of this vector's components. Returns the pointer to this updated vector.

func (*Vector2) Set Uses

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

Set sets this vector X and Y components. Returns the pointer to this updated vector.

func (*Vector2) SetByName Uses

func (v *Vector2) SetByName(name string, value float32)

SetByName sets this vector component value by its case insensitive name: "x" or "y".

func (*Vector2) SetComponent Uses

func (v *Vector2) SetComponent(index int, value float32) *Vector2

SetComponent sets this vector component value by its index: 0 for X, 1 for Y. Returns the pointer to this updated vector

func (*Vector2) SetLength Uses

func (v *Vector2) SetLength(l float32) *Vector2

SetLength sets this vector to have the specified length. Returns the pointer to this updated vector.

func (*Vector2) SetX Uses

func (v *Vector2) SetX(x float32) *Vector2

SetX sets this vector X component. Returns the pointer to this updated Vector.

func (*Vector2) SetY Uses

func (v *Vector2) SetY(y float32) *Vector2

SetY sets this vector Y component. Returns the pointer to this updated vector.

func (*Vector2) Sub Uses

func (v *Vector2) Sub(other *Vector2) *Vector2

Sub subtracts other vector from this one. Returns the pointer to this updated vector.

func (*Vector2) SubScalar Uses

func (v *Vector2) SubScalar(s float32) *Vector2

SubScalar subtracts scalar s from each component of this vector. Returns the pointer to this updated vector.

func (*Vector2) SubVectors Uses

func (v *Vector2) SubVectors(a, b *Vector2) *Vector2

SubVectors sets this vector to a - b. Returns the pointer to this updated vector.

func (*Vector2) ToArray Uses

func (v *Vector2) ToArray(array []float32, offset int) []float32

ToArray copies this vector's components to array starting at offset. Returns the array.

func (*Vector2) Zero Uses

func (v *Vector2) Zero() *Vector2

Zero sets this vector X and Y components to be zero. Returns the pointer to this updated vector.

type Vector3 Uses

type Vector3 struct {
    X   float32
    Y   float32
    Z   float32
}

Vector3 is a 3D vector/point with X, Y and Z components.

func BarycoordFromPoint Uses

func BarycoordFromPoint(point, a, b, c, optionalTarget *Vector3) *Vector3

BarycoordFromPoint returns the barycentric coordinates for the specified point.

func NewVec3 Uses

func NewVec3() *Vector3

NewVec3 creates and returns a pointer to a new zero-ed Vector3.

func NewVector3 Uses

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

NewVector3 creates and returns a pointer to a new Vector3 with the specified x, y and y components

func Normal Uses

func Normal(a, b, c, optionalTarget *Vector3) *Vector3

Normal returns the triangle's normal.

func (*Vector3) Add Uses

func (v *Vector3) Add(other *Vector3) *Vector3

Add adds other vector to this one. Returns the pointer to this updated vector.

func (*Vector3) AddScalar Uses

func (v *Vector3) AddScalar(s float32) *Vector3

AddScalar adds scalar s to each component of this vector. Returns the pointer to this updated vector.

func (*Vector3) AddVectors Uses

func (v *Vector3) AddVectors(a, b *Vector3) *Vector3

AddVectors adds vectors a and b to this one. Returns the pointer to this updated vector.

func (*Vector3) AlmostEquals Uses

func (v *Vector3) AlmostEquals(other *Vector3, tolerance float32) bool

TODO: implement similar methods for Vector2 and Vector4 AlmostEquals returns whether the vector is almost equal to another vector within the specified tolerance.

func (*Vector3) AngleTo Uses

func (v *Vector3) AngleTo(other *Vector3) float32

AngleTo returns the angle between this vector and other

func (*Vector3) ApplyAxisAngle Uses

func (v *Vector3) ApplyAxisAngle(axis *Vector3, angle float32) *Vector3

ApplyAxisAngle rotates the vector around axis by angle. Returns the pointer to this updated vector.

func (*Vector3) ApplyMatrix3 Uses

func (v *Vector3) ApplyMatrix3(m *Matrix3) *Vector3

ApplyMatrix3 multiplies the specified 3x3 matrix by this vector. Returns the pointer to this updated vector.

func (*Vector3) ApplyMatrix4 Uses

func (v *Vector3) ApplyMatrix4(m *Matrix4) *Vector3

ApplyMatrix4 multiplies the specified 4x4 matrix by this vector. Returns the pointer to this updated vector.

func (*Vector3) ApplyProjection Uses

func (v *Vector3) ApplyProjection(m *Matrix4) *Vector3

ApplyProjection applies the projection matrix m to this vector Returns the pointer to this updated vector.

func (*Vector3) ApplyQuaternion Uses

func (v *Vector3) ApplyQuaternion(q *Quaternion) *Vector3

ApplyQuaternion transforms this vector by multiplying it by the specified quaternion and then by the quaternion inverse. It basically applies the rotation encoded in the quaternion to this vector. Returns the pointer to this updated vector.

func (*Vector3) Ceil Uses

func (v *Vector3) Ceil() *Vector3

Ceil applies math32.Ceil() to each of this vector's components. Returns the pointer to this updated vector.

func (*Vector3) Clamp Uses

func (v *Vector3) Clamp(min, max *Vector3) *Vector3

Clamp sets this vector components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max, if this assumption isn't true it will not operate correctly. Returns the pointer to this updated vector.

func (*Vector3) ClampScalar Uses

func (v *Vector3) ClampScalar(minVal, maxVal float32) *Vector3

ClampScalar sets this vector components to be no less than minVal and not greater than maxVal. Returns the pointer to this updated vector.

func (*Vector3) Clone Uses

func (v *Vector3) Clone() *Vector3

Clone returns a copy of this vector

func (*Vector3) Component Uses

func (v *Vector3) Component(index int) float32

Component returns this vector component by its index: 0 for X, 1 for Y, 2 for Z.

func (*Vector3) Copy Uses

func (v *Vector3) Copy(other *Vector3) *Vector3

Copy copies other vector to this one. It is equivalent to: *v = *other. Returns the pointer to this updated vector.

func (*Vector3) Cross Uses

func (v *Vector3) Cross(other *Vector3) *Vector3

Cross calculates the cross product of this vector with other and returns the result vector.

func (*Vector3) CrossVectors Uses

func (v *Vector3) CrossVectors(a, b *Vector3) *Vector3

CrossVectors calculates the cross product of a and b storing the result in this vector. Returns the pointer to this updated vector.

func (*Vector3) DistanceTo Uses

func (v *Vector3) DistanceTo(other *Vector3) float32

DistanceTo returns the distance of this point to other.

func (*Vector3) DistanceToSquared Uses

func (v *Vector3) DistanceToSquared(other *Vector3) float32

DistanceToSquared returns the distance squared of this point to other.

func (*Vector3) Divide Uses

func (v *Vector3) Divide(other *Vector3) *Vector3

Divide divides each component of this vector by the corresponding one from other vector. Returns the pointer to this updated vector

func (*Vector3) DivideScalar Uses

func (v *Vector3) DivideScalar(scalar float32) *Vector3

DivideScalar divides each component of this vector by the scalar s. If scalar is zero, sets this vector to zero. Returns the pointer to this updated vector.

func (*Vector3) Dot Uses

func (v *Vector3) Dot(other *Vector3) float32

Dot returns the dot product of this vector with other. None of the vectors are changed.

func (*Vector3) Equals Uses

func (v *Vector3) Equals(other *Vector3) bool

Equals returns if this vector is equal to other.

func (*Vector3) Floor Uses

func (v *Vector3) Floor() *Vector3

Floor applies math32.Floor() to each of this vector's components. Returns the pointer to this updated vector.

func (*Vector3) FromArray Uses

func (v *Vector3) FromArray(array []float32, offset int) *Vector3

FromArray sets this vector's components from the specified array and offset Returns the pointer to this updated vector.

func (*Vector3) Length Uses

func (v *Vector3) Length() float32

Length returns the length of this vector.

func (*Vector3) LengthSq Uses

func (v *Vector3) LengthSq() float32

LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.

func (*Vector3) Lerp Uses

func (v *Vector3) Lerp(other *Vector3, alpha float32) *Vector3

Lerp sets each of this vector's components to the linear interpolated value of alpha between ifself and the corresponding other component. Returns the pointer to this updated vector.

func (*Vector3) Max Uses

func (v *Vector3) Max(other *Vector3) *Vector3

Max sets this vector components to the maximum value of itself and other vector. Returns the pointer to this updated vector.

func (*Vector3) Min Uses

func (v *Vector3) Min(other *Vector3) *Vector3

Min sets this vector components to the minimum values of itself and other vector. Returns the pointer to this updated vector.

func (*Vector3) Multiply Uses

func (v *Vector3) Multiply(other *Vector3) *Vector3

Multiply multiplies each component of this vector by the corresponding one from other vector. Returns the pointer to this updated vector.

func (*Vector3) MultiplyScalar Uses

func (v *Vector3) MultiplyScalar(s float32) *Vector3

MultiplyScalar multiplies each component of this vector by the scalar s. Returns the pointer to this updated vector.

func (*Vector3) MultiplyVectors Uses

func (v *Vector3) MultiplyVectors(a, b *Vector3) *Vector3

MultiplyVectors multiply vectors a and b storing the result in this vector. Returns the pointer to this updated vector.

func (*Vector3) Negate Uses

func (v *Vector3) Negate() *Vector3

Negate negates each of this vector's components. Returns the pointer to this updated vector.

func (*Vector3) Normalize Uses

func (v *Vector3) Normalize() *Vector3

Normalize normalizes this vector so its length will be 1. Returns the pointer to this updated vector.

func (*Vector3) ProjectOnPlane Uses

func (v *Vector3) ProjectOnPlane(planeNormal *Vector3) *Vector3

ProjectOnPlane sets this vector to its projection on the plane specified by its normal vector. Returns the pointer to this updated vector.

func (*Vector3) ProjectOnVector Uses

func (v *Vector3) ProjectOnVector(other *Vector3) *Vector3

ProjectOnVector sets this vector to its projection on other vector. Returns the pointer to this updated vector.

func (*Vector3) RandomTangents Uses

func (v *Vector3) RandomTangents() (*Vector3, *Vector3)

RandomTangents computes and returns two arbitrary tangents to the vector.

func (*Vector3) Reflect Uses

func (v *Vector3) Reflect(normal *Vector3) *Vector3

Reflect sets this vector to its reflection relative to the normal vector. The normal vector is assumed to be normalized. Returns the pointer to this updated vector.

func (*Vector3) Round Uses

func (v *Vector3) Round() *Vector3

Round rounds each of this vector's components. Returns the pointer to this updated vector.

func (*Vector3) Set Uses

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

Set sets this vector X, Y and Z components. Returns the pointer to this updated vector.

func (*Vector3) SetByName Uses

func (v *Vector3) SetByName(name string, value float32)

SetByName sets this vector component value by its case insensitive name: "x", "y", or "z".

func (*Vector3) SetComponent Uses

func (v *Vector3) SetComponent(index int, value float32)

SetComponent sets this vector component value by its index: 0 for X, 1 for Y, 2 for Z. Returns the pointer to this updated vector

func (*Vector3) SetFromMatrixColumn Uses

func (v *Vector3) SetFromMatrixColumn(index int, m *Matrix4) *Vector3

SetFromMatrixColumn set this vector with the column at index of the m matrix. Returns the pointer to this updated vector.

func (*Vector3) SetFromMatrixPosition Uses

func (v *Vector3) SetFromMatrixPosition(m *Matrix4) *Vector3

SetFromMatrixPosition set this vector from the translation coordinates in the specified transformation matrix.

func (*Vector3) SetFromQuaternion Uses

func (v *Vector3) SetFromQuaternion(q *Quaternion) *Vector3

SetFromQuaternion sets this vector components to the Euler angles from the specified quaternion Returns the pointer to this updated vector.

func (*Vector3) SetFromRotationMatrix Uses

func (v *Vector3) SetFromRotationMatrix(m *Matrix4) *Vector3

SetFromRotationMatrix sets this vector components to the Euler angles from the specified pure rotation matrix. Returns the pointer to this updated vector.

func (*Vector3) SetLength Uses

func (v *Vector3) SetLength(l float32) *Vector3

SetLength sets this vector to have the specified length. If the current length is zero, does nothing. Returns the pointer to this updated vector.

func (*Vector3) SetX Uses

func (v *Vector3) SetX(x float32) *Vector3

SetX sets this vector X component. Returns the pointer to this updated Vector.

func (*Vector3) SetY Uses

func (v *Vector3) SetY(y float32) *Vector3

SetY sets this vector Y component. Returns the pointer to this updated vector.

func (*Vector3) SetZ Uses

func (v *Vector3) SetZ(z float32) *Vector3

SetZ sets this vector Z component. Returns the pointer to this updated vector.

func (*Vector3) Sub Uses

func (v *Vector3) Sub(other *Vector3) *Vector3

Sub subtracts other vector from this one. Returns the pointer to this updated vector.

func (*Vector3) SubScalar Uses

func (v *Vector3) SubScalar(s float32) *Vector3

SubScalar subtracts scalar s from each component of this vector. Returns the pointer to this updated vector.

func (*Vector3) SubVectors Uses

func (v *Vector3) SubVectors(a, b *Vector3) *Vector3

SubVectors sets this vector to a - b. Returns the pointer to this updated vector.

func (*Vector3) ToArray Uses

func (v *Vector3) ToArray(array []float32, offset int) []float32

ToArray copies this vector's components to array starting at offset. Returns the array.

func (*Vector3) Zero Uses

func (v *Vector3) Zero() *Vector3

Zero sets this vector X, Y and Z components to be zero. Returns the pointer to this updated vector.

type Vector4 Uses

type Vector4 struct {
    X   float32
    Y   float32
    Z   float32
    W   float32
}

Vector4 is a vector/point in homogeneous coordinates with X, Y, Z and W components.

func NewVec4 Uses

func NewVec4() *Vector4

NewVec4 creates and returns a pointer to a new zero-ed Vector4 (with W=1).

func NewVector4 Uses

func NewVector4(x, y, z, w float32) *Vector4

NewVector4 creates and returns a pointer to a new Vector4

func (*Vector4) Add Uses

func (v *Vector4) Add(other *Vector4) *Vector4

Add adds other vector to this one. Returns the pointer to this updated vector.

func (*Vector4) AddScalar Uses

func (v *Vector4) AddScalar(s float32) *Vector4

AddScalar adds scalar s to each component of this vector. Returns the pointer to this updated vector.

func (*Vector4) AddVectors Uses

func (v *Vector4) AddVectors(a, b *Vector4) *Vector4

AddVectors adds vectors a and b to this one. Returns the pointer to this updated vector.

func (*Vector4) ApplyMatrix4 Uses

func (v *Vector4) ApplyMatrix4(m *Matrix4) *Vector4

ApplyMatrix4 multiplies the specified 4x4 matrix by this vector. Returns the pointer to this updated vector.

func (*Vector4) Ceil Uses

func (v *Vector4) Ceil() *Vector4

Ceil applies math32.Ceil() to each of this vector's components. Returns the pointer to this updated vector.

func (*Vector4) Clamp Uses

func (v *Vector4) Clamp(min, max *Vector4) *Vector4

Clamp sets this vector components to be no less than the corresponding components of min and not greater than the corresponding component of max. Assumes min < max, if this assumption isn't true it will not operate correctly. Returns the pointer to this updated vector.

func (*Vector4) ClampScalar Uses

func (v *Vector4) ClampScalar(minVal, maxVal float32) *Vector4

ClampScalar sets this vector components to be no less than minVal and not greater than maxVal. Returns the pointer to this updated vector.

func (*Vector4) Clone Uses

func (v *Vector4) Clone() *Vector4

Clone returns a copy of this vector

func (*Vector4) Component Uses

func (v *Vector4) Component(index int) float32

Component returns this vector component by its index: 0 for X, 1 for Y, 2 for Z, 3 for W.

func (*Vector4) Copy Uses

func (v *Vector4) Copy(other *Vector4) *Vector4

Copy copies other vector to this one. Returns the pointer to this updated vector.

func (*Vector4) Divide Uses

func (v *Vector4) Divide(other *Vector4) *Vector4

Divide divides each component of this vector by the corresponding one from other vector. Returns the pointer to this updated vector

func (*Vector4) DivideScalar Uses

func (v *Vector4) DivideScalar(scalar float32) *Vector4

DivideScalar divides each component of this vector by the scalar s. If scalar is zero, sets this vector to zero. Returns the pointer to this updated vector.

func (*Vector4) Dot Uses

func (v *Vector4) Dot(other *Vector4) float32

Dot returns the dot product of this vector with other. None of the vectors are changed.

func (*Vector4) Equals Uses

func (v *Vector4) Equals(other *Vector4) bool

Equals returns if this vector is equal to other.

func (*Vector4) Floor Uses

func (v *Vector4) Floor() *Vector4

Floor applies math32.Floor() to each of this vector's components. Returns the pointer to this updated vector.

func (*Vector4) FromArray Uses

func (v *Vector4) FromArray(array []float32, offset int) *Vector4

FromArray sets this vector's components from the specified array and offset Returns the pointer to this updated vector.

func (*Vector4) Length Uses

func (v *Vector4) Length() float32

Length returns the length of this vector.

func (*Vector4) LengthSq Uses

func (v *Vector4) LengthSq() float32

LengthSq returns the length squared of this vector. LengthSq can be used to compare vectors' lengths without the need to perform a square root.

func (*Vector4) Lerp Uses

func (v *Vector4) Lerp(other *Vector4, alpha float32) *Vector4

Lerp sets each of this vector's components to the linear interpolated value of alpha between ifself and the corresponding other component. Returns the pointer to this updated vector.

func (*Vector4) Max Uses

func (v *Vector4) Max(other *Vector4) *Vector4

Max sets this vector components to the maximum value of itself and other vector. Returns the pointer to this updated vector.

func (*Vector4) Min Uses

func (v *Vector4) Min(other *Vector4) *Vector4

Min sets this vector components to the minimum values of itself and other vector. Returns the pointer to this updated vector.

func (*Vector4) Multiply Uses

func (v *Vector4) Multiply(other *Vector4) *Vector4

Multiply multiplies each component of this vector by the corresponding one from other vector. Returns the pointer to this updated vector.

func (*Vector4) MultiplyScalar Uses

func (v *Vector4) MultiplyScalar(scalar float32) *Vector4

MultiplyScalar multiplies each component of this vector by the scalar s. Returns the pointer to this updated vector.

func (*Vector4) Negate Uses

func (v *Vector4) Negate() *Vector4

Negate negates each of this vector's components. Returns the pointer to this updated vector.

func (*Vector4) Normalize Uses

func (v *Vector4) Normalize() *Vector4

Normalize normalizes this vector so its length will be 1. Returns the pointer to this updated vector.

func (*Vector4) Round Uses

func (v *Vector4) Round() *Vector4

Round rounds each of this vector's components. Returns the pointer to this updated vector.

func (*Vector4) Set Uses

func (v *Vector4) Set(x, y, z, w float32) *Vector4

Set sets this vector X, Y, Z and W components. Returns the pointer to this updated vector.

func (*Vector4) SetAxisAngleFromQuaternion Uses

func (v *Vector4) SetAxisAngleFromQuaternion(q *Quaternion) *Vector4

SetAxisAngleFromQuaternion set this vector to be the axis (x, y, z) and angle (w) of a rotation specified the quaternion q. Assumes q is normalized.

func (*Vector4) SetAxisFromRotationMatrix Uses

func (v *Vector4) SetAxisFromRotationMatrix(m *Matrix4) *Vector4

SetAxisFromRotationMatrix this vector to be the axis (x, y, z) and angle (w) of a rotation specified the matrix m. Assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).

func (*Vector4) SetByName Uses

func (v *Vector4) SetByName(name string, value float32)

SetByName sets this vector component value by its case insensitive name: "x", "y", "z" or "w".

func (*Vector4) SetComponent Uses

func (v *Vector4) SetComponent(index int, value float32) *Vector4

SetComponent sets this vector component value by its index: 0 for X, 1 for Y, 2 for Z, 3 for W. Returns the pointer to this updated vector

func (*Vector4) SetLength Uses

func (v *Vector4) SetLength(l float32) *Vector4

SetLength sets this vector to have the specified length. If the current length is zero, does nothing. Returns the pointer to this updated vector.

func (*Vector4) SetVector3 Uses

func (v *Vector4) SetVector3(other *Vector3, w float32) *Vector4

SetVector3 sets this vector from another Vector3 and W

func (*Vector4) SetW Uses

func (v *Vector4) SetW(w float32) *Vector4

SetW sets this vector W component. Returns the pointer to this updated vector.

func (*Vector4) SetX Uses

func (v *Vector4) SetX(x float32) *Vector4

SetX sets this vector X component. Returns the pointer to this updated Vector.

func (*Vector4) SetY Uses

func (v *Vector4) SetY(y float32) *Vector4

SetY sets this vector Y component. Returns the pointer to this updated vector.

func (*Vector4) SetZ Uses

func (v *Vector4) SetZ(z float32) *Vector4

SetZ sets this vector Z component. Returns the pointer to this updated vector.

func (*Vector4) Sub Uses

func (v *Vector4) Sub(other *Vector4) *Vector4

Sub subtracts other vector from this one. Returns the pointer to this updated vector.

func (*Vector4) SubScalar Uses

func (v *Vector4) SubScalar(s float32) *Vector4

SubScalar subtracts scalar s from each component of this vector. Returns the pointer to this updated vector.

func (*Vector4) SubVectors Uses

func (v *Vector4) SubVectors(a, b *Vector4) *Vector4

SubVectors sets this vector to a - b. Returns the pointer to this updated vector.

func (*Vector4) ToArray Uses

func (v *Vector4) ToArray(array []float32, offset int) []float32

ToArray copies this vector's components to array starting at offset. Returns the array.

func (*Vector4) Zero Uses

func (v *Vector4) Zero() *Vector4

Zero sets this vector X, Y and Z components to be zero and W to be one. Returns the pointer to this updated vector.

Package math32 imports 4 packages (graph) and is imported by 44 packages. Updated 2018-08-23. Refresh now. Tools for package owners.