math32

package
v0.0.0-...-a112006 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2017 License: BSD-2-Clause Imports: 2 Imported by: 0

Documentation

Overview

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

Constants

View Source
const Pi = math.Pi

Variables

View Source
var Black = Color{0, 0, 0}
View Source
var Black4 = Color4{0, 0, 0, 1}
View Source
var Blue = Color{0, 0, 1}
View Source
var Blue4 = Color4{0, 0, 1, 1}
View Source
var Gray = Color{0.5, 0.5, 0.5}
View Source
var Gray4 = Color4{0.5, 0.5, 0.5, 1}
View Source
var Green = Color{0, 1, 0}
View Source
var Green4 = Color4{0, 1, 0, 1}
View Source
var Infinity = float32(math.Inf(1))
View Source
var Red = Color{1, 0, 0}
View Source
var Red4 = Color4{1, 0, 0, 1}
View Source
var Vector3Back = Vector3{0, 0, -1}
View Source
var Vector3Down = Vector3{0, -1, 0}
View Source
var Vector3Front = Vector3{0, 0, 1}
View Source
var Vector3Left = Vector3{-1, 0, 0}
View Source
var Vector3Right = Vector3{1, 0, 0}
View Source
var Vector3Up = Vector3{0, 1, 0}
View Source
var Vector3Zero = Vector3{0, 0, 0}

Common Vector3 values

View Source
var White = Color{1, 1, 1}
View Source
var White4 = Color4{1, 1, 1, 1}

Functions

func Abs

func Abs(v float32) float32

func Acos

func Acos(v float32) float32

func Asin

func Asin(v float32) float32

func Atan

func Atan(v float32) float32

func Atan2

func Atan2(y, x float32) float32

func Ceil

func Ceil(v float32) float32

func Clamp

func Clamp(x, a, b float32) float32

func ClampBotton

func ClampBotton(x, a float32) float32

func ClampInt

func ClampInt(x, a, b int) int

func ContainsPoint

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

func Cos

func Cos(v float32) float32

func DegToRad

func DegToRad(degrees float32) float32

func Floor

func Floor(v float32) float32

func Inf

func Inf(sign int) float32

func IsNaN

func IsNaN(v float32) bool

func Max

func Max(a, b float32) float32

func Min

func Min(a, b float32) float32

func Mod

func Mod(a, b float32) float32

func NaN

func NaN() float32

func Pow

func Pow(a, b float32) float32

func RadToDeg

func RadToDeg(radians float32) float32

func Round

func Round(v float32) float32

func Sin

func Sin(v float32) float32

func Sqrt

func Sqrt(v float32) float32

func Tan

func Tan(v float32) float32

Types

type ArrayF32

type ArrayF32 []float32

func NewArrayF32

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

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

func (*ArrayF32) AppendColor

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

func (*ArrayF32) AppendVector2

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

func (*ArrayF32) AppendVector3

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

func (*ArrayF32) Bytes

func (a *ArrayF32) Bytes() int

Bytes returns the size of the array in bytes

func (ArrayF32) GetColor

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

func (ArrayF32) GetVector2

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

func (ArrayF32) GetVector3

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

func (*ArrayF32) Len

func (a *ArrayF32) Len() int

Len returns the number of float32 elements in the array

func (ArrayF32) Set

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

func (ArrayF32) SetColor

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

func (ArrayF32) SetVector2

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

func (ArrayF32) SetVector3

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

func (*ArrayF32) Size

func (a *ArrayF32) Size() int

Size returns the number of float32 elements in the array

type ArrayU32

type ArrayU32 []uint32

func NewArrayU32

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

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

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

func (*ArrayU32) Bytes

func (a *ArrayU32) Bytes() int

Bytes returns the size of the array in bytes

func (*ArrayU32) Len

func (a *ArrayU32) Len() int

Len returns the number of float32 elements in the array

func (*ArrayU32) Size

func (a *ArrayU32) Size() int

Size returns the number of float32 elements in the array

type Box2

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

func NewBox2

func NewBox2(min, max *Vector2) *Box2

func (*Box2) Center

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

func (*Box2) ClampPoint

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

func (*Box2) ContainsBox

func (this *Box2) ContainsBox(box *Box2) bool

func (*Box2) ContainsPoint

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

func (*Box2) Copy

func (this *Box2) Copy(box *Box2) *Box2

func (*Box2) DistanceToPoint

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

func (*Box2) Empty

func (this *Box2) Empty() bool

func (*Box2) Equals

func (this *Box2) Equals(box *Box2) bool

func (*Box2) ExpandByPoint

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

func (*Box2) ExpandByScalar

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

func (*Box2) ExpandByVector

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

func (*Box2) GetParameter

func (this *Box2) GetParameter(point *Vector2, optionalTarget *Vector2) *Vector2

func (*Box2) Intersect

func (this *Box2) Intersect(box *Box2) *Box2

func (*Box2) IsIntersectionBox

func (this *Box2) IsIntersectionBox(box *Box2) bool

func (*Box2) MakeEmpty

func (this *Box2) MakeEmpty() *Box2

func (*Box2) Set

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

func (*Box2) SetFromCenterAndSize

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

func (*Box2) SetFromPoints

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

func (*Box2) Size

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

func (*Box2) Translate

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

func (*Box2) Union

func (this *Box2) Union(box *Box2) *Box2

type Box3

type Box3 struct {
	Min Vector3
	Max Vector3
}

func NewBox3

func NewBox3(min, max *Vector3) *Box3

func (*Box3) ApplyMatrix4

func (this *Box3) ApplyMatrix4(matrix *Matrix4) *Box3

func (*Box3) Center

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

func (*Box3) ClampPoint

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

func (*Box3) Clone

func (this *Box3) Clone() *Box3

func (*Box3) ContainsBox

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

func (*Box3) ContainsPoint

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

func (*Box3) Copy

func (this *Box3) Copy(box *Box3) *Box3

func (*Box3) DistanceToPoint

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

func (*Box3) Empty

func (this *Box3) Empty() bool

func (*Box3) Equals

func (this *Box3) Equals(box *Box3) bool

func (*Box3) ExpandByPoint

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

func (*Box3) ExpandByScalar

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

func (*Box3) ExpandByVector

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

func (*Box3) GetBoundingSphere

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

func (*Box3) GetParameter

func (this *Box3) GetParameter(point *Vector3, optionalTarget *Vector3) *Vector3

func (*Box3) Intersect

func (this *Box3) Intersect(box *Box3) *Box3

func (*Box3) IsIntersectionBox

func (this *Box3) IsIntersectionBox(box *Box3) bool

func (*Box3) MakeEmpty

func (this *Box3) MakeEmpty() *Box3

func (*Box3) Set

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

func (*Box3) SetFromCenterAndSize

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

func (*Box3) SetFromPoints

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

func (*Box3) Size

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

func (*Box3) Translate

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

func (*Box3) Union

func (this *Box3) Union(box *Box3) *Box3

type Color

type Color struct {
	R float32
	G float32
	B float32
}

func NewColor

func NewColor(r, g, b float32) *Color

NewColor creates and returns a pointer to a new color with the specified RGB components

func NewColorHex

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

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

func (*Color) AddColors

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

func (*Color) AddScalar

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

func (*Color) Clone

func (c *Color) Clone() *Color

func (*Color) Equals

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

func (*Color) Lerp

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

func (*Color) Multiply

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

func (*Color) MultiplyScalar

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

func (*Color) Set

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

Set sets this color individual R,G,B components

func (*Color) SetHex

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

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

SetName sets the color RGB components from the specified HTML color name

type Color4

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

func NewColor4

func NewColor4(r, g, b, a float32) *Color4

func (*Color4) FromColor

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

FromColor sets this Color4 fields from Color and an alpha

func (*Color4) MultiplyScalar

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

func (*Color4) Set

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

Set sets this color individual R,G,B,A components

func (*Color4) SetHex

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

func (*Color4) SetName

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

SetName sets the color RGB components from the specified HTML color name Alpha component is not modified

func (*Color4) ToColor

func (c *Color4) ToColor() Color

ToColor returns a Color with this Color4 RGB components

type Frustum

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

func NewFrustum

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

func (*Frustum) Clone

func (this *Frustum) Clone() *Frustum

func (*Frustum) ContainsPoint

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

func (*Frustum) Copy

func (this *Frustum) Copy(frustum *Frustum) *Frustum

func (*Frustum) IntersectsBox

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

func (*Frustum) IntersectsSphere

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

func (*Frustum) Set

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

func (*Frustum) SetFromMatrix

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

type Line3

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

func NewLine3

func NewLine3(start, end *Vector3) *Line3

func (*Line3) ApplyMatrix4

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

func (*Line3) At

func (this *Line3) At(t float32, optionalTarget *Vector3) *Vector3

func (*Line3) Center

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

func (*Line3) Clone

func (this *Line3) Clone() *Line3

func (*Line3) ClosestPointToPoint

func (this *Line3) ClosestPointToPoint(point *Vector3, clampToLine bool, optionalTarget *Vector3) *Vector3

func (*Line3) ClosestPointToPointParameter

func (this *Line3) ClosestPointToPointParameter() func(*Vector3, bool) float32

func (*Line3) Copy

func (this *Line3) Copy(line *Line3) *Line3

func (*Line3) Delta

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

func (*Line3) Distance

func (this *Line3) Distance() float32

func (*Line3) DistanceSq

func (this *Line3) DistanceSq() float32

func (*Line3) Equals

func (this *Line3) Equals(line *Line3) bool

func (*Line3) Set

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

type Matrix3

type Matrix3 [9]float32

func NewMatrix3

func NewMatrix3() *Matrix3

func (*Matrix3) ApplyToVector3Array

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

func (*Matrix3) Clone

func (m *Matrix3) Clone() *Matrix3

func (*Matrix3) Copy

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

func (*Matrix3) Determinant

func (m *Matrix3) Determinant() float32

func (*Matrix3) FlattenToArrayOffset

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

func (*Matrix3) FromArray

func (m *Matrix3) FromArray(array []float32) *Matrix3

func (*Matrix3) GetInverse

func (m *Matrix3) GetInverse(src *Matrix4, throwOnInvertible bool) *Matrix3

func (*Matrix3) GetNormalMatrix

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

func (*Matrix3) Identity

func (m *Matrix3) Identity() *Matrix3

func (*Matrix3) MultiplyScalar

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

func (*Matrix3) Set

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

func (*Matrix3) ToArray

func (m *Matrix3) ToArray() []float32

func (*Matrix3) Transpose

func (m *Matrix3) Transpose() *Matrix3

func (*Matrix3) TransposeIntoArray

func (m *Matrix3) TransposeIntoArray(r []float32) *Matrix3

type Matrix4

type Matrix4 [16]float32

func NewMatrix4

func NewMatrix4() *Matrix4

func (*Matrix4) ApplyToVector3Array

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

func (*Matrix4) Clone

func (m *Matrix4) Clone() *Matrix4

func (*Matrix4) Compose

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

func (*Matrix4) Copy

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

Copy copies the specified matrix into this one

func (*Matrix4) CopyPosition

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

Copy position copies the position elements of the specified matrix into this one.

func (*Matrix4) Decompose

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

func (*Matrix4) Determinant

func (m *Matrix4) Determinant() float32

Determinant calculates and returns the determinat of this matrix.

func (*Matrix4) ExtractBasis

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

func (*Matrix4) ExtractRotation

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

func (*Matrix4) FlattenToArrayOffset

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

func (*Matrix4) FromArray

func (m *Matrix4) FromArray(array [16]float32) *Matrix4

func (*Matrix4) GetInverse

func (m *Matrix4) GetInverse(src *Matrix4, throwOnInvertible bool) *Matrix4

GetInverse set this matrix to the inverse of the specified matrix "src".

func (*Matrix4) GetMaxScaleOnAxis

func (m *Matrix4) GetMaxScaleOnAxis() float32

func (*Matrix4) Identity

func (m *Matrix4) Identity() *Matrix4

func (*Matrix4) LookAt

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

func (*Matrix4) MakeBasis

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

func (*Matrix4) MakeFrustum

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

func (*Matrix4) MakeOrthographic

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

func (*Matrix4) MakePerspective

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

func (*Matrix4) MakeRotationAxis

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

func (*Matrix4) MakeRotationFromEuler

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

func (*Matrix4) MakeRotationFromQuaternion

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

func (*Matrix4) MakeRotationX

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

func (*Matrix4) MakeRotationY

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

func (*Matrix4) MakeRotationZ

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

func (*Matrix4) MakeScale

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

func (*Matrix4) MakeTranslation

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

func (*Matrix4) Multiply

func (m *Matrix4) Multiply(src *Matrix4) *Matrix4

Multiply multiply this matrix by the specified matrix

func (*Matrix4) MultiplyMatrices

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

MultiplyMatrices multiply matrix 'a' by 'b' storing the result in this matrix.

func (*Matrix4) MultiplyScalar

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

MultiplyScalar multiplies each element of this matrix by the specified scalar.

func (*Matrix4) MultiplyToArray

func (m *Matrix4) MultiplyToArray(a, b *Matrix4, r []float32) *Matrix4

func (*Matrix4) Scale

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.

func (*Matrix4) Set

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

func (*Matrix4) SetPosition

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

func (*Matrix4) ToArray

func (m *Matrix4) ToArray() []float32

func (*Matrix4) Transpose

func (m *Matrix4) Transpose() *Matrix4

type Plane

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

func NewPlane

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

func (*Plane) ApplyMatrix4

func (this *Plane) ApplyMatrix4(matrix *Matrix4, optionalNormalMatrix *Matrix3) *Plane

func (*Plane) Clone

func (this *Plane) Clone(plane *Plane) *Plane

func (*Plane) CoplanarPoint

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

func (*Plane) Copy

func (this *Plane) Copy(plane *Plane) *Plane

func (*Plane) DistanceToPoint

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

func (*Plane) DistanceToSphere

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

func (*Plane) Equals

func (this *Plane) Equals(plane *Plane) bool

func (*Plane) IntersectLine

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

func (*Plane) IsIntersectionLine

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

func (*Plane) Negate

func (this *Plane) Negate() *Plane

func (*Plane) Normalize

func (this *Plane) Normalize() *Plane

func (*Plane) OrthoPoint

func (this *Plane) OrthoPoint(point *Vector3, optionalTarget *Vector3) *Vector3

func (*Plane) ProjectPoint

func (this *Plane) ProjectPoint(point *Vector3, optionalTarget *Vector3) *Vector3

func (*Plane) Set

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

func (*Plane) SetComponents

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

func (*Plane) SetFromCoplanarPoints

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

func (*Plane) SetFromNormalAndCoplanarPoint

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

func (*Plane) Translate

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

type Quaternion

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

func NewQuaternion

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

func (*Quaternion) Conjugate

func (this *Quaternion) Conjugate() *Quaternion

func (*Quaternion) Copy

func (this *Quaternion) Copy(quaternion *Quaternion) *Quaternion

Copy copies the specified quaternion into this one.

func (*Quaternion) Dot

func (this *Quaternion) Dot(v *Quaternion) float32

func (*Quaternion) Equals

func (this *Quaternion) Equals(quaternion *Quaternion) bool

func (*Quaternion) FromArray

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

func (*Quaternion) Inverse

func (q *Quaternion) Inverse() *Quaternion

func (*Quaternion) IsIdentity

func (q *Quaternion) IsIdentity() bool

func (*Quaternion) Length

func (this *Quaternion) Length() float32

func (*Quaternion) Multiply

func (this *Quaternion) Multiply(q *Quaternion) *Quaternion

func (*Quaternion) MultiplyQuaternions

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

func (*Quaternion) Normalize

func (this *Quaternion) Normalize() *Quaternion

func (*Quaternion) Set

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

func (*Quaternion) SetFromAxisAngle

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

SetFromAxisAngle sets this quaternion with the rotation specified by the given axis and angle.

func (*Quaternion) SetFromEuler

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.

func (*Quaternion) SetFromRotationMatrix

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

func (*Quaternion) SetFromUnitVectors

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

func (*Quaternion) SetIdentity

func (this *Quaternion) SetIdentity() *Quaternion

func (*Quaternion) SetW

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

func (*Quaternion) SetX

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

func (*Quaternion) SetY

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

func (*Quaternion) SetZ

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

func (*Quaternion) Slerp

func (this *Quaternion) Slerp(qb *Quaternion, t float32) *Quaternion

func (*Quaternion) ToArray

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

func (*Quaternion) W

func (this *Quaternion) W() float32

func (*Quaternion) X

func (this *Quaternion) X() float32

func (*Quaternion) Y

func (this *Quaternion) Y() float32

func (*Quaternion) Z

func (this *Quaternion) Z() float32

type Ray

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

func NewRay

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

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

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

At sets the target position vector at the specified distance from the ray origin and along its direction.

func (*Ray) Clone

func (ray *Ray) Clone() *Ray

func (*Ray) ClosestPointToPoint

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

func (*Ray) Copy

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

Copy copies the specified ray into this one.

func (*Ray) Direction

func (ray *Ray) Direction() Vector3

Direction returns a copy or the ray current direction

func (*Ray) DistanceSqToPoint

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

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

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

func (*Ray) DistanceToPoint

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

func (*Ray) Equals

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

func (*Ray) IntersectBox

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

func (*Ray) IntersectPlane

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

func (*Ray) IntersectSphere

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

func (*Ray) IntersectTriangle

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

IntersectTriangle checks 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

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

IsIntersectPlane checks if this ray intersects the specified plane

func (*Ray) IsIntersectionBox

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

func (*Ray) IsIntersectionSphere

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

IsIntersectionSphere checks if this ray intersects with the specified sphere

func (*Ray) Origin

func (ray *Ray) Origin() Vector3

Origin returns a copy or the ray current origin

func (*Ray) Recast

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

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

func (*Ray) Set

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

Set sets the origin and direction vectors to the Ray.

type Sphere

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

func NewSphere

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

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

ApplyMatrix4 applies the specified matrix transform to this sphere

func (*Sphere) ClampPoint

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

func (*Sphere) ContainsPoint

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

ContainsPoint checks if this sphere contains the specified point

func (*Sphere) Copy

func (this *Sphere) Copy(sphere *Sphere) *Sphere

func (*Sphere) DistanceToPoint

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

func (*Sphere) Empty

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

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

func (*Sphere) GetBoundingBox

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

func (*Sphere) IntersectSphere

func (this *Sphere) IntersectSphere(sphere *Sphere) bool

func (*Sphere) Set

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

Set sets the center and radius of the sphere

func (*Sphere) SetFromPoints

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

func (*Sphere) Translate

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

type Spline

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

func NewSpline

func NewSpline(points []Vector3) *Spline

func (*Spline) InitFromArray

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

type Triangle

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

func NewTriangle

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

func (*Triangle) Area

func (this *Triangle) Area() float32

func (*Triangle) BarycoordFromPoint

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

func (*Triangle) Clone

func (this *Triangle) Clone(triangle *Triangle) *Triangle

func (*Triangle) ContainsPoint

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

func (*Triangle) Copy

func (this *Triangle) Copy(triangle *Triangle) *Triangle

func (*Triangle) Equals

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

func (*Triangle) Midpoint

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

func (*Triangle) Normal

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

func (*Triangle) Plane

func (this *Triangle) Plane(optionalTarget *Plane) *Plane

func (*Triangle) Set

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

func (*Triangle) SetFromPointsAndIndices

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

type Vector2

type Vector2 struct {
	X float32
	Y float32
}

func NewVector2

func NewVector2(x, y float32) *Vector2

func (*Vector2) Add

func (this *Vector2) Add(v *Vector2) *Vector2

func (*Vector2) AddScalar

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

func (*Vector2) AddVectors

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

func (*Vector2) Ceil

func (this *Vector2) Ceil() *Vector2

func (*Vector2) Clamp

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

func (*Vector2) ClampScalar

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

func (*Vector2) Close

func (this *Vector2) Close() *Vector2

func (*Vector2) Copy

func (this *Vector2) Copy(v *Vector2) *Vector2

func (*Vector2) DistanceTo

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

func (*Vector2) DistanceToSquared

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

func (*Vector2) Divide

func (this *Vector2) Divide(v *Vector2) *Vector2

func (*Vector2) DivideScalar

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

func (*Vector2) Dot

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

func (*Vector2) Equals

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

func (*Vector2) Floor

func (this *Vector2) Floor() *Vector2

func (*Vector2) FromArray

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

func (*Vector2) GetComponent

func (this *Vector2) GetComponent(index int) float32

func (*Vector2) Length

func (this *Vector2) Length() float32

func (*Vector2) LengthSq

func (this *Vector2) LengthSq() float32

func (*Vector2) Lerp

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

func (*Vector2) LerpVectors

func (this *Vector2) LerpVectors(v1, v2 *Vector2, alpha float32) *Vector2

func (*Vector2) Max

func (this *Vector2) Max(v *Vector2) *Vector2

func (*Vector2) Min

func (this *Vector2) Min(v *Vector2) *Vector2

func (*Vector2) Multiply

func (this *Vector2) Multiply(v *Vector2) *Vector2

func (*Vector2) MultiplyScalar

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

func (*Vector2) Negate

func (this *Vector2) Negate() *Vector2

func (*Vector2) Normalize

func (this *Vector2) Normalize() *Vector2

func (*Vector2) Round

func (this *Vector2) Round() *Vector2

func (*Vector2) RoundToZero

func (this *Vector2) RoundToZero() *Vector2

func (*Vector2) Set

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

func (*Vector2) SetComponent

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

func (*Vector2) SetLength

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

func (*Vector2) SetX

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

func (*Vector2) SetY

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

func (*Vector2) Sub

func (this *Vector2) Sub(v *Vector2) *Vector2

func (*Vector2) SubScalar

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

func (*Vector2) SubVectors

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

func (*Vector2) ToArray

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

type Vector3

type Vector3 struct {
	X float32
	Y float32
	Z float32
}

func BarycoordFromPoint

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

func NewVector3

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

NewVector creates and returns a pointer to a Vector3 type

func Normal

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

func (*Vector3) Add

func (v *Vector3) Add(src *Vector3) *Vector3

Add adds the specified vector to this.

func (*Vector3) AddScalar

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

AddScalar adds the specified value to each of the vector components

func (*Vector3) AddVectors

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

AddVectors adds the specified vectors and saves the result in this vector: v = a * b

func (*Vector3) AngleTo

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

func (*Vector3) ApplyAxisAngle

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

ApplyAxisAngle rotates the vertex around the specified axis by the specified angle

func (*Vector3) ApplyMatrix3

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

ApplyMatrix3 multiplies the specified 3x3 matrix by this vector: v = m * v

func (*Vector3) ApplyMatrix4

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

ApplyMatrix4 multiplies the specified 4x4 matrix by this vector: v = m * v

func (*Vector3) ApplyProjection

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

func (*Vector3) ApplyQuaternion

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. v = q * v * inverse(q)

func (*Vector3) Ceil

func (this *Vector3) Ceil() *Vector3

func (*Vector3) Clamp

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

func (*Vector3) ClampScalar

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

func (*Vector3) Clone

func (this *Vector3) Clone() *Vector3

func (*Vector3) Copy

func (v *Vector3) Copy(src *Vector3) *Vector3

Copy copies the specified vector into this one.

func (*Vector3) Cross

func (this *Vector3) Cross(v *Vector3) *Vector3

func (*Vector3) CrossVectors

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

func (*Vector3) DistanceTo

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

func (*Vector3) DistanceToSquared

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

func (*Vector3) Divide

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

func (*Vector3) DivideScalar

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

func (*Vector3) Dot

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

func (*Vector3) Equals

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

func (*Vector3) Floor

func (this *Vector3) Floor() *Vector3

func (*Vector3) FromArray

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

func (*Vector3) Length

func (this *Vector3) Length() float32

func (*Vector3) LengthManhattan

func (this *Vector3) LengthManhattan(v *Vector3) float32

func (*Vector3) LengthSq

func (this *Vector3) LengthSq() float32

func (*Vector3) Lerp

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

func (*Vector3) LerpVectors

func (this *Vector3) LerpVectors(v1, v2 *Vector3, alpha float32) *Vector3

func (*Vector3) Max

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

Max sets this vector with maximum components from itself and the other vector

func (*Vector3) Min

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

func (*Vector3) Multiply

func (v *Vector3) Multiply(a *Vector3) *Vector3

Multiply multiplies this vector by the specified vector: v = v * a

func (*Vector3) MultiplyScalar

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

MultiplyScalar multiples this vector by the specified scalar: v = v * s

func (*Vector3) MultiplyVectors

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

MultiplyVectors multiply the specified vectors storing the result in this vector: v = a * b

func (*Vector3) Negate

func (this *Vector3) Negate() *Vector3

func (*Vector3) Normalize

func (this *Vector3) Normalize() *Vector3

func (*Vector3) ProjectOnPlane

func (this *Vector3) ProjectOnPlane(planeNormal *Vector3) *Vector3

func (*Vector3) ProjectOnVector

func (this *Vector3) ProjectOnVector(vector *Vector3) *Vector3

func (*Vector3) Reflect

func (this *Vector3) Reflect(normal *Vector3) *Vector3

func (*Vector3) Round

func (this *Vector3) Round() *Vector3

func (*Vector3) RoundToZero

func (this *Vector3) RoundToZero() *Vector3

func (*Vector3) Set

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

Set sets the components of the vector

func (*Vector3) SetByName

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

SetByName sets the value of this vector component specified by its name: "x|Z", "y|Y", or "z|Z".

func (*Vector3) SetComponent

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

SetComponent sets the value of this vector component specified by its index: X=0, Y=1, Z=2

func (*Vector3) SetFromMatrixColumn

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

SetFromMatrixColumn set this vector with the column at index 'index' of the 'm' matrix.

func (*Vector3) SetFromMatrixPosition

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

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

func (*Vector3) SetFromMatrixScale

func (this *Vector3) SetFromMatrixScale(m *Matrix4) *Vector3

func (*Vector3) SetFromQuaternion

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

SetFromQuaternion sets this vector components to the Euler angles from the specified quaternion

func (*Vector3) SetFromRotationMatrix

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

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

func (*Vector3) SetLength

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

func (*Vector3) SetX

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

SetX sets the value of the X component of this vector

func (*Vector3) SetY

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

SetY sets the value of the Y component of this vector

func (*Vector3) SetZ

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

SetZ sets the value of the Z component of this vector

func (*Vector3) Sub

func (v *Vector3) Sub(p *Vector3) *Vector3

Sub subtracts the specified vector from this one: v = v - p

func (*Vector3) SubScalar

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

SubScalar subtracts the specified scalar from this vector: v = v - s

func (*Vector3) SubVectors

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

SubVectors subtracts the specified vectors and stores the result in this vector: v = a - b

func (*Vector3) ToArray

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

func (*Vector3) TransformDirection

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

type Vector4

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

func NewVector4

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

func (*Vector4) Add

func (this *Vector4) Add(v *Vector4) *Vector4

func (*Vector4) AddScalar

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

func (*Vector4) AddVectors

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

func (*Vector4) ApplyMatrix4

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

func (*Vector4) Ceil

func (this *Vector4) Ceil() *Vector4

func (*Vector4) Clamp

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

func (*Vector4) ClampScalar

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

func (*Vector4) Clone

func (this *Vector4) Clone() *Vector4

func (*Vector4) Copy

func (this *Vector4) Copy(v *Vector4) *Vector4

func (*Vector4) DivideScalar

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

func (*Vector4) Dot

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

func (*Vector4) Equals

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

func (*Vector4) Floor

func (this *Vector4) Floor() *Vector4

func (*Vector4) FromArray

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

func (*Vector4) GetComponent

func (this *Vector4) GetComponent(index int) float32

func (*Vector4) Length

func (this *Vector4) Length() float32

func (*Vector4) LengthManhattan

func (this *Vector4) LengthManhattan(v *Vector4) float32

func (*Vector4) LengthSq

func (this *Vector4) LengthSq(v *Vector4) float32

func (*Vector4) Lerp

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

func (*Vector4) LerpVectors

func (this *Vector4) LerpVectors(v1, v2 *Vector4, alpha float32) *Vector4

func (*Vector4) Max

func (this *Vector4) Max(v *Vector4) *Vector4

func (*Vector4) Min

func (this *Vector4) Min(v *Vector4) *Vector4

func (*Vector4) MultiplyScalar

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

func (*Vector4) Negate

func (this *Vector4) Negate() *Vector4

func (*Vector4) Normalize

func (this *Vector4) Normalize() *Vector4

func (*Vector4) Round

func (this *Vector4) Round() *Vector4

func (*Vector4) RoundToZero

func (this *Vector4) RoundToZero() *Vector4

func (*Vector4) Set

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

func (*Vector4) SetAxisAngleFromQuaternion

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

func (*Vector4) SetAxisFromRotationMatrix

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

func (*Vector4) SetComponent

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

func (*Vector4) SetLength

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

func (*Vector4) SetVector3

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

SetVector3 sets this vector from another Vector3 and 'w' value

func (*Vector4) Sub

func (this *Vector4) Sub(v *Vector4) *Vector4

func (*Vector4) SubScalar

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

func (*Vector4) SubVectors

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

func (*Vector4) ToArray

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

Jump to

Keyboard shortcuts

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