Documentation
¶
Index ¶
- Constants
- func Abs[T ComponentWise[T]](val T) T
- func Absf[T ~float32 | ~float64](x T) T
- func Absi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x T) T
- func AngleDifference[T ~float32 | ~float64](from, to T) T
- func BezierDerivative[T ~float32 | ~float64](start, control_1, control_2, end, t T) T
- func BezierInterpolate[T ~float32 | ~float64](start, control_1, control_2, end, t T) T
- func Ceil[T ComponentWise[T]](val T) T
- func Ceilf[T ~float32 | ~float64](x T) T
- func Ceili[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x T) T
- func Clamp[T ordered](value, min, max T) T
- func Clampf[T ~float32 | ~float64](value, min, max T) T
- func Clampi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](value, min, max T) T
- func Cos[T ~float32 | ~float64](x T) T
- func Cosh[T ~float32 | ~float64](x T) T
- func CubicInterpolate[T ~float32 | ~float64](from, to, pre, post, weight T) T
- func CubicInterpolateAngle[T ~float32 | ~float64](from, to, pre, post, weight T) T
- func CubicInterpolateAngleInTime[T ~float32 | ~float64](from, to, pre, post, weight, to_t, pre_t, post_t T) T
- func CubicInterpolateInTime[T ~float32 | ~float64](from, to, pre, post, weight, to_t, pre_t, post_t T) T
- func DecibelsToLinear[T ~float32 | ~float64](db T) T
- func Ease[T ~float32 | ~float64](x, curve T) T
- func Exp[T ~float32 | ~float64](x T) T
- func Floor[T ComponentWise[T]](val T) T
- func Floorf[T ~float32 | ~float64](x T) T
- func Floori[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x T) T
- func Fmod[T ~float32 | ~float64](x, y T) T
- func Fposmod[T ~float32 | ~float64](x, y T) T
- func InverseLerp[T ~float32 | ~float64](from, to, weight T) T
- func IsApproximatelyEqual[T ~float32 | ~float64](a, b T) bool
- func IsApproximatelyZero[T ~float32 | ~float64](x T) bool
- func IsFinite[T ~float32 | ~float64](x T) bool
- func IsInfinity[T ~float32 | ~float64](x T) bool
- func IsNaN[T ~float32 | ~float64](x T) bool
- func Lerp[T Lerpable[T]](a, b T, t float64) T
- func LerpAngle[T ~float32 | ~float64](from, to, weight T) T
- func Lerpf[T ~float32 | ~float64](from, to, weight T) T
- func LinearToDecibels[T ~float32 | ~float64](energy T) T
- func Log[T ~float32 | ~float64](x T) T
- func MoveToward[T ~float32 | ~float64](from, to, delta T) T
- func NearestPowerOfTwo(x int64) int64
- func PingPong[T ~float32 | ~float64](value, length T) T
- func Posmod[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x, y T) T
- func Pow[T ~float32 | ~float64](base, exp T) T
- func Remap[T ~float32 | ~float64](value, istart, istop, ostart, ostop T) T
- func RotateToward[T ~float32 | ~float64](from, to, delta T) T
- func Round[T ComponentWise[T]](val T) T
- func Roundf[T ~float32 | ~float64](x T) T
- func Roundi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x T) T
- func Sign[T ComponentWise[T]](val T) T
- func Signf[T ~float32 | ~float64](x T) T
- func Signi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x T) T
- func Sin[T ~float32 | ~float64](x T) T
- func Sinh[T ~float32 | ~float64](x T) T
- func Smoothstep[T ~float32 | ~float64](from, to, x T) T
- func Snapped[T ComponentWise[T]](val T, by T) T
- func Snappedf[T ~float32 | ~float64](x, step T) T
- func Snappedi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x, step T) T
- func Sqrt[T ~float32 | ~float64](x T) T
- func StepDecimals[T ~float32 | ~float64](x T) int64
- func Tan[T ~float32 | ~float64](x T) T
- func Tanh[T ~float32 | ~float64](x T) T
- func Wrapf[T ~float32 | ~float64](value, min, max T) T
- func Wrapi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](value, min, max T) T
- type AABB
- func (a AABB) Abs() AABB
- func (a AABB) Center() Vector3
- func (a AABB) Encloses(b AABB) bool
- func (a AABB) End() Vector3
- func (a AABB) Endpoint(idx int) Vector3
- func (a AABB) Expand(to Vector3) AABB
- func (a AABB) Grow(by float64) AABB
- func (a AABB) HasPoint(point Vector3) bool
- func (a AABB) HasSurface() bool
- func (a AABB) HasVolume() bool
- func (a AABB) Intersection(b AABB) AABB
- func (a AABB) Intersects(b AABB) bool
- func (a AABB) IntersectsPlane(plane Plane) bool
- func (a AABB) IntersectsRay(from, dir Vector3) (clip Vector3, normal Vector3, ok bool)
- func (a AABB) IntesectsSegment(from, to Vector3) (clip Vector3, normal Vector3, ok bool)
- func (a AABB) IsAproxximatelyEqual(other AABB) bool
- func (a AABB) IsFinite() bool
- func (a AABB) LongestAxis() Vector3
- func (a AABB) LongestAxisIndex() Axis
- func (a AABB) LongestAxisSize() float64
- func (a AABB) Merge(b AABB) AABB
- func (a AABB) Projection() Projection
- func (a *AABB) SetEnd(end Vector3)
- func (a AABB) ShortestAxis() Vector3
- func (a AABB) ShortestAxisIndex() Axis
- func (a AABB) ShortestAxisSize() float64
- func (a AABB) Support(dir Vector3) Vector3
- func (a AABB) Transform(t Transform3D) AABB
- func (a AABB) Volume() float64
- type Axis
- type Basis
- func (b Basis) Determinant() float64
- func (b Basis) EulerAngles(order EulerOrder) EulerAngles
- func (Basis) FLIP_X() Basis
- func (Basis) FLIP_Y() Basis
- func (Basis) FLIP_Z() Basis
- func (Basis) IDENTITY() Basis
- func (b Basis) Inverse() Basis
- func (b Basis) IsApproximatelyEqual(other Basis) bool
- func (b Basis) IsConformal() bool
- func (b Basis) IsFinite() bool
- func (b Basis) Mul(other Basis) Basis
- func (b Basis) Orthonormalized() Basis
- func (b Basis) Quaternion() Quaternion
- func (b Basis) Rotated(axis Vector3, angle Radians) Basis
- func (b Basis) Scale() Vector3
- func (b Basis) Scaled(scale Vector3) Basis
- func (b *Basis) SetX(x Vector3)
- func (b *Basis) SetY(y Vector3)
- func (b *Basis) SetZ(z Vector3)
- func (b Basis) Slerp(to Basis, weight float64) Basis
- func (m Basis) Transform(v Vector3) Vector3
- func (m Basis) Transposed() Basis
- func (b Basis) TransposedDotX(v Vector3) float64
- func (b Basis) TransposedDotY(v Vector3) float64
- func (b Basis) TransposedDotZ(v Vector3) float64
- func (b Basis) X() Vector3
- func (b Basis) Y() Vector3
- func (b Basis) Z() Vector3
- type ComponentWise
- type Degrees
- type EulerAngles
- type EulerOrder
- type Float
- type Lerpable
- type Plane
- func (p Plane) Center() Vector3
- func (p Plane) DistanceTo(point Vector3) float64
- func (p Plane) HasPoint(point Vector3, tolerance float64) bool
- func (p Plane) Intersect3(b, c Plane) (Vector3, bool)
- func (p Plane) IntersectsRay(from, dir Vector3) (Vector3, bool)
- func (p Plane) IntersectsSegment(from, to Vector3) (Vector3, bool)
- func (p Plane) IsApproximatelyEqual(other Plane) bool
- func (p Plane) IsFinite() bool
- func (p Plane) IsPointOver(point Vector3) bool
- func (p Plane) Normalized() Plane
- func (p Plane) Project(point Vector3) Vector3
- func (p *Plane) SetX(x float64)
- func (p *Plane) SetY(y float64)
- func (p *Plane) SetZ(z float64)
- func (p Plane) Transform(t Transform3D) Plane
- func (p Plane) X() float64
- func (Plane) XY() Plane
- func (Plane) XZ() Plane
- func (p Plane) Y() float64
- func (Plane) YZ() Plane
- func (p Plane) Z() float64
- type Projection
- func NewProjectionForHeadMountedDisplay(eye int, ...) Projection
- func NewProjectionThatIsOrthogonal(left, right, bottom, top, z_near, z_far float64) Projection
- func NewProjectionThatIsOrthogonalWithAspectRatio(size, aspect, z_near, z_far float64, flip_fov bool) Projection
- func NewProjectionWithDepthCorrection(fliy bool) Projection
- func NewProjectionWithFrustum(left, right, bottom, top, z_near, z_far float64) Projection
- func NewProjectionWithFrustumAspectRatio(size, aspect float64, offset Vector2, z_near, z_far float64, flip_fov bool) Projection
- func NewProjectionWithPerspective(fovy Degrees, aspect, z_near, z_far float64, flip_fov bool) Projection
- func NewProjectionWithPerspectiveForHeadMountedDisplay(fovy Degrees, aspect, z_near, z_far float64, flip_fov bool, eye int, ...) Projection
- func (p Projection) AspectRatio() float64
- func (p Projection) Determinant() float64
- func (p Projection) FarPlaneHalfExtents() Vector2
- func (p Projection) FarZ() float64
- func (p Projection) FieldOfView() Degrees
- func (p Projection) FlippedY() Projection
- func (Projection) IDENTITY() Projection
- func (p Projection) Inverse() Projection
- func (p Projection) IsOrthogonal() bool
- func (p Projection) JitterOffseted(jitter Vector2) Projection
- func (p Projection) LevelOfDetailMultiplier() float64
- func (p Projection) Mul(other Projection) Projection
- func (p Projection) NearZ() float64
- func (p Projection) PerspectiveAdjustedNearZ(new_near_z float64) Projection
- func (p Projection) PixelsPerMeter(pixel_width int64) int64
- func (p Projection) ProjectionPlane(plane ProjectionPlane) (new_plane Plane)
- func (p Projection) Transform3D() Transform3D
- func (p Projection) ViewportHalfExtents() Vector2
- func (p Projection) W() Vector4
- func (p Projection) X() Vector4
- func (p Projection) Y() Vector4
- func (p Projection) Z() Vector4
- type ProjectionPlane
- type Quaternion
- func (q Quaternion) Add(other Quaternion) Quaternion
- func (q Quaternion) Addf(other float64) Quaternion
- func (q Quaternion) Angle() Radians
- func (q Quaternion) AngleTo(other Quaternion) Radians
- func (q Quaternion) Axis() Vector3
- func (q Quaternion) Basis() Basis
- func (q Quaternion) Div(other Quaternion) Quaternion
- func (q Quaternion) Divf(other float64) Quaternion
- func (q Quaternion) Dot(other Quaternion) float64
- func (q Quaternion) EulerAngles(order EulerOrder) EulerAngles
- func (q Quaternion) Exp() Quaternion
- func (Quaternion) IDENTITY() Quaternion
- func (q Quaternion) Inverse() Quaternion
- func (q Quaternion) IsApproximatelyEqual(other Quaternion) bool
- func (q Quaternion) IsFinite() bool
- func (q Quaternion) IsNormalized() bool
- func (q Quaternion) Length() float64
- func (q Quaternion) LengthSquared() float64
- func (q Quaternion) Log() Quaternion
- func (q Quaternion) Mul(other Quaternion) Quaternion
- func (q Quaternion) Mulf(other float64) Quaternion
- func (q Quaternion) Neg() Quaternion
- func (q Quaternion) Normalized() Quaternion
- func (q Quaternion) SetW(v float64)
- func (q Quaternion) SetX(v float64)
- func (q Quaternion) SetY(v float64)
- func (q Quaternion) SetZ(v float64)
- func (q Quaternion) Slerp(to Quaternion, weight float64) Quaternion
- func (q Quaternion) Slerpni(to Quaternion, weight float64) Quaternion
- func (q Quaternion) SphericalCubicInterpolate(b, pre_a, post_b Quaternion, weight float64) Quaternion
- func (q Quaternion) SphericalCubicInterpolateInTime(b, pre_a, post_b Quaternion, weight, b_t, pre_a_t, post_b_t float64) Quaternion
- func (q Quaternion) Sub(other Quaternion) Quaternion
- func (q Quaternion) Subf(other float64) Quaternion
- func (q Quaternion) W() float64
- func (q Quaternion) X() float64
- func (q Quaternion) Y() float64
- func (q Quaternion) Z() float64
- type Radians
- func Acos[T ~float32 | ~float64](x T) Radians
- func Acosh[T ~float32 | ~float64](x T) Radians
- func Asin[T ~float32 | ~float64](x T) Radians
- func Asinh[T ~float32 | ~float64](x T) Radians
- func Atan[T ~float32 | ~float64](x T) Radians
- func Atan2[T ~float32 | ~float64](y, x T) Radians
- func Atanh[T ~float32 | ~float64](x T) Radians
- type Rect2
- func (r Rect2) Abs() Rect2
- func (r Rect2) Area() float64
- func (r Rect2) Center() Vector2
- func (r Rect2) Encloses(b Rect2) bool
- func (r Rect2) End() Vector2
- func (r Rect2) Expand(to Vector2) Rect2
- func (r Rect2) Grow(amount float64) Rect2
- func (r Rect2) GrowIndividual(left, top, right, bottom float64) Rect2
- func (r Rect2) GrowSide(side Side, amount float64) Rect2
- func (r Rect2) HasArea() bool
- func (r Rect2) HasPoint(point Vector2) bool
- func (r Rect2) Intersection(b Rect2) Rect2
- func (r Rect2) Intersects(b Rect2, include_borders bool) bool
- func (r Rect2) IsApproximatelyEqual(b Rect2) bool
- func (r Rect2) IsFinite() bool
- func (r Rect2) Merge(b Rect2) Rect2
- func (r Rect2) Projection() Projection
- func (r Rect2) Rect2i() Rect2i
- func (r *Rect2) SetEnd(end Vector2)
- func (r Rect2) Transform(t Transform2D) Rect2
- type Rect2i
- func (r Rect2i) Abs() Rect2i
- func (r Rect2i) Area() int64
- func (r Rect2i) Center() Vector2i
- func (r Rect2i) Encloses(b Rect2i) bool
- func (r Rect2i) End() Vector2i
- func (r Rect2i) Expand(to Vector2i) Rect2i
- func (r Rect2i) Grow(amount int64) Rect2i
- func (r Rect2i) GrowIndividual(left, top, right, bottom int64) Rect2i
- func (r Rect2i) GrowSide(side Side, amount int64) Rect2i
- func (r Rect2i) HasArea() bool
- func (r Rect2i) HasPoint(point Vector2i) bool
- func (r Rect2i) Intersection(b Rect2i) Rect2i
- func (r Rect2i) Intersects(b Rect2i, include_borders bool) bool
- func (r Rect2i) Merge(b Rect2i) Rect2i
- func (r Rect2i) Rect2() Rect2
- func (r *Rect2i) SetEnd(end Vector2i)
- type Side
- type Transform2D
- func (t Transform2D) AffineInverse() Transform2D
- func (t Transform2D) BasisTransform(v Vector2) Vector2
- func (t Transform2D) Determinant() float64
- func (t Transform2D) FLIP_X() Transform2D
- func (t Transform2D) FLIP_Y() Transform2D
- func (t Transform2D) IDENTITY() Transform2D
- func (t Transform2D) InterpolateWith(b Transform2D, weight float64) Transform2D
- func (t Transform2D) Inverse() Transform2D
- func (t Transform2D) InverseBasisTransform(v Vector2) Vector2
- func (t Transform2D) IsApproximatelyEqual(xform Transform2D) bool
- func (t Transform2D) IsConformal() bool
- func (t Transform2D) IsFinite() bool
- func (t Transform2D) LookingAt(target Vector2) Transform2D
- func (t Transform2D) Mul(other Transform2D) Transform2D
- func (t Transform2D) Origin() Vector2
- func (t Transform2D) Orthonormalized() Transform2D
- func (t Transform2D) Rotated(angle Radians) Transform2D
- func (t Transform2D) RotatedLocal(angle Radians) Transform2D
- func (t Transform2D) Rotation() Radians
- func (t Transform2D) Scale() Vector2
- func (t Transform2D) Scaled(scale Vector2) Transform2D
- func (t Transform2D) ScaledLocal(scale Vector2) Transform2D
- func (t *Transform2D) SetOrigin(o Vector2)
- func (t *Transform2D) SetX(x Vector2)
- func (t *Transform2D) SetY(y Vector2)
- func (t Transform2D) Skew() Radians
- func (t Transform2D) Translated(offset Vector2) Transform2D
- func (t Transform2D) TranslatedLocal(offset Vector2) Transform2D
- func (t Transform2D) X() Vector2
- func (t Transform2D) Y() Vector2
- type Transform3D
- func (t Transform3D) AffineInverse() Transform3D
- func (Transform3D) FLIP_X() Transform3D
- func (Transform3D) FLIP_Y() Transform3D
- func (Transform3D) FLIP_Z() Transform3D
- func (Transform3D) IDENTITY() Transform3D
- func (t Transform3D) InterpolateWith(other Transform3D, weight float64) Transform3D
- func (t Transform3D) Inverse() Transform3D
- func (t Transform3D) IsApproximatelyEqual(other Transform3D) bool
- func (t Transform3D) IsFinite() bool
- func (t Transform3D) LookingAt(target, up Vector3, use_model_front bool) Transform3D
- func (t Transform3D) Mul(other Transform3D) Transform3D
- func (t Transform3D) Orthonormalized() Transform3D
- func (t Transform3D) Projection() Projection
- func (t Transform3D) Rotated(axis Vector3, phi Radians) Transform3D
- func (t Transform3D) RotatedLocal(axis Vector3, phi Radians) Transform3D
- func (t Transform3D) Scaled(scale Vector3) Transform3D
- func (t Transform3D) ScaledLocal(scale Vector3) Transform3D
- func (t Transform3D) Translated(offset Vector3) Transform3D
- func (t Transform3D) TranslatedLocal(offset Vector3) Transform3D
- type Vector2
- func (v Vector2) Abs() Vector2
- func (v Vector2) Add(other Vector2) Vector2
- func (v Vector2) Addf(other float64) Vector2
- func (v Vector2) Angle() Radians
- func (v Vector2) AngleTo(to Vector2) Radians
- func (v Vector2) AngleToPoint(to Vector2) Radians
- func (v Vector2) Aspect() float64
- func (v Vector2) BezierDerivative(control1, control2, end Vector2, t float64) Vector2
- func (v Vector2) BezierInterpolate(control1, control2, end Vector2, t float64) Vector2
- func (v Vector2) Bounce(n Vector2) Vector2
- func (v Vector2) Ceil() Vector2
- func (v Vector2) Clamp(from, to Vector2) Vector2
- func (v Vector2) Cross(other Vector2) float64
- func (v Vector2) CubicInterpolate(b, preA, postB Vector2, weight float64) Vector2
- func (v Vector2) CubicInterpolateInTime(b, preA, postB Vector2, weight, b_t, pre_a_t, post_b_t float64) Vector2
- func (v Vector2) DOWN() Vector2
- func (v Vector2) DirectionTo(to Vector2) Vector2
- func (v Vector2) DistanceSquaredTo(to Vector2) float64
- func (v Vector2) DistanceTo(to Vector2) float64
- func (v Vector2) Div(other Vector2) Vector2
- func (v Vector2) Divf(other float64) Vector2
- func (v Vector2) Dot(other Vector2) float64
- func (v Vector2) Floor() Vector2
- func (v Vector2) INF() Vector2
- func (v Vector2) IsApproximatelyEqual(to Vector2) bool
- func (v Vector2) IsApproximatelyZero() bool
- func (v Vector2) IsFinite() bool
- func (v Vector2) IsNormalized() bool
- func (v Vector2) LEFT() Vector2
- func (v Vector2) Length() float64
- func (v Vector2) LengthSquared() float64
- func (v Vector2) Lerp(to Vector2, weight float64) Vector2
- func (v Vector2) LimitLength(length float64) Vector2
- func (v Vector2) MaxAxis() Axis
- func (v Vector2) MinAxis() Axis
- func (v Vector2) MoveToward(to Vector2, delta float64) Vector2
- func (v Vector2) Mul(other Vector2) Vector2
- func (v Vector2) Mulf(other float64) Vector2
- func (v Vector2) Neg() Vector2
- func (v Vector2) Normalized() Vector2
- func (v Vector2) ONE() Vector2
- func (v Vector2) Orthogonal() Vector2
- func (v Vector2) Posmod(mod float64) Vector2
- func (v Vector2) PosmodVector(mod Vector2) Vector2
- func (v Vector2) Project(b Vector2) Vector2
- func (v Vector2) RIGHT() Vector2
- func (v Vector2) Reflect(n Vector2) Vector2
- func (v Vector2) Rotated(by Radians) Vector2
- func (v Vector2) Round() Vector2
- func (v *Vector2) SetX(x float64)
- func (v *Vector2) SetY(y float64)
- func (v Vector2) Sign() Vector2
- func (v Vector2) Slerp(to Vector2, weight Radians) Vector2
- func (v Vector2) Slide(n Vector2) Vector2
- func (v Vector2) Snapped(step Vector2) Vector2
- func (v Vector2) Sub(other Vector2) Vector2
- func (v Vector2) Subf(other float64) Vector2
- func (v Vector2) Transform(t Transform2D) Vector2
- func (v Vector2) UP() Vector2
- func (v Vector2) Vector2i() Vector2i
- func (v Vector2) X() float64
- func (v Vector2) Y() float64
- func (v Vector2) ZERO() Vector2
- type Vector2i
- func (v Vector2i) Abs() Vector2i
- func (v Vector2i) Add(other Vector2i) Vector2i
- func (v Vector2i) Addi(other int64) Vector2i
- func (v Vector2i) Aspect() float64
- func (v Vector2i) Clamp(min, max Vector2i) Vector2i
- func (v Vector2i) DOWN() Vector2i
- func (v Vector2i) Div(other Vector2i) Vector2i
- func (v Vector2i) Divi(other int64) Vector2i
- func (v Vector2i) LEFT() Vector2i
- func (v Vector2i) Length() float64
- func (v Vector2i) LengthSquared() int64
- func (v Vector2i) MAX() Vector2i
- func (v Vector2i) MIN() Vector2i
- func (v Vector2i) MaxAxis() Axis
- func (v Vector2i) MinAxis() Axis
- func (v Vector2i) Mod(other Vector2i) Vector2i
- func (v Vector2i) Modi(other int64) Vector2i
- func (v Vector2i) Mul(other Vector2i) Vector2i
- func (v Vector2i) Muli(other int64) Vector2i
- func (v Vector2i) Neg() Vector2i
- func (v Vector2i) ONE() Vector2i
- func (v Vector2i) RIGHT() Vector2i
- func (v Vector2i) SetX(x int64)
- func (v Vector2i) SetY(y int64)
- func (v Vector2i) Sign() Vector2i
- func (v Vector2i) Snapped(step Vector2i) Vector2i
- func (v Vector2i) Sub(other Vector2i) Vector2i
- func (v Vector2i) Subi(other int64) Vector2i
- func (v Vector2i) UP() Vector2i
- func (v Vector2i) Vector2() Vector2
- func (v Vector2i) X() int64
- func (v Vector2i) Y() int64
- func (v Vector2i) ZERO() Vector2i
- type Vector3
- func (v Vector3) Abs() Vector3
- func (v Vector3) Add(other Vector3) Vector3
- func (v Vector3) Addf(other float64) Vector3
- func (v Vector3) AngleTo(to Vector3) Radians
- func (Vector3) BACK() Vector3
- func (v Vector3) BezierDerivative(control1, control2, end Vector3, t float64) Vector3
- func (v Vector3) BezierInterpolate(control1, control2, end Vector3, t float64) Vector3
- func (v Vector3) Bounce(n Vector3) Vector3
- func (v Vector3) Ceil() Vector3
- func (v Vector3) Clamp(min, max Vector3) Vector3
- func (v Vector3) Cross(with Vector3) Vector3
- func (v Vector3) CubicInterpolate(b, preA, postB Vector3, weight float64) Vector3
- func (v Vector3) CubicInterpolateInTime(b, preA, postB Vector3, weight, b_t, pre_a_t, post_b_t float64) Vector3
- func (Vector3) DOWN() Vector3
- func (v Vector3) DirectionTo(to Vector3) Vector3
- func (v Vector3) DistanceSquaredTo(to Vector3) float64
- func (v Vector3) DistanceTo(to Vector3) float64
- func (v Vector3) Div(other Vector3) Vector3
- func (v Vector3) Divf(other float64) Vector3
- func (v Vector3) Dot(with Vector3) float64
- func (Vector3) FORWARD() Vector3
- func (v Vector3) Floor() Vector3
- func (Vector3) INF() Vector3
- func (v Vector3) Inverse() Vector3
- func (v Vector3) IsApproximatelyEqual(other Vector3) bool
- func (v Vector3) IsApproximatelyZero() bool
- func (v Vector3) IsFinite() bool
- func (v Vector3) IsNormalized() bool
- func (Vector3) LEFT() Vector3
- func (v Vector3) Length() float64
- func (v Vector3) LengthSquared() float64
- func (v Vector3) Lerp(to Vector3, weight float64) Vector3
- func (v Vector3) LimitLength(length float64) Vector3
- func (Vector3) MODEL_BOTTOM() Vector3
- func (Vector3) MODEL_FRONT() Vector3
- func (Vector3) MODEL_LEFT() Vector3
- func (Vector3) MODEL_REAR() Vector3
- func (Vector3) MODEL_RIGHT() Vector3
- func (Vector3) MODEL_TOP() Vector3
- func (v Vector3) MaxAxis() Axis
- func (v Vector3) MinAxis() Axis
- func (v Vector3) MoveToward(to Vector3, delta float64) Vector3
- func (v Vector3) Mul(other Vector3) Vector3
- func (v Vector3) Mulf(other float64) Vector3
- func (v Vector3) Neg() Vector3
- func (v Vector3) Normalized() Vector3
- func (Vector3) ONE() Vector3
- func (v Vector3) OctahedronDecode(uv Vector2) Vector3
- func (v Vector3) OctahedronEncode() Vector2
- func (v Vector3) Outer(with Vector3) Basis
- func (v Vector3) Posmodf(mod float64) Vector3
- func (v Vector3) Posmodv(mod Vector3) Vector3
- func (v Vector3) Project(b Vector3) Vector3
- func (Vector3) RIGHT() Vector3
- func (v Vector3) Reflect(n Vector3) Vector3
- func (v Vector3) Rotated(axis Vector3, angle Radians) Vector3
- func (v Vector3) Round() Vector3
- func (v *Vector3) SetX(x float64)
- func (v *Vector3) SetY(y float64)
- func (v *Vector3) SetZ(z float64)
- func (v Vector3) SignedAngleTo(to Vector3, axis Vector3) Radians
- func (v Vector3) Slerp(to Vector3, weight float64) Vector3
- func (v Vector3) Slide(n Vector3) Vector3
- func (v Vector3) Snapped(step Vector3) Vector3
- func (v Vector3) Sub(other Vector3) Vector3
- func (v Vector3) Subf(other float64) Vector3
- func (v Vector3) Transform(t Transform3D) Vector3
- func (Vector3) UP() Vector3
- func (v Vector3) Vector3i() Vector3i
- func (v Vector3) X() float64
- func (v Vector3) Y() float64
- func (v Vector3) Z() float64
- func (Vector3) ZERO() Vector3
- type Vector3i
- func (v Vector3i) Abs() Vector3i
- func (v Vector3i) Add(other Vector3i) Vector3i
- func (v Vector3i) Addi(other int64) Vector3i
- func (Vector3i) BACK() Vector3i
- func (v Vector3i) Clamp(min, max Vector3i) Vector3i
- func (Vector3i) DOWN() Vector3i
- func (v Vector3i) Div(other Vector3i) Vector3i
- func (v Vector3i) Divi(other int64) Vector3i
- func (Vector3i) FORWARD() Vector3i
- func (Vector3i) LEFT() Vector3i
- func (v Vector3i) Length() float64
- func (v Vector3i) LengthSquared() int64
- func (Vector3i) MAX() Vector3i
- func (Vector3i) MIN() Vector3i
- func (v Vector3i) MaxAxis() Axis
- func (v Vector3i) MinAxis() Axis
- func (v Vector3i) Mod(other Vector3i) Vector3i
- func (v Vector3i) Modi(other int64) Vector3i
- func (v Vector3i) Mul(other Vector3i) Vector3i
- func (v Vector3i) Muli(other int64) Vector3i
- func (v Vector3i) Neg() Vector3i
- func (Vector3i) ONE() Vector3i
- func (Vector3i) RIGHT() Vector3i
- func (v *Vector3i) SetX(x int64)
- func (v *Vector3i) SetY(y int64)
- func (v *Vector3i) SetZ(z int64)
- func (v Vector3i) Sign() Vector3i
- func (v Vector3i) Snapped(step Vector3i) Vector3i
- func (v Vector3i) Sub(other Vector3i) Vector3i
- func (v Vector3i) Subi(other int64) Vector3i
- func (Vector3i) UP() Vector3i
- func (v Vector3i) Vector3() Vector3
- func (v Vector3i) X() int64
- func (v Vector3i) Y() int64
- func (v Vector3i) Z() int64
- func (Vector3i) ZERO() Vector3i
- type Vector4
- func (v Vector4) Abs() Vector4
- func (v Vector4) Add(other Vector4) Vector4
- func (v Vector4) Addf(other float64) Vector4
- func (v Vector4) Ceil() Vector4
- func (v Vector4) Clamp(min, max Vector4) Vector4
- func (v Vector4) CubicInterpolate(b, pre_a, post_b Vector4, weight float64) Vector4
- func (v Vector4) CubicInterpolateInTime(b, pre_a, post_b Vector4, weight, b_t, pre_a_t, post_b_t float64) Vector4
- func (v Vector4) DirectionTo(to Vector4) Vector4
- func (v Vector4) DistanceSquaredTo(to Vector4) float64
- func (v Vector4) DistanceTo(to Vector4) float64
- func (v Vector4) Div(other Vector4) Vector4
- func (v Vector4) Divf(other float64) Vector4
- func (v Vector4) Dot(b Vector4) float64
- func (v Vector4) Floor() Vector4
- func (Vector4) INF() Vector4
- func (v Vector4) Inverse() Vector4
- func (v Vector4) IsApproximatelyEqual(to Vector4) bool
- func (v Vector4) IsApproximatelyZero() bool
- func (v Vector4) IsFinite() bool
- func (v Vector4) IsNormalized() bool
- func (v Vector4) Length() float64
- func (v Vector4) LengthSquared() float64
- func (v Vector4) Lerp(to Vector4, weight float64) Vector4
- func (v Vector4) MaxAxis() Axis
- func (v Vector4) MinAxis() Axis
- func (v Vector4) Mul(other Vector4) Vector4
- func (v Vector4) Mulf(other float64) Vector4
- func (v Vector4) Neg() Vector4
- func (v Vector4) Normalized() Vector4
- func (Vector4) ONE() Vector4
- func (v Vector4) Posmodf(mod float64) Vector4
- func (v Vector4) Posmodv(mod Vector4) Vector4
- func (v Vector4) Round() Vector4
- func (v *Vector4) SetW(w float64)
- func (v *Vector4) SetX(x float64)
- func (v *Vector4) SetY(y float64)
- func (v *Vector4) SetZ(z float64)
- func (v Vector4) Sign() Vector4
- func (v Vector4) Snapped(step Vector4) Vector4
- func (v Vector4) Sub(other Vector4) Vector4
- func (v Vector4) Subf(other float64) Vector4
- func (v Vector4) Transform(p Projection) Vector4
- func (v Vector4) Vector4i() Vector4i
- func (v Vector4) W() float64
- func (v Vector4) X() float64
- func (v Vector4) Y() float64
- func (v Vector4) Z() float64
- func (Vector4) ZERO() Vector4
- type Vector4i
- func (v Vector4i) Abs() Vector4i
- func (v Vector4i) Add(other Vector4i) Vector4i
- func (v Vector4i) Addi(other int64) Vector4i
- func (v Vector4i) Clamp(min, max Vector4i) Vector4i
- func (v Vector4i) Div(other Vector4i) Vector4i
- func (v Vector4i) Divi(other int64) Vector4i
- func (v Vector4i) Length() float64
- func (v Vector4i) LengthSquared() int64
- func (Vector4i) MAX() Vector4i
- func (Vector4i) MIN() Vector4i
- func (v Vector4i) MaxAxis() Axis
- func (v Vector4i) MinAxis() Axis
- func (v Vector4i) Mod(other Vector4i) Vector4i
- func (v Vector4i) Modi(other int64) Vector4i
- func (v Vector4i) Mul(other Vector4i) Vector4i
- func (v Vector4i) Muli(other int64) Vector4i
- func (v Vector4i) Neg() Vector4i
- func (Vector4i) ONE() Vector4i
- func (v *Vector4i) SetW(w int64)
- func (v *Vector4i) SetX(x int64)
- func (v *Vector4i) SetY(y int64)
- func (v *Vector4i) SetZ(z int64)
- func (v Vector4i) Sign() Vector4i
- func (v Vector4i) Snapped(step Vector4i) Vector4i
- func (v Vector4i) Sub(other Vector4i) Vector4i
- func (v Vector4i) Subi(other int64) Vector4i
- func (v Vector4i) Vector4() Vector4
- func (v Vector4i) W() int64
- func (v Vector4i) X() int64
- func (v Vector4i) Y() int64
- func (v Vector4i) Z() int64
- func (Vector4i) ZERO() Vector4i
Constants ¶
const ( Pi = math.Pi Tau = math.Pi * 2 )
Variables ¶
This section is empty.
Functions ¶
func Abs ¶
func Abs[T ComponentWise[T]](val T) T
func AngleDifference ¶
AngleDifference returns the difference between the two angles, in the range of [-Pi, +Pi]. When from and to are opposite, returns -Pi if from is smaller than to, or Pi otherwise.
func BezierDerivative ¶
BezierDerivative returns the derivative at the given t on a one-dimensional Bézier curve defined by the given control_1, control_2, and end points.
func BezierInterpolate ¶
BezierInterpolate returns the point at the given t on a one-dimensional Bézier curve defined by the given control_1, control_2, and end points.
func Ceil ¶
func Ceil[T ComponentWise[T]](val T) T
func Ceilf ¶
Ceilf rounds x upward (towards positive infinity), returning the smallest whole number that is not less than x.
func Ceili ¶
Ceili rounds x upward (towards positive infinity), returning the smallest whole number that is not less than x.
func Clamp ¶
func Clamp[T ordered](value, min, max T) T
Clamp clamps the value, returning a Variant not less than min and not more than max. Any values that can be compared with the less than and greater than operators will work.
func Clampi ¶
Clampi clamps the value, returning an integer not less than min and not more than max.
func CubicInterpolate ¶
CubicInterpolate cubic interpolates between two values by the factor defined in weightSee also with pre and post values.
func CubicInterpolateAngle ¶
CubicInterpolateAngle cubic interpolates between two rotation values with shortest path by the factor defined in weight with pre and post values. See also LerpAngle.
func CubicInterpolateAngleInTime ¶
func CubicInterpolateAngleInTime[T ~float32 | ~float64](from, to, pre, post, weight, to_t, pre_t, post_t T) T
CubicInterpolateAngleInTime cubic interpolates between two rotation values with shortest path by the factor defined in weight with pre and post values. See also LerpAngle.
It can perform smoother interpolation than CubicInterpolate by the time values.
func CubicInterpolateInTime ¶
func CubicInterpolateInTime[T ~float32 | ~float64](from, to, pre, post, weight, to_t, pre_t, post_t T) T
CubicInterpolateInTime cubic interpolates between two values by the factor defined in weight with pre and post values.
It can perform smoother interpolation than cubic_interpolate by the time values.
func DecibelsToLinear ¶
DecibelsToLinear converts from decibels to linear energy (audio).
func Ease ¶
Ease returns an "eased" value of x based on an easing function defined with curve. This easing function is based on an exponent. The curve can be any floating-point number, with specific values leading to the following behaviors:
- Lower than -1.0 (exclusive): Ease in-out - 1.0: Linear - Between -1.0 and 0.0 (exclusive): Ease out-in - 0.0: Constant - Between 0.0 to 1.0 (exclusive): Ease out - 1.0: Linear - Greater than 1.0 (exclusive): Ease in
https://raw.githubusercontent.com/godotengine/godot-docs/master/img/ease_cheatsheet.png
See also Smoothstep. If you need to perform more advanced transitions, use [Tween.InterpolateValue].
func Exp ¶
Exp raises the mathematical constant e to the power of x and returns it. e has an approximate value of 2.71828, and can be obtained with Exp(1).
For exponents to other bases use the method pow.
func Floor ¶
func Floor[T ComponentWise[T]](val T) T
func Floorf ¶
Floorf rounds x downward (towards negative infinity), returning the largest whole number that is not more than x.
func Floori ¶
Floori rounds x downward (towards negative infinity), returning the largest whole number that is not more than x.
func Fposmod ¶
Fposmod returns the floating-point modulus of x divided by y, wrapping equally in positive and negative.
func InverseLerp ¶
InverseLerp returns an interpolation or extrapolation factor considering the range specified in from and to, and the interpolated value specified in weight. The returned value will be between 0.0 and 1.0 if weight is between from and to (inclusive). If weight is located outside this range, then an extrapolation factor will be returned (return value lower than 0.0 or greater than 1.0). Use Clamp on the result of InverseLerp if this is not desired.
func IsApproximatelyEqual ¶
IsApproximatelyEqual returns true if a and b are approximately equal to each other.
Here, "approximately equal" means that a and b are within a small internal epsilon of each other, which scales with the magnitude of the numbers.
Infinity values of the same sign are considered equal.
func IsApproximatelyZero ¶
IsApproximatelyZero Returns true if x is zero or almost zero. The comparison is done using a tolerance calculation with a small internal epsilon. This function is faster than using IsApproximatelyEqual with one value as zero.
func IsInfinity ¶
IsInfinity returns whether x is an infinite value, i.e. it is +INF or -INF.
func Lerp ¶
Lerp linearly interpolates between two values by the factor defined in weight. To perform interpolation, weight should be between 0.0 and 1.0 (inclusive). However, values outside this range are allowed and can be used to perform extrapolation. If this is not desired, use Clamp on the result of this function.
Both from and to must be the same type. Supported types: Vector2, Vector3, Vector4, Quaternion, Basis.
See also InverseLerp which performs the reverse of this operation. To perform eased interpolation with lerp, combine it with Ease or Smoothstep. See also Remap to map a continuous series of values to another.
func LerpAngle ¶
LerpAngle linearly interpolates between two angles (in radians) by a weight value between 0.0 and 1.0. Similar to lerp, but interpolates correctly when the angles wrap around Tau. To perform eased interpolation with LerpAngle, combine it with Ease or Smoothstep.
Note: This function lerps through the shortest path between from and to. However, when these two angles are approximately Pi + k * Tau apart for any integer k, it's not obvious which way they lerp due to floating-point precision errors. For example, LerpAngle(0, Pi, weight) lerps counter-clockwise, while LerpAngle(0, Pi + 5 * Tau, weight) lerps clockwise.
func Lerpf ¶
Lerpf linearly interpolates between two values by the factor defined in weight. To perform interpolation, weight should be between 0.0 and 1.0 (inclusive). However, values outside this range are allowed and can be used to perform extrapolation. If this is not desired, use Clampf on the result of this function.
See also InverseLerp which performs the reverse of this operation. To perform eased interpolation with Lerpf, combine it with ease or smoothstep.
func LinearToDecibels ¶
LinearToDecibels converts from linear energy (audio) to decibels.
func Log ¶
Log returns the natural logarithm of x (base e, with e being approximately 2.71828). This is the amount of time needed to reach a certain level of continuous growth.
Note: This is not the same as the "log" function on most calculators, which uses a base 10 logarithm. To use base 10 logarithm, use Log(x) / Log(10).
Note: The logarithm of 0 returns -inf, while negative values return -NaN.
func MoveToward ¶
MoveToward moves from toward to by the delta amount. Will not go past to. Use a negative delta value to move away.
func NearestPowerOfTwo ¶
NearestPowerOfTwo returns the nearest power of two to the given value.
Warning: Due to its implementation, this method returns 0 rather than 1 for values less than or equal to 0, with an exception for value being the smallest negative 64-bit integer (-9223372036854775808) in which case the value is returned unchanged.
func PingPong ¶
PingPong wraps value between 0 and the length. If the limit is reached, the next value the function returns is decreased to the 0 side or increased to the length side (like a triangle wave). If length is less than zero, it becomes positive.
func Posmod ¶
Posmod returns the integer modulus of x divided by y that wraps equally in positive and negative.
func Remap ¶
Remap maps a value from range (istart, istop) to (ostart, ostop). See also Lerp and InverseLerp. If value is outside (istart, istop), then the resulting value will also be outside (ostart, ostop). If this is not desired, use Clamp on the result of this function.
func RotateToward ¶
RotateToward rotates from toward to by the delta amount. Will not go past to.
Similar to move_toward, but interpolates correctly when the angles wrap around Tau.
If delta is negative, this function will rotate away from to, toward the opposite angle, and will not go past the opposite angle.
func Round ¶
func Round[T ComponentWise[T]](val T) T
func Sign ¶
func Sign[T ComponentWise[T]](val T) T
func Signf ¶
Signf returns -1.0 if x is negative, 1.0 if x is positive, and 0.0 if x is zero. For NaN values of x it returns 0.0.
func Signi ¶
Signi returns -1 if x is negative, 1 if x is positive, and 0 if x is zero. For NaN values of x it returns 0.
func Smoothstep ¶
Smoothstep returns the result of smoothly interpolating the value of x between 0 and 1, based on the where x lies with respect to the edges from and to.
The return value is 0 if x <= from, and 1 if x >= to. If x lies between from and to, the returned value follows an S-shaped curve that maps x between 0 and 1.
This S-shaped curve is the cubic Hermite interpolator, given by
(y) = 3*y^2 - 2*y^3 where y = (x-from) / (to-from).
func Snapped ¶
func Snapped[T ComponentWise[T]](val T, by T) T
func Snappedf ¶
Snappedf returns the multiple of step that is the closest to x. This can also be used to round a floating point number to an arbitrary number of decimals.
func Snappedi ¶
Snappedi returns the multiple of step that is the closest to x. This can also be used to round a floating point number to an arbitrary number of decimals.
func StepDecimals ¶
StepDecimals returns the position of the first non-zero digit, after the decimal point. Note that the maximum return value is 10, which is a design decision in the implementation.
Types ¶
type AABB ¶
AABB consists of a position, a size, and several utility functions. It is typically used for fast overlap tests.
It uses floating-point coordinates. The 2D counterpart to AABB is Rect2.
Negative values for size are not supported and will not work for most methods. Use abs to get an AABB with a positive size.
Note: Unlike Rect2, AABB does not have a variant that uses integer coordinates.
func (AABB) Abs ¶
Abs returns an AABB with equivalent position and size, modified so that the most-negative corner is the origin and the size is positive.
func (AABB) Center ¶
Center returns the center of the AABB, which is equal to position + (size / 2).
func (AABB) Expand ¶
Expand returns a copy of this AABB expanded to include a given point.
// position (-3, 2, 0), size (1, 1, 1) var box = AABB{Vector3{-3,2,0}, Vector3{1,1,1}} // position (-3, -1, 0), size (3, 4, 2), so we fit both the original AABB and Vector3(0, -1, 2) var box2 = box.Expand(Vector3{0, -1, 2})
func (AABB) Grow ¶
Grow returns a copy of the AABB grown a given number of units towards all the sides.
func (AABB) HasPoint ¶
HasPoint returns true if the AABB contains a point. Points on the faces of the AABB are considered included, though float-point precision errors may impact the accuracy of such checks.
Note: This method is not reliable for AABB with a negative size. Use abs to get a positive sized equivalent AABB to check for contained points.
func (AABB) HasSurface ¶
HasSurface returns true if the AABB has a surface or a length, and false if the AABB is empty (all components of size are zero or negative).
func (AABB) HasVolume ¶
HasVolume returns true if the AABB has a volume, and false if the AABB is flat, empty, or has a negative size.
func (AABB) Intersection ¶
Intersection returns the intersection between two AABB. An empty AABB (size (0, 0, 0)) is returned on failure.
func (AABB) Intersects ¶
Intersects returns true if the AABB overlaps with another.
func (AABB) IntersectsPlane ¶
IntersectsPlane returns true if the AABB is on both sides of a plane.
func (AABB) IntersectsRay ¶
IntersectsRay returns the point of intersection of the given ray with this AABB along with the normal or false if there is no intersection. Ray length is infinite.
func (AABB) IntesectsSegment ¶
IntesectsSegment returns the point of intersection between from and to along with this AABB along with the normal or false if there is no intersection.
func (AABB) IsAproxximatelyEqual ¶
IsAproxximatelyEqual returns true if this AABB and other are approximately equal, by running IsApproximatelyEqual on each component.
func (AABB) IsFinite ¶
IsFinite returns true if this AABB is finite, by calling IsFinite on each component.
func (AABB) LongestAxis ¶
LongestAxis returns the normalized longest axis of the AABB.
func (AABB) LongestAxisIndex ¶
LongestAxisIndex returns the index of the longest axis of the AABB (according to Axis constants).
func (AABB) LongestAxisSize ¶
LongestAxisSize returns the scalar length of the longest axis of the AABB.
func (AABB) Projection ¶
func (a AABB) Projection() Projection
Projection creates a new Projection that scales a given projection to fit around a given AABB in projection space.
func (AABB) ShortestAxis ¶
ShortestAxis returns the normalized shortest axis of the AABB.
func (AABB) ShortestAxisIndex ¶
ShortestAxisIndex returns the index of the shortest axis of the AABB (according to Axis constants).
func (AABB) ShortestAxisSize ¶
ShortestAxisSize returns the scalar length of the shortest axis of the AABB.
func (AABB) Support ¶
Support returns the vertex of the AABB that's the farthest in a given direction. This point is commonly known as the support point in collision detection algorithms.
func (AABB) Transform ¶
func (a AABB) Transform(t Transform3D) AABB
Transform (multiplies) the AABB by the given Transform3D matrix.
type Basis ¶
type Basis [3]Vector3
Basis is a 3×3 matrix used for representing 3D rotation and scale. Usually used as an orthogonal basis for a Transform3D.
Contains 3 vector fields X, Y and Z as its columns, which are typically interpreted as the local basis vectors of a transformation. For such use, it is composed of a scaling and a rotation matrix, in that order (M = R.S).
Basis can also be accessed as an array of 3D vectors. These vectors are usually orthogonal to each other, but are not necessarily normalized (due to scaling).
func NewBasisLookingAt ¶
NewBasisLookingAt creates a Basis with a rotation such that the forward axis (-Z) points towards the target position.
The up axis (+Y) points as close to the up vector as possible while staying perpendicular to the forward axis. The resulting Basis is orthonormalized. The target and up vectors cannot be zero, and cannot be parallel to each other.
If use_model_front is true, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the target position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).
func NewBasisRotatedAround ¶
NewBasisRotatedAround constructs a pure rotation basis matrix, rotated around the given axis by angle (in radians). The axis must be a normalized vector.
func NewBasisScaledBy ¶
NewBasisScaledBy constructs a pure scale basis matrix with no rotation or shearing. The scale values are set as the diagonal of the matrix, and the other parts of the matrix are zero.
func (Basis) Determinant ¶
Determinant returns the determinant of the basis matrix. If the basis is uniformly scaled, its determinant is the square of the scale.
A negative determinant means the basis has a negative scale. A zero determinant means the basis isn't invertible, and is usually considered invalid.
func (Basis) EulerAngles ¶
func (b Basis) EulerAngles(order EulerOrder) EulerAngles
EulerAngles returns the basis's rotation in the form of Euler angles. The Euler order depends on the order parameter, by default it uses the YXZ convention: when decomposing, first Z, then X, and Y last. The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
Consider using the Basis.Quaternion method instead, which returns a Quaternion quaternion instead of EulerAngles.
func (Basis) IsApproximatelyEqual ¶
IsApproximatelyEqual returns true if this basis and b are approximately equal, by calling IsApproximatelyEqual on all vector components.
func (Basis) IsConformal ¶
IsConformal returns true if the basis is conformal, meaning it preserves angles and distance ratios, and may only be composed of rotation and uniform scale. Returns false if the basis has non-uniform scale or shear/skew. This can be used to validate if the basis is non-distorted, which is important for physics and other use cases.
func (Basis) IsFinite ¶
IsFinite returns true if this basis is finite, by calling IsFinite on all vector components.
func (Basis) Orthonormalized ¶
Orthonormalized returns the orthonormalized version of the matrix (useful to call from time to time to avoid rounding error for orthogonal matrices). This performs a Gram-Schmidt orthonormalization on the basis of the matrix.
func (Basis) Quaternion ¶
func (b Basis) Quaternion() Quaternion
Quaternion returns the basis's rotation in the form of a quaternion. See Basis.EulerAngles if you need Euler angles, but keep in mind quaternions should generally be preferred to EulerAngles.
func (Basis) Rotated ¶
Rotated returns a copy of the basis rotated around the given axis by the given angle (in radians). The axis must be a normalized vector.
func (Basis) Scale ¶
Scale assuming that the matrix is the combination of a rotation and scaling, returns the absolute value of scaling factors along each axis.
func (Basis) Scaled ¶
Scaled introduce an additional scaling specified by the given 3D scaling factor.
func (Basis) Slerp ¶
Slerp assuming that the matrix is a proper rotation matrix, slerp performs a spherical-linear interpolation with another rotation matrix.
func (Basis) Transposed ¶
Transposed returns the transposed version of the matrix.
func (Basis) TransposedDotX ¶
TransposedDotX returns the transposed dot product with the X axis of the matrix.
func (Basis) TransposedDotY ¶
TransposedDotY returns the transposed dot product with the Y axis of the matrix.
func (Basis) TransposedDotZ ¶
TransposedDotZ returns the transposed dot product with the Z axis of the matrix.
type ComponentWise ¶
type Degrees ¶
type Degrees float64
Degrees represents an angle in degrees.
func ProjectionFovy ¶
ProjectionFovy returns the vertical field of view of the projection (in degrees) associated with the given horizontal field of view (in degrees) and aspect ratio.
type EulerAngles ¶
type EulerAngles [3]Radians
EulerAngles represents a rotation in 3D space using Euler angles.
func (EulerAngles) Basis ¶
func (e EulerAngles) Basis(order EulerOrder) Basis
Basis constructs a pure rotation Basis matrix from Euler angles in the specified Euler rotation order. By default, use YXZ order (most common). See the EulerOrder enum for possible values.
func (EulerAngles) Quaternion ¶
func (e EulerAngles) Quaternion() Quaternion
Quaternion constructs a Quaternion from Euler angles in YXZ rotation order.
type EulerOrder ¶
type EulerOrder int64
const ( EulerOrderXYZ EulerOrder = 0 EulerOrderXZY EulerOrder = 1 EulerOrderYXZ EulerOrder = 2 EulerOrderYZX EulerOrder = 3 EulerOrderZXY EulerOrder = 4 EulerOrderZYX EulerOrder = 5 )
type Plane ¶
type Plane struct { /* Normal of the plane, typically a unit vector. Shouldn't be a zero vector as Plane with such normal does not represent a valid plane. In the scalar equation of the plane ax + by + cz = d, this is the vector (a, b, c), where d is the d property. */ Normal Vector3 /* D is the distance from the origin to the plane, expressed in terms of normal (according to its direction and magnitude). Actual absolute distance from the origin to the plane can be calculated as Abs(d) / normal.Length() (if normal has zero length then this Plane does not represent a valid plane). In the scalar equation of the plane ax + by + cz = d, this is d, while the (a, b, c) coordinates are represented by the normal property. */ D float }
Plane represents a normalized plane equation. normal is the normal of the plane (a, b, c normalized), and d is the distance from the origin to the plane (in the direction of "normal"). "Over" or "Above" the plane is considered the side of the plane towards where the normal is pointing.
func (Plane) DistanceTo ¶
DistanceTo returns the shortest distance from the plane to the position point. If the point is above the plane, the distance will be positive. If below, the distance will be negative.
func (Plane) HasPoint ¶
HasPoint returns true if point is inside the plane. Comparison uses a custom minimum tolerance threshold.
func (Plane) Intersect3 ¶
Intersect3 returns the intersection point of the three planes b, c and this plane. If no intersection is found, false is returned.
func (Plane) IntersectsRay ¶
IntersectsRay returns the intersection point of a ray consisting of the position from and the direction normal dir with this plane. If no intersection is found, false is returned.
func (Plane) IntersectsSegment ¶
IntersectsSegment returns the intersection point of a segment from position from to position to with this plane. If no intersection is found, false is returned.
func (Plane) IsApproximatelyEqual ¶
IsApproximatelyEqual returns true if this plane and other are approximately equal, by running IsApproximatelyEqual on each component.
func (Plane) IsFinite ¶
IsFinite returns true if this plane is finite, by calling IsFinite on each component.
func (Plane) IsPointOver ¶
IsPointOver returns true if point is located above the plane.
func (Plane) Normalized ¶
Normalized returns a copy of the plane, with normalized normal (so it's a unit vector). Returns Plane{0, 0, 0, 0} if normal can't be normalized (it has zero length).
func (Plane) Project ¶
Project returns the orthogonal projection of point into a point in the plane.
func (Plane) Transform ¶
func (p Plane) Transform(t Transform3D) Plane
Transform transforms (multiplies) the Plane by the given Transform3D transformation matrix.
type Projection ¶
type Projection [4]Vector4
Projection is a 4x4 matrix used for 3D projective transformations. It can represent transformations such as translation, rotation, scaling, shearing, and perspective division. It consists of four Vector4 columns.
For purely linear transformations (translation, rotation, and scale), it is recommended to use Transform3D, as it is more performant and requires less memory.
Generally used for a camera's projection matrix.
func NewProjectionForHeadMountedDisplay ¶
func NewProjectionForHeadMountedDisplay(eye int, aspect, intraocular_dist, display_width, display_to_lens, oversample, z_near, z_far float64) Projection
NewProjectionForHeadMountedDisplay creates a new Projection for projecting positions onto a head-mounted display with the given X:Y aspect ratio, distance between eyes, display width, distance to lens, oversampling factor, and depth clipping planes.
eye creates the projection for the left eye when set to 1, or the right eye when set to 2.
func NewProjectionThatIsOrthogonal ¶
func NewProjectionThatIsOrthogonal(left, right, bottom, top, z_near, z_far float64) Projection
NewProjectionThatIsOrthogonal creates a new Projection that projects positions using an orthogonal projection with the given clipping planes.
func NewProjectionThatIsOrthogonalWithAspectRatio ¶
func NewProjectionThatIsOrthogonalWithAspectRatio(size, aspect, z_near, z_far float64, flip_fov bool) Projection
NewProjectionThatIsOrthogonalWithAspectRatio creates a new Projection that projects positions using an orthogonal projection with the given size, X:Y aspect ratio, and clipping planes.
flip_fov determines whether the projection's field of view is flipped over its diagonal.
func NewProjectionWithDepthCorrection ¶
func NewProjectionWithDepthCorrection(fliy bool) Projection
NewProjectionWithDepthCorrection creates a new Projection that projects positions from a depth range of -1 to 1 to one that ranges from 0 to 1, and flips the projected positions vertically, according to fliy.
func NewProjectionWithFrustum ¶
func NewProjectionWithFrustum(left, right, bottom, top, z_near, z_far float64) Projection
NewProjectionWithFrustum creates a new Projection that projects positions in a frustum with the given clipping planes.
func NewProjectionWithFrustumAspectRatio ¶
func NewProjectionWithFrustumAspectRatio(size, aspect float64, offset Vector2, z_near, z_far float64, flip_fov bool) Projection
NewProjectionWithFrustumAspectRatio creates a new Projection that projects positions in a frustum with the given size, X:Y aspect ratio, offset, and clipping planes.
flip_fov determines whether the projection's field of view is flipped over its diagonal.
func NewProjectionWithPerspective ¶
func NewProjectionWithPerspective(fovy Degrees, aspect, z_near, z_far float64, flip_fov bool) Projection
NewProjectionWithPerspective creates a new Projection that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping planes.
flip_fov determines whether the projection's field of view is flipped over its diagonal.
func NewProjectionWithPerspectiveForHeadMountedDisplay ¶
func NewProjectionWithPerspectiveForHeadMountedDisplay(fovy Degrees, aspect, z_near, z_far float64, flip_fov bool, eye int, intraocular_dist, convergence_dist float64) Projection
NewProjectionWithPerspectiveForHeadMountedDisplay creates a new Projection that projects positions using a perspective projection with the given Y-axis field of view (in degrees), X:Y aspect ratio, and clipping distances. The projection is adjusted for a head-mounted display with the given distance between eyes and distance to a point that can be focused on.
eye creates the projection for the left eye when set to 1, or the right eye when set to 2.
flip_fov determines whether the projection's field of view is flipped over its diagonal
func (Projection) AspectRatio ¶
func (p Projection) AspectRatio() float64
AspectRatio returns the X:Y aspect ratio of this Projection's viewport.
func (Projection) Determinant ¶
func (p Projection) Determinant() float64
Determinant returns a scalar value that is the signed factor by which areas are scaled by this matrix. If the sign is negative, the matrix flips the orientation of the area.
The determinant can be used to calculate the invertibility of a matrix or solve linear systems of equations involving the matrix, among other applications.
func (Projection) FarPlaneHalfExtents ¶
func (p Projection) FarPlaneHalfExtents() Vector2
FarPlaneHalfExtents returns the dimensions of the far clipping plane of the projection, divided by two.
func (Projection) FarZ ¶
func (p Projection) FarZ() float64
FarZ returns the distance for this Projection beyond which positions are clipped.
func (Projection) FieldOfView ¶
func (p Projection) FieldOfView() Degrees
FieldOfView returns the horizontal field of view of the projection (in degrees).
func (Projection) FlippedY ¶
func (p Projection) FlippedY() Projection
FlippedY returns a copy of this Projection with the signs of the values of the Y column flipped.
func (Projection) IDENTITY ¶
func (Projection) IDENTITY() Projection
func (Projection) Inverse ¶
func (p Projection) Inverse() Projection
Inverse returns a Projection that performs the inverse of this Projection's projective transformation.
func (Projection) IsOrthogonal ¶
func (p Projection) IsOrthogonal() bool
IsOrthogonal returns true if this Projection performs an orthogonal projection.
func (Projection) JitterOffseted ¶
func (p Projection) JitterOffseted(jitter Vector2) Projection
JitterOffseted returns a Projection with the X and Y values from the given Vector2 added to the first and second values of the final column respectively.
func (Projection) LevelOfDetailMultiplier ¶
func (p Projection) LevelOfDetailMultiplier() float64
LevelOfDetailMultiplier returns the factor by which the visible level of detail is scaled by this Projection.
func (Projection) Mul ¶
func (p Projection) Mul(other Projection) Projection
func (Projection) NearZ ¶
func (p Projection) NearZ() float64
NearZ returns the distance for this Projection before which positions are clipped.
func (Projection) PerspectiveAdjustedNearZ ¶
func (p Projection) PerspectiveAdjustedNearZ(new_near_z float64) Projection
PerspectiveAdjustedNearZ returns a Projection with the near clipping distance adjusted to be new_znear.
Note: The original Projection must be a perspective projection.
func (Projection) PixelsPerMeter ¶
func (p Projection) PixelsPerMeter(pixel_width int64) int64
PixelsPerMeter returns the number of pixels with the given pixel width displayed per meter, after this Projection is applied.
func (Projection) ProjectionPlane ¶
func (p Projection) ProjectionPlane(plane ProjectionPlane) (new_plane Plane)
ProjectionPlane returns the clipping plane of this Projection whose index is given by plane.
plane should be equal to one of PLANE_NEAR, PLANE_FAR, PLANE_LEFT, PLANE_TOP, PLANE_RIGHT, or PLANE_BOTTOM.
func (Projection) Transform3D ¶
func (p Projection) Transform3D() Transform3D
func (Projection) ViewportHalfExtents ¶
func (p Projection) ViewportHalfExtents() Vector2
ViewportHalfExtents returns the dimensions of the viewport plane that this Projection projects positions onto, divided by two.
func (Projection) W ¶
func (p Projection) W() Vector4
func (Projection) X ¶
func (p Projection) X() Vector4
func (Projection) Y ¶
func (p Projection) Y() Vector4
func (Projection) Z ¶
func (p Projection) Z() Vector4
type ProjectionPlane ¶
type ProjectionPlane int
const ( PlaneNear ProjectionPlane = iota PlaneFar PlaneLeft PlaneTop PlaneRight PlaneBottom )
type Quaternion ¶
type Quaternion [4]float
Quaternions are similar to Basis, which implements the matrix representation of rotations. Unlike Basis, which stores rotation, scale, and shearing, quaternions only store rotation.
Quaternions can be parametrized using both an axis-angle pair or Euler angles. Due to their compactness and the way they are stored in memory, certain operations (obtaining axis-angle and performing SLERP, in particular) are more efficient and robust against floating-point errors.
Note: Quaternions need to be normalized before being used for rotation.
func NewQuaternion ¶
func NewQuaternion(arc_from, arc_to Vector3) Quaternion
NewQuaternion constructs a quaternion representing the shortest arc between two points on the surface of a sphere with a radius of 1.0.
func (Quaternion) Add ¶
func (q Quaternion) Add(other Quaternion) Quaternion
func (Quaternion) Addf ¶
func (q Quaternion) Addf(other float64) Quaternion
func (Quaternion) Angle ¶
func (q Quaternion) Angle() Radians
func (Quaternion) AngleTo ¶
func (q Quaternion) AngleTo(other Quaternion) Radians
AngleTo Returns the angle between this quaternion and to. This is the magnitude of the angle you would need to rotate by to get from one to the other.
Note: The magnitude of the floating-point error for this method is abnormally high, so methods such as IsApproximatelyZero will not work reliably.
func (Quaternion) Axis ¶
func (q Quaternion) Axis() Vector3
func (Quaternion) Basis ¶
func (q Quaternion) Basis() Basis
func (Quaternion) Div ¶
func (q Quaternion) Div(other Quaternion) Quaternion
func (Quaternion) Divf ¶
func (q Quaternion) Divf(other float64) Quaternion
func (Quaternion) Dot ¶
func (q Quaternion) Dot(other Quaternion) float64
Dot Returns the dot product of this quaternion and other.
func (Quaternion) EulerAngles ¶
func (q Quaternion) EulerAngles(order EulerOrder) EulerAngles
EulerAngles returns the quaternion's rotation in the form of Euler angles. The Euler order depends on the order parameter, for example using the YXZ convention: since this method decomposes, first Z, then X, and Y last. See the EulerOrder enum for possible values. The returned vector contains the rotation angles in the format (X angle, Y angle, Z angle).
func (Quaternion) Exp ¶
func (q Quaternion) Exp() Quaternion
func (Quaternion) IDENTITY ¶
func (Quaternion) IDENTITY() Quaternion
func (Quaternion) Inverse ¶
func (q Quaternion) Inverse() Quaternion
Inverse returns the inverse of the quaternion.
func (Quaternion) IsApproximatelyEqual ¶
func (q Quaternion) IsApproximatelyEqual(other Quaternion) bool
IsApproximatelyEqual returns true if this quaternion and to are approximately equal, by running IsApproximatelyEqual on each component.
func (Quaternion) IsFinite ¶
func (q Quaternion) IsFinite() bool
IsFinite returns true if this quaternion is finite, by calling IsFinite on each component.
func (Quaternion) IsNormalized ¶
func (q Quaternion) IsNormalized() bool
IsNormalized returns whether the quaternion is normalized or not.
func (Quaternion) Length ¶
func (q Quaternion) Length() float64
Length returns the length of the quaternion.
func (Quaternion) LengthSquared ¶
func (q Quaternion) LengthSquared() float64
LengthSquared returns the length of the quaternion, squared.
func (Quaternion) Log ¶
func (q Quaternion) Log() Quaternion
func (Quaternion) Mul ¶
func (q Quaternion) Mul(other Quaternion) Quaternion
func (Quaternion) Mulf ¶
func (q Quaternion) Mulf(other float64) Quaternion
func (Quaternion) Neg ¶
func (q Quaternion) Neg() Quaternion
func (Quaternion) Normalized ¶
func (q Quaternion) Normalized() Quaternion
Normalized returns a copy of the quaternion, normalized to unit length.
func (Quaternion) SetW ¶
func (q Quaternion) SetW(v float64)
func (Quaternion) SetX ¶
func (q Quaternion) SetX(v float64)
func (Quaternion) SetY ¶
func (q Quaternion) SetY(v float64)
func (Quaternion) SetZ ¶
func (q Quaternion) SetZ(v float64)
func (Quaternion) Slerp ¶
func (q Quaternion) Slerp(to Quaternion, weight float64) Quaternion
Slerp returns the result of the spherical linear interpolation between this quaternion and to by amount weight.
Note: Both quaternions must be normalized.
func (Quaternion) Slerpni ¶
func (q Quaternion) Slerpni(to Quaternion, weight float64) Quaternion
Slerpni returns the result of the spherical linear interpolation between this quaternion and to by amount weight, but without checking if the rotation path is not bigger than 90 degrees.
func (Quaternion) SphericalCubicInterpolate ¶
func (q Quaternion) SphericalCubicInterpolate(b, pre_a, post_b Quaternion, weight float64) Quaternion
SphericalCubicInterpolate performs a spherical cubic interpolation between quaternions pre_a, this vector, b, and post_b, by the given amount weight.
func (Quaternion) SphericalCubicInterpolateInTime ¶
func (q Quaternion) SphericalCubicInterpolateInTime(b, pre_a, post_b Quaternion, weight, b_t, pre_a_t, post_b_t float64) Quaternion
SphericalCubicInterpolateInTime performs a spherical cubic interpolation between quaternions pre_a, this vector, b, and post_b, by the given amount weight.
It can perform smoother interpolation than spherical_cubic_interpolate by the time values.
func (Quaternion) Sub ¶
func (q Quaternion) Sub(other Quaternion) Quaternion
func (Quaternion) Subf ¶
func (q Quaternion) Subf(other float64) Quaternion
func (Quaternion) W ¶
func (q Quaternion) W() float64
func (Quaternion) X ¶
func (q Quaternion) X() float64
func (Quaternion) Y ¶
func (q Quaternion) Y() float64
func (Quaternion) Z ¶
func (q Quaternion) Z() float64
type Radians ¶
type Radians float64
Radians represents an angle in radians.
func Acos ¶
Acos returns the arc cosine of x in radians. Use to get the angle of cosine x. x will be clamped between -1.0 and 1.0 (inclusive), in order to prevent acos from returning NaN.
func Acosh ¶
Acosh returns the hyperbolic arc (also called inverse) cosine of x, returning a value in radians. Use it to get the angle from an angle's cosine in hyperbolic space if x is larger or equal to 1. For values of x lower than 1, it will return 0, in order to prevent acosh from returning NaN.
func Asin ¶
Asin returns the arc sine of x in radians. Use to get the angle of sine x. x will be clamped between -1.0 and 1.0 (inclusive), in order to prevent asin from returning NaN.
func Asinh ¶
Asinh returns the hyperbolic arc (also called inverse) sine of x, returning a value in radians. Use it to get the angle from an angle's sine in hyperbolic space.
func Atan ¶
Atan returns the arc tangent of x in radians. Use it to get the angle from an angle's tangent in trigonometry. The method cannot know in which quadrant the angle should fall. See atan2 if you have both y and x.
func Atan2 ¶
Atan2 returns the arc tangent of y/x in radians. Use to get the angle of tangent y/x. To compute the value, the method takes into account the sign of both arguments in order to determine the quadrant.
Important note: The Y coordinate comes first, by convention.
func Atanh ¶
Atanh returns the hyperbolic arc (also called inverse) tangent of x, returning a value in radians. Use it to get the angle from an angle's tangent in hyperbolic space if x is between -1 and 1 (non-inclusive).
In mathematics, the inverse hyperbolic tangent is only defined for -1 < x < 1 in the real set, so values equal or lower to -1 for x return -INF and values equal or higher than 1 return +INF in order to prevent atanh from returning NaN.
type Rect2 ¶
Rect2 represents an axis-aligned rectangle in a 2D space. It is defined by its position and size, which are Vector2. It is frequently used for fast overlap tests (see intersects). Although Rect2 itself is axis-aligned, it can be combined with Transform2D to represent a rotated or skewed rectangle.
For integer coordinates, use Rect2i. The 3D equivalent to Rect2 is AABB.
Note: Negative values for size are not supported. With negative size, most Rect2 methods do not work correctly. Use abs to get an equivalent Rect2 with a non-negative size.
Note: In a boolean context, a Rect2 evaluates to false if both position and size are zero (equal to Const(Vector2.ZERO)). Otherwise, it always evaluates to true.
func NewRect2 ¶
NewRect2 constructs a Rect2 by setting its position to (x, y), and its size to (width, height).
func (Rect2) Abs ¶
Abs returns a Rect2 equivalent to this rectangle, with its width and height modified to be non-negative values, and with its position being the top-left corner of the rectangle.
var rect = NewRect2(25,25,-100,-50) var absolute = rect.Abs() // absolute is Rect2(-75, -25, 100, 50)
Note: It's recommended to use this method when size is negative, as most other methods in Godot assume that the position is the top-left corner, and the end is the bottom-right corner.
func (Rect2) Area ¶
Area returns the rectangle's area. This is equivalent to Size[X] * Size[Y]. See also Rect2.HasArea.
func (Rect2) Center ¶
Center returns the center point of the rectangle. This is the same as position + (size / 2.0).
func (Rect2) Encloses ¶
Encloses returns true if this rectangle completely encloses the b rectangle.
func (Rect2) End ¶
End is the ending point. This is usually the bottom-right corner of the rectangle, and is equivalent to position + size.
func (Rect2) Expand ¶
Expand returns a copy of this rectangle expanded to align the edges with the given to point, if necessary.
var rect = NewRect2(0, 0, 5, 2) rect = rect.Expand(Vector2{10, 0}) // rect is now Rect2(0, 0, 10, 2) rect = rect.Expand(Vector2{-5, 5}) // rect is now Rect2(-5, 0, 10, 5)
func (Rect2) Grow ¶
Grow returns a copy of this rectangle extended on all sides by the given amount. A negative amount shrinks the rectangle instead. See also Rect2.GrowIndividual and Rect2.GrowSide.
var a = Rect2{4,4,8,8}.Grow(4) // a is Rect2(0, 0, 16, 16) var b = Rect2{4,4,8,8}.Grow(2) // b is Rect2(-2, -2, 12, 8)
func (Rect2) GrowIndividual ¶
GrowIndividual returns a copy of this rectangle with its left, top, right, and bottom sides extended by the given amounts. Negative values shrink the sides, instead. See also Rect2.Grow and Rect2.GrowSide.
func (Rect2) GrowSide ¶
GrowSide returns a copy of this rectangle with its side extended by the given amount (see Side constants). A negative amount shrinks the rectangle, instead. See also Rect2.Grow and Rect2.GrowIndividual.
func (Rect2) HasArea ¶
HasArea returns true if this rectangle has positive width and height. See also [GetArea].
func (Rect2) HasPoint ¶
HasPoint returns true if the rectangle contains the given point. By convention, points on the right and bottom edges are not included.
Note: This method is not reliable for Rect2 with a negative size. Use abs first to get a valid rectangle.
func (Rect2) Intersection ¶
Intersection returns the intersection between this rectangle and b. If the rectangles do not intersect, returns an empty Rect2.
var rect1 = Rect2{0, 0, 5, 10} var rect2 = Rect2{2, 0, 9, 4} var a = rect1.Intersection(rect2) // a is Rect2(2, 0, 3, 4)
Note: If you only need to know whether two rectangles are overlapping, use Rect2.Intersects, instead.
func (Rect2) Intersects ¶
Intersects returns true if this rectangle overlaps with the b rectangle. The edges of both rectangles are excluded, unless include_borders is true.
func (Rect2) IsApproximatelyEqual ¶
IsApproximatelyEqual returns true if this rectangle and rect are approximately equal, by calling Vector2.IsApproximatelyEqual on the position and the size.
func (Rect2) IsFinite ¶
IsFinite returns true if this rectangle's values are finite, by calling Vector2.IsFinite on the position and the size.
func (Rect2) Merge ¶
Merge returns a Rect2 that encloses both this rectangle and b around the edges. See also Rect2.Encloses.
func (Rect2) Projection ¶
func (r Rect2) Projection() Projection
Projection creates a new Projection that projects positions into the given Rect2.
func (*Rect2) SetEnd ¶
SetEnd sets the ending point. This is usually the bottom-right corner of the rectangle, and is equivalent to position + size. Setting the end point will change the size of the rectangle.
func (Rect2) Transform ¶
func (r Rect2) Transform(t Transform2D) Rect2
Transform inversely transforms (multiplies) the Rect2 by the given Transform2D transformation matrix, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
rect * transform is equivalent to transform.Inverse() * rect. See Transform2D.Inverse.
For transforming by inverse of an affine transformation (e.g. with scaling) rect.Transform(transform.AffineInverse()) can be used instead. See Transform2D.AffineInverse.
type Rect2i ¶
Rect2 represents an axis-aligned rectangle in a 2D space, using integer coordinates. It is defined by its position and size, which are Vector2i. Because it does not rotate, it is frequently used for fast overlap tests (see intersects).
For floating-point coordinates, see Rect2.
Note: Negative values for size are not supported. With negative size, most Rect2i methods do not work correctly. Use abs to get an equivalent Rect2i with a non-negative size.
Note: In a boolean context, a Rect2i evaluates to false if both position and size are zero (equal to Const(Vector2i.ZERO)). Otherwise, it always evaluates to true.
func (Rect2i) Abs ¶
Abs returns a Rect2 equivalent to this rectangle, with its width and height modified to be non-negative values, and with its position being the top-left corner of the rectangle.
var rect = NewRect2(25,25,-100,-50) var absolute = rect.Abs() // absolute is Rect2(-75, -25, 100, 50)
Note: It's recommended to use this method when size is negative, as most other methods in Godot assume that the position is the top-left corner, and the end is the bottom-right corner.
func (Rect2i) Area ¶
Area returns the rectangle's area. This is equivalent to Size[X] * Size[Y]. See also Rect2.HasArea.
func (Rect2i) Center ¶
Center returns the center point of the rectangle. This is the same as position + (size / 2.0).
func (Rect2i) Encloses ¶
Encloses returns true if this rectangle completely encloses the b rectangle.
func (Rect2i) End ¶
End is the ending point. This is usually the bottom-right corner of the rectangle, and is equivalent to position + size.
func (Rect2i) Expand ¶
Expand returns a copy of this rectangle expanded to align the edges with the given to point, if necessary.
var rect = NewRect2(0, 0, 5, 2) rect = rect.Expand(Vector2{10, 0}) // rect is now Rect2(0, 0, 10, 2) rect = rect.Expand(Vector2{-5, 5}) // rect is now Rect2(-5, 0, 10, 5)
func (Rect2i) Grow ¶
Grow returns a copy of this rectangle extended on all sides by the given amount. A negative amount shrinks the rectangle instead. See also Rect2.GrowIndividual and Rect2.GrowSide.
var a = Rect2{4,4,8,8}.Grow(4) // a is Rect2(0, 0, 16, 16) var b = Rect2{4,4,8,8}.Grow(2) // b is Rect2(-2, -2, 12, 8)
func (Rect2i) GrowIndividual ¶
GrowIndividual returns a copy of this rectangle with its left, top, right, and bottom sides extended by the given amounts. Negative values shrink the sides, instead. See also Rect2.Grow and Rect2.GrowSide.
func (Rect2i) GrowSide ¶
GrowSide returns a copy of this rectangle with its side extended by the given amount (see Side constants). A negative amount shrinks the rectangle, instead. See also Rect2.Grow and Rect2.GrowIndividual.
func (Rect2i) HasArea ¶
HasArea returns true if this rectangle has positive width and height. See also [GetArea].
func (Rect2i) HasPoint ¶
HasPoint returns true if the rectangle contains the given point. By convention, points on the right and bottom edges are not included.
Note: This method is not reliable for Rect2 with a negative size. Use abs first to get a valid rectangle.
func (Rect2i) Intersection ¶
Intersection returns the intersection between this rectangle and b. If the rectangles do not intersect, returns an empty Rect2.
var rect1 = Rect2{0, 0, 5, 10} var rect2 = Rect2{2, 0, 9, 4} var a = rect1.Intersection(rect2) // a is Rect2(2, 0, 3, 4)
Note: If you only need to know whether two rectangles are overlapping, use Rect2.Intersects, instead.
func (Rect2i) Intersects ¶
Intersects returns true if this rectangle overlaps with the b rectangle. The edges of both rectangles are excluded, unless include_borders is true.
func (Rect2i) Merge ¶
Merge returns a Rect2 that encloses both this rectangle and b around the edges. See also Rect2.Encloses.
type Transform2D ¶
type Transform2D [3]Vector2
Transform2D is a 2×3 matrix (2 rows, 3 columns) used for 2D linear transformations. It can represent transformations such as translation, rotation, and scaling. It consists of three Vector2 values: x, y, and the origin.
For more information, read the "Matrices and transforms" documentation article.
func NewTransform2D ¶
func NewTransform2D(rotation Radians, scale Vector2, skew Radians, position Vector2) Transform2D
NewTransform2D constructs a new Transform2D from the given rotation and position.
func (Transform2D) AffineInverse ¶
func (t Transform2D) AffineInverse() Transform2D
AffineInverse returns the inverse of the transform, under the assumption that the basis is invertible (must have non-zero determinant).
func (Transform2D) BasisTransform ¶
func (t Transform2D) BasisTransform(v Vector2) Vector2
BasisTransform returns a vector transformed (multiplied) by the basis matrix.
This method does not account for translation (the origin vector).
func (Transform2D) Determinant ¶
func (t Transform2D) Determinant() float64
Determinant returns the determinant of the basis matrix. If the basis is uniformly scaled, then its determinant equals the square of the scale factor.
A negative determinant means the basis was flipped, so one part of the scale is negative. A zero determinant means the basis isn't invertible, and is usually considered invalid.
func (Transform2D) FLIP_X ¶
func (t Transform2D) FLIP_X() Transform2D
func (Transform2D) FLIP_Y ¶
func (t Transform2D) FLIP_Y() Transform2D
func (Transform2D) IDENTITY ¶
func (t Transform2D) IDENTITY() Transform2D
func (Transform2D) InterpolateWith ¶
func (t Transform2D) InterpolateWith(b Transform2D, weight float64) Transform2D
InterpolateWith returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0).
func (Transform2D) Inverse ¶
func (t Transform2D) Inverse() Transform2D
Inverse returns the inverse of the transform, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). Use affine_inverse for non-orthonormal transforms (e.g. with scaling).
func (Transform2D) InverseBasisTransform ¶
func (t Transform2D) InverseBasisTransform(v Vector2) Vector2
InverseBasisTransform returns a vector transformed (multiplied) by the inverse basis matrix, under the assumption that the basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not).
This method does not account for translation (the origin vector).
transform.InverseBasisTransform(vector) is equivalent to transform.Inverse().BasisTransform(vector). See Transform2D.Inverse.
For non-orthonormal transforms (e.g. with scaling) transform.AffineInverse().BasisTransform(vector) can be used instead. See Transform2D.AffineInverse.
func (Transform2D) IsApproximatelyEqual ¶
func (t Transform2D) IsApproximatelyEqual(xform Transform2D) bool
IsApproximatelyEqual returns true if this transform and xform are approximately equal, by running Vector2.IsApproximatelyEqual on each component.
func (Transform2D) IsConformal ¶
func (t Transform2D) IsConformal() bool
IsConformal returns true if the transform's basis is conformal, meaning it preserves angles and distance ratios, and may only be composed of rotation and uniform scale. Returns false if the transform's basis has non-uniform scale or shear/skew. This can be used to validate if the transform is non-distorted, which is important for physics and other use cases.
func (Transform2D) IsFinite ¶
func (t Transform2D) IsFinite() bool
IsFinite returns true if this transform is finite, by calling Vector2.IsFinite on each component.
func (Transform2D) LookingAt ¶
func (t Transform2D) LookingAt(target Vector2) Transform2D
LookingAt returns a copy of the transform rotated such that the rotated X-axis points towards the target position.
Operations take place in global space.
func (Transform2D) Mul ¶
func (t Transform2D) Mul(other Transform2D) Transform2D
func (Transform2D) Origin ¶
func (t Transform2D) Origin() Vector2
Origin returns the transform's origin (translation).
func (Transform2D) Orthonormalized ¶
func (t Transform2D) Orthonormalized() Transform2D
Orthonormalized returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
func (Transform2D) Rotated ¶
func (t Transform2D) Rotated(angle Radians) Transform2D
Rotated returns a copy of the transform rotated by the given angle (in radians).
This method is an optimized version of multiplying the given transform X with a corresponding rotation transform R from the left, i.e., R * X.
This can be seen as transforming with respect to the global/parent frame.
func (Transform2D) RotatedLocal ¶
func (t Transform2D) RotatedLocal(angle Radians) Transform2D
RotatedLocal returns a copy of the transform rotated by the given angle (in radians).
This method is an optimized version of multiplying the given transform X with a corresponding rotation transform R from the right, i.e., X * R.
This can be seen as transforming with respect to the local frame.
func (Transform2D) Rotation ¶
func (t Transform2D) Rotation() Radians
Rotation returns the transform's rotation.
func (Transform2D) Scale ¶
func (t Transform2D) Scale() Vector2
Scale returns the transform's scale.
func (Transform2D) Scaled ¶
func (t Transform2D) Scaled(scale Vector2) Transform2D
Scaled returns a copy of the transform scaled by the given scale factor.
This method is an optimized version of multiplying the given transform X with a corresponding scaling transform S from the left, i.e., S * X.
This can be seen as transforming with respect to the global/parent frame.
func (Transform2D) ScaledLocal ¶
func (t Transform2D) ScaledLocal(scale Vector2) Transform2D
ScaledLocal returns a copy of the transform scaled by the given scale factor.
This method is an optimized version of multiplying the given transform X with a corresponding scaling transform S from the right, i.e., X * S.
This can be seen as transforming with respect to the local frame.
func (*Transform2D) SetOrigin ¶
func (t *Transform2D) SetOrigin(o Vector2)
func (*Transform2D) SetX ¶
func (t *Transform2D) SetX(x Vector2)
func (*Transform2D) SetY ¶
func (t *Transform2D) SetY(y Vector2)
func (Transform2D) Skew ¶
func (t Transform2D) Skew() Radians
Skew returns the transform's skew (in radians)
func (Transform2D) Translated ¶
func (t Transform2D) Translated(offset Vector2) Transform2D
Translated returns a copy of the transform translated by the given offset.
This method is an optimized version of multiplying the given transform X with a corresponding translation transform T from the left, i.e., T * X.
This can be seen as transforming with respect to the global/parent frame.
func (Transform2D) TranslatedLocal ¶
func (t Transform2D) TranslatedLocal(offset Vector2) Transform2D
TranslatedLocal returns a copy of the transform translated by the given offset.
This method is an optimized version of multiplying the given transform X with a corresponding translation transform T from the right, i.e., X * T.
This can be seen as transforming with respect to the local frame.
func (Transform2D) X ¶
func (t Transform2D) X() Vector2
func (Transform2D) Y ¶
func (t Transform2D) Y() Vector2
type Transform3D ¶
Transform3D is a 3×4 matrix (3 rows, 4 columns) used for 3D linear transformations. It can represent transformations such as translation, rotation, and scaling. It consists of a basis (first 3 columns) and a Vector3 for the origin (last column).
func (Transform3D) AffineInverse ¶
func (t Transform3D) AffineInverse() Transform3D
AffineInverse returns the inverse of the transform, under the assumption that the basis is invertible (must have non-zero determinant).
func (Transform3D) FLIP_X ¶
func (Transform3D) FLIP_X() Transform3D
func (Transform3D) FLIP_Y ¶
func (Transform3D) FLIP_Y() Transform3D
func (Transform3D) FLIP_Z ¶
func (Transform3D) FLIP_Z() Transform3D
func (Transform3D) IDENTITY ¶
func (Transform3D) IDENTITY() Transform3D
func (Transform3D) InterpolateWith ¶
func (t Transform3D) InterpolateWith(other Transform3D, weight float64) Transform3D
InterpolateWith returns a transform interpolated between this transform and another by a given weight (on the range of 0.0 to 1.0).
func (Transform3D) Inverse ¶
func (t Transform3D) Inverse() Transform3D
Inverse returns the inverse of the transform, under the assumption that the transformation basis is orthonormal (i.e. rotation/reflection is fine, scaling/skew is not). Use affine_inverse for non-orthonormal transforms (e.g. with scaling).
func (Transform3D) IsApproximatelyEqual ¶
func (t Transform3D) IsApproximatelyEqual(other Transform3D) bool
IsApproximatelyEqual returns true if this transform and xform are approximately equal, by running IsApproximatelyEqual on each component.
func (Transform3D) IsFinite ¶
func (t Transform3D) IsFinite() bool
IsFinite returns true if this transform is finite, by calling IsFinite on each component.
func (Transform3D) LookingAt ¶
func (t Transform3D) LookingAt(target, up Vector3, use_model_front bool) Transform3D
LookingAt returns a copy of the transform rotated such that the forward axis (-Z) points towards the target position.
The up axis (+Y) points as close to the up vector as possible while staying perpendicular to the forward axis. The resulting transform is orthonormalized. The existing rotation, scale, and skew information from the original transform is discarded. The target and up vectors cannot be zero, cannot be parallel to each other, and are defined in global/parent space.
If use_model_front is true, the +Z axis (asset front) is treated as forward (implies +X is left) and points toward the target position. By default, the -Z axis (camera forward) is treated as forward (implies +X is right).
func (Transform3D) Mul ¶
func (t Transform3D) Mul(other Transform3D) Transform3D
func (Transform3D) Orthonormalized ¶
func (t Transform3D) Orthonormalized() Transform3D
Orthonormalized returns the transform with the basis orthogonal (90 degrees), and normalized axis vectors (scale of 1 or -1).
func (Transform3D) Projection ¶
func (t Transform3D) Projection() Projection
func (Transform3D) Rotated ¶
func (t Transform3D) Rotated(axis Vector3, phi Radians) Transform3D
Rotated returns a copy of the transform rotated around the given axis by the given angle (in radians).
The axis must be a normalized vector.
This method is an optimized version of multiplying the given transform X with a corresponding rotation transform R from the left, i.e., R * X.
This can be seen as transforming with respect to the global/parent frame.
func (Transform3D) RotatedLocal ¶
func (t Transform3D) RotatedLocal(axis Vector3, phi Radians) Transform3D
RotatedLocal returns a copy of the transform rotated around the given axis by the given angle (in radians).
The axis must be a normalized vector.
This method is an optimized version of multiplying the given transform X with a corresponding rotation transform R from the right, i.e., X * R.
This can be seen as transforming with respect to the local frame.
func (Transform3D) Scaled ¶
func (t Transform3D) Scaled(scale Vector3) Transform3D
Scaled returns a copy of the transform scaled by the given scale factor.
This method is an optimized version of multiplying the given transform X with a corresponding scaling transform S from the left, i.e., S * X.
This can be seen as transforming with respect to the global/parent frame.
func (Transform3D) ScaledLocal ¶
func (t Transform3D) ScaledLocal(scale Vector3) Transform3D
ScaledLocal returns a copy of the transform scaled by the given scale factor.
This method is an optimized version of multiplying the given transform X with a corresponding scaling transform S from the right, i.e., X * S.
This can be seen as transforming with respect to the local frame.
func (Transform3D) Translated ¶
func (t Transform3D) Translated(offset Vector3) Transform3D
Translated returns a copy of the transform translated by the given offset.
This method is an optimized version of multiplying the given transform X with a corresponding translation transform T from the left, i.e., T * X.
This can be seen as transforming with respect to the global/parent frame.
func (Transform3D) TranslatedLocal ¶
func (t Transform3D) TranslatedLocal(offset Vector3) Transform3D
TranslatedLocal returns a copy of the transform translated by the given offset.
This method is an optimized version of multiplying the given transform X with a corresponding translation transform T from the right, i.e., X * T.
This can be seen as transforming with respect to the local frame.
type Vector2 ¶
type Vector2 [2]float
Vector2 is a 2-element structure that can be used to represent 2D coordinates or any other pair of numeric values.
It uses floating-point coordinates. By default, these floating-point values use 32-bit precision, unlike Float which is always 64-bit. If double precision is needed, compile the engine with the option precision=double.
See Vector2i for its integer counterpart.
Note: In a boolean context, a Vector2 will evaluate to false if it's equal to Vector2{0, 0}. Otherwise, a Vector2 will always evaluate to true.
func NewVector2 ¶
NewVector2 constructs a new Vector2 from the given x and y.
func (Vector2) Abs ¶
Abs returns a new vector with all components in absolute values (i.e. positive).
func (Vector2) Angle ¶
Angle Returns this vector's angle with respect to the positive X axis, or (1, 0) vector, in radians.
For example, Const(Vector2.Right).Angle() will return zero, Const(Vector2.Down).Angle() will return PI / 2 (a quarter turn, or 90 degrees), and Vector2(1, -1).Angle() will return -Pi / 4 (a negative eighth turn, or -45 degrees).
Illustration of the returned angle. https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle.png
Equivalent to the result of Atan2 when called with the vector's y and x as parameters:
Atan2(y, x).
func (Vector2) AngleTo ¶
AngleTo Returns the angle to the given vector, in radians.
Illustration of the returned angle. https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to.png
func (Vector2) AngleToPoint ¶
AngleToPoint returns the angle between the line connecting the two points and the X axis, in radians. a.AngleToPoint(b) is equivalent of doing (b - a).Angle().
Illustration of the returned angle. https://raw.githubusercontent.com/godotengine/godot-docs/master/img/vector2_angle_to_point.png
func (Vector2) BezierDerivative ¶
BezierDerivative returns the derivative at the given t on the Bézier curve defined by this vector and the given control_1, control_2, and end points.
func (Vector2) BezierInterpolate ¶
BezierInterpolate returns the point at the given t on the Bézier curve defined by this vector and the given control_1, control_2, and end points.
func (Vector2) Bounce ¶
Bounce returns a new vector "bounced off" from a plane defined by the given normal.
func (Vector2) Ceil ¶
Ceil returns a new vector with all components rounded up (towards positive infinity).
func (Vector2) Clamp ¶
Clamp returns a new vector with all components clamped to the given min and max.
func (Vector2) Cross ¶
Cross returns the 2D analog of the cross product for this vector and with.
This is the signed area of the parallelogram formed by the two vectors. If the second vector is clockwise from the first vector, then the cross product is the positive area. If counter-clockwise, the cross product is the negative area.
Note: Cross product is not defined in 2D mathematically. This method embeds the 2D vectors in the XY plane of 3D space and uses their cross product's Z component as the analog.
func (Vector2) CubicInterpolate ¶
CubicInterpolate performs a cubic interpolation between this vector and b using pre_a and post_b as handles, and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
func (Vector2) CubicInterpolateInTime ¶
func (v Vector2) CubicInterpolateInTime(b, preA, postB Vector2, weight, b_t, pre_a_t, post_b_t float64) Vector2
CubicInterpolateInTime performs a cubic interpolation between this vector and b using pre_a and post_b as handles, and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
It can perform smoother interpolation than cubic_interpolate by the time values.
func (Vector2) DirectionTo ¶
DirectionTo returns the normalized vector pointing from this vector to to. This is equivalent to using (b - a).Normalized().
func (Vector2) DistanceSquaredTo ¶
DistanceSquaredTo returns the squared distance between this vector and to.
This method runs faster than distance_to, so prefer it if you need to compare vectors or need the squared distance for some formula.
func (Vector2) DistanceTo ¶
DistanceTo returns the distance between this vector and to.
func (Vector2) Dot ¶
Dot returns the dot product of this vector and with. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
The dot product will be 0 for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
When using unit (normalized) vectors, the result will always be between -1.0 (180 degree angle) when the vectors are facing opposite directions, and 1.0 (0 degree angle) when the vectors are aligned.
Note: Vector2.Dot(a,b) is equivalent to Vector2.Dot(b,a)
func (Vector2) Floor ¶
Floor returns a new vector with all components rounded down (towards negative infinity).
func (Vector2) IsApproximatelyEqual ¶
IsAproximatelyEqual returns true if this vector and to are approximately equal, by running [IsAproximatelyEqual] on each component.
func (Vector2) IsApproximatelyZero ¶
IsAproximatelyZero returns true if this vector is approximately equal to Vector2.Zero.
func (Vector2) IsFinite ¶
IsFinite returns true if this vector is finite, by calling IsFinite on each component.
func (Vector2) IsNormalized ¶
IsNormalized returns true if the vector is normalized, i.e. its length is approximately equal to 1.
func (Vector2) LengthSquared ¶
LengthSquared returns the squared length (squared magnitude) of this vector.
func (Vector2) Lerp ¶
Lerp returns the result of the linear interpolation between this vector and to by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
func (Vector2) LimitLength ¶
LimitLength returns the vector with a maximum length by limiting its length to length.
func (Vector2) MaxAxis ¶
MaxAxis returns the axis of the vector's highest value. See Axis constants. If all components are equal, this method returns X.
func (Vector2) MinAxis ¶
MinAxis returns the axis of the vector's lowest value. See Axis constants. If all components are equal, this method returns Y.
func (Vector2) MoveToward ¶
MoveToward returns a new vector moved toward to by the fixed delta amount. Will not go past the final value.
func (Vector2) Normalized ¶
Normalized returns the result of scaling the vector to unit length. Equivalent to v / v.Length(). See also is_normalized.
Note: This function may return incorrect values if the input vector length is near zero.
func (Vector2) Orthogonal ¶
Orthogonal returns a perpendicular vector rotated 90 degrees counter-clockwise compared to the original, with the same length.
func (Vector2) Posmod ¶
Posmode returns a vector composed of the Fposmod of this vector's components and [Mod].
func (Vector2) PosmodVector ¶
Posmod returns a vector composed of the Fposmod of this vector's components and [Mod].
func (Vector2) Project ¶
Project returns the result of projecting the vector onto the given vector b.
func (Vector2) Reflect ¶
Reflect returns the result of reflecting the vector from a line defined by the given direction vector n.
func (Vector2) Round ¶
Round returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
func (Vector2) Sign ¶
Sign returns a new vector with each component set to 1.0 if it's positive, -1.0 if it's negative, and 0.0 if it's zero. The result is identical to calling Signf on each component.
func (Vector2) Slerp ¶
Slerp returns the result of spherical linear interpolation between this vector and to, by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like lerp.
func (Vector2) Slide ¶
Slide returns the result of sliding the vector along a plane defined by the given normal.
func (Vector2) Snapped ¶
Snapped returns a new vector with all components snapped to the nearest multiple of step.
func (Vector2) Transform ¶
func (v Vector2) Transform(t Transform2D) Vector2
func (Vector2) Vector2i ¶
Vector2i constructs a new Vector2i from the given Vector2 by truncating components' fractional parts (rounding towards zero). For a different behavior consider passing the result of Vector2.Ceil, Vector2.Floor or Vector2.Round to this constructor instead.
type Vector2i ¶
type Vector2i [2]int32
Vector2i is a 2-element structure that can be used to represent 2D grid coordinates or any other pair of integers.
It uses integer coordinates and is therefore preferable to Vector2 when exact precision is required. Note that the values are limited to 32 bits, and unlike Vector2 this cannot be configured with an engine build option. Use [Int] or [PackedInt64Array] if 64-bit values are needed.
Note: In a boolean context, a Vector2i will evaluate to false if it's equal to Vector2i{0, 0}. Otherwise, a Vector2i will always evaluate to true.
func (Vector2i) Abs ¶
Abs returns a new vector with all components in absolute values (i.e. positive).
func (Vector2i) Clamp ¶
Clamp returns a new vector with all components clamped between the components of min and max, by running clamp on each component.
func (Vector2i) LengthSquared ¶
LengthSquared returns the squared length (squared magnitude) of this vector.
This method runs faster than length, so prefer it if you need to compare vectors or need the squared distance for some formula.
func (Vector2i) MaxAxis ¶
MaxAxis returns the axis of the vector's highest value. See Axis constants. If all components are equal, this method returns X.
func (Vector2i) MinAxis ¶
MinAxis returns the axis of the vector's lowest value. See Axis constants. If all components are equal, this method returns Y.
func (Vector2i) Sign ¶
Sign returns a new vector with each component set to 1 if it's positive, -1 if it's negative, and 0 if it's zero. The result is identical to calling Signi on each component.
func (Vector2i) Snapped ¶
Snapped returns a new vector with each component snapped to the closest multiple of the corresponding component in step.
type Vector3 ¶
type Vector3 [3]float
Vector3 is a 3-element structure that can be used to represent 3D coordinates or any other triplet of numeric values.
It uses floating-point coordinates. By default, these floating-point values use 32-bit precision, unlike Float which is always 64-bit. If double precision is needed, compile the engine with the option precision=double.
See Vector3i for its integer counterpart.
Note: In a boolean context, a Vector3 will evaluate to false if it's equal to Vector3{0, 0, 0}. Otherwise, a Vector3 will always evaluate to true.
func NewVector3 ¶
NewVector3 constructs a new Vector3 from the given x, y, and z.
func (Vector3) Abs ¶
Abs returns a new vector with all components in absolute values (i.e. positive).
func (Vector3) AngleTo ¶
AngleTo returns the unsigned minimum angle to the given vector, in radians.
func (Vector3) BezierDerivative ¶
BezierDerivative returns the derivative at the given t on the Bézier curve defined by this vector and the given control_1, control_2, and end points.
func (Vector3) BezierInterpolate ¶
BezierInterpolate returns the point at the given t on the Bézier curve defined by this vector and the given control_1, control_2, and end points.
func (Vector3) Bounce ¶
Bounce returns the vector "bounced off" from a plane defined by the given normal.
func (Vector3) Ceil ¶
Ceil returns a new vector with all components rounded up (towards positive infinity).
func (Vector3) Clamp ¶
Clamp returns a new vector with all components clamped between the components of min and max, by running Clampf on each component.
func (Vector3) CubicInterpolate ¶
CubicInterpolate performs a cubic interpolation between this vector and b using pre_a and post_b as handles and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
func (Vector3) CubicInterpolateInTime ¶
func (v Vector3) CubicInterpolateInTime(b, preA, postB Vector3, weight, b_t, pre_a_t, post_b_t float64) Vector3
CubicInterpolateInTime performs a cubic interpolation between this vector and b using pre_a and post_b as handles and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
It can perform smoother interpolation than Vector3.CubicInterpolate by the time values.
func (Vector3) DirectionTo ¶
DirectionTo returns the normalized vector pointing from this vector to to. This is equivalent to using (b - a).Normalized().
func (Vector3) DistanceSquaredTo ¶
DistanceSquaredTo returns the squared distance between this vector and to.
This method runs faster than Vector3.DistanceTo, so prefer it if you need to compare vectors or need the squared distance for some formula.
func (Vector3) DistanceTo ¶
DistanceTo returns the distance between this vector and to.
func (Vector3) Dot ¶
Dot returns the dot product of this vector and with. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
The dot product will be 0 for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
When using unit (normalized) vectors, the result will always be between -1.0 (180 degree angle) when the vectors are facing opposite directions, and 1.0 (0 degree angle) when the vectors are aligned.
Note: a.Dot(b) is equivalent to b.Dot(a).
func (Vector3) Floor ¶
Floor returns a new vector with all components rounded down (towards negative infinity).
func (Vector3) Inverse ¶
Inverse returns the inverse of the vector. This is the same as Vector3{1/v[X],1/v[Y],1/v[Z]}.
func (Vector3) IsApproximatelyEqual ¶
IsApproximatelyEqual returns true if this vector and other are approximately equal, by running IsApproximatelyEqual on each component.
func (Vector3) IsApproximatelyZero ¶
IsApproximatelyZero returns true if this vector is approximately equal to zero, by running IsApproximatelyZero on each component.
func (Vector3) IsFinite ¶
IsFinite returns true if this vector's values are finite, by running IsFinite on each component.
func (Vector3) IsNormalized ¶
IsNormalized Returns true if the vector is normalized, i.e. its length is approximately equal to 1.
func (Vector3) LengthSquared ¶
LengthSquared returns the squared length (squared magnitude) of this vector.
This method runs faster than length, so prefer it if you need to compare vectors or need the squared distance for some formula.
func (Vector3) Lerp ¶
Lerp returns the result of the linear interpolation between this vector and to by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
func (Vector3) LimitLength ¶
LimitLength returns the vector with a maximum length by limiting its length to length.
func (Vector3) MODEL_BOTTOM ¶
func (Vector3) MODEL_FRONT ¶
func (Vector3) MODEL_LEFT ¶
func (Vector3) MODEL_REAR ¶
func (Vector3) MODEL_RIGHT ¶
func (Vector3) MaxAxis ¶
MaxAxis returns the axis of the vector's highest value. See Axis constants. If all components are equal, this method returns X.
func (Vector3) MinAxis ¶
MinAxis returns the axis of the vector's lowest value. See Axis constants. If all components are equal, this method returns Z.
func (Vector3) MoveToward ¶
MoveToward returns a new vector moved toward to by the fixed delta amount. Will not go past the final value.
func (Vector3) Normalized ¶
Normalized returns the result of scaling the vector to unit length. Equivalent to v / v.Length(). See also Vector3.IsNormalized.
Note: This function may return incorrect values if the input vector length is near zero.
func (Vector3) OctahedronDecode ¶
OctahedronDecode returns the Vector3 from an octahedral-compressed form created using OctahedronEncode (stored as a Vector2).
func (Vector3) OctahedronEncode ¶
OctahedronEncode returns the octahedral-encoded (oct32) form of this Vector3 as a Vector2. Since a Vector2 occupies 1/3 less memory compared to Vector3, this form of compression can be used to pass greater amounts of normalized [Vector3]s without increasing storage or memory requirements. See also Vector3.OctahedronDecode.
Note: OctahedronEncode can only be used for normalized vectors. OctahedronEncode does not check whether this Vector3 is normalized, and will return a value that does not decompress to the original value if the Vector3 is not normalized.
Note: Octahedral compression is lossy, although visual differences are rarely perceptible in real world scenarios.
func (Vector3) Posmodf ¶
Posmodf returns a vector composed of the Fposmod of this vector's components and mod.
func (Vector3) Posmodv ¶
Posmodv returns a vector composed of the Fposmod of this vector's components and mod.
func (Vector3) Project ¶
Project returns the result of projecting the vector onto the given vector b.
func (Vector3) Reflect ¶
Reflect returns the result of reflecting the vector from a plane defined by the given normal n.
func (Vector3) Rotated ¶
Rotated returns the result of rotating this vector around a given axis by angle (in radians). The axis must be a normalized vector.
func (Vector3) Round ¶
Round returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
func (Vector3) SignedAngleTo ¶
SignedAngleTo returns the signed angle to the given vector, in radians. The sign of the angle is positive in a counter-clockwise direction and negative in a clockwise direction when viewed from the side specified by the axis.
func (Vector3) Slerp ¶
Slerp returns the result of spherical linear interpolation between this vector and to, by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
This method also handles interpolating the lengths if the input vectors have different lengths. For the special case of one or both input vectors having zero length, this method behaves like lerp.
func (Vector3) Snapped ¶
Snapped returns a new vector with each component snapped to the nearest multiple of the corresponding component in step. This can also be used to round the components to an arbitrary number of decimals.
func (Vector3) Transform ¶
func (v Vector3) Transform(t Transform3D) Vector3
type Vector3i ¶
type Vector3i [3]int32
Vector3i is A 3-element structure that can be used to represent 3D grid coordinates or any other triplet of integers.
It uses integer coordinates and is therefore preferable to Vector3 when exact precision is required. Note that the values are limited to 32 bits, and unlike Vector3 this cannot be configured with an engine build option. Use [Int] or [PackedInt64Array] if 64-bit values are needed.
Note: In a boolean context, a Vector3i will evaluate to false if it's equal to Vector3i{0, 0, 0}. Otherwise, a Vector3i will always evaluate to true.
func (Vector3i) Abs ¶
Abs returns a new vector with all components in absolute values (i.e. positive).
func (Vector3i) Clamp ¶
Clamp returns a new vector with all components clamped between the components of min and max, by running Clampi on each component.
func (Vector3i) LengthSquared ¶
LengthSquared returns the squared length (squared magnitude) of this vector.
This method runs faster than length, so prefer it if you need to compare vectors or need the squared distance for some formula.
func (Vector3i) MaxAxis ¶
MaxAxis returns the axis of the vector's highest value. See Axis constants. If all components are equal, this method returns X.
func (Vector3i) MinAxis ¶
MinAxis returns the axis of the vector's lowest value. See Axis constants. If all components are equal, this method returns Z.
func (Vector3i) Sign ¶
Sign returns a new vector with each component set to 1 if it's positive, -1 if it's negative, and 0 if it's zero. The result is identical to calling Signi on each component.
type Vector4 ¶
type Vector4 [4]float
Vector4 A 4-element structure that can be used to represent 4D coordinates or any other quadruplet of numeric values.
It uses floating-point coordinates. By default, these floating-point values use 32-bit precision, unlike float which is always 64-bit. If double precision is needed, compile the engine with the option precision=double.
See Vector4i for its integer counterpart.
Note: In a boolean context, a Vector4 will evaluate to false if it's equal to Vector4{0, 0, 0, 0}. Otherwise, a Vector4 will always evaluate to true.
func NewVector4 ¶
NewVector4 constructs a new Vector4 from the given x, y, z, and w.
func (Vector4) Abs ¶
Abs returns a new vector with all components in absolute values (i.e. positive).
func (Vector4) Ceil ¶
Ceil returns a new vector with all components rounded up (towards positive infinity).
func (Vector4) Clamp ¶
Clamp returns a new vector with all components clamped between the components of min and max, by running Clampf on each component.
func (Vector4) CubicInterpolate ¶
CubicInterpolate performs a cubic interpolation between this vector and b using pre_a and post_b as handles and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
func (Vector4) CubicInterpolateInTime ¶
func (v Vector4) CubicInterpolateInTime(b, pre_a, post_b Vector4, weight, b_t, pre_a_t, post_b_t float64) Vector4
CubicInyerpolateInTime performs a cubic interpolation between this vector and b using pre_a and post_b as handles and returns the result at position weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
It can perform smoother interpolation than cubic_interpolate by the time values.
func (Vector4) DirectionTo ¶
DirectionTo returns the normalized vector pointing from this vector to to. This is equivalent to using (b - a).Normalized().
func (Vector4) DistanceSquaredTo ¶
DistanceSquaredTo returns the squared distance between this vector and to.
This method runs faster than DistanceTo, so prefer it if you need to compare vectors or need the squared distance for some formula.
func (Vector4) DistanceTo ¶
DistanceTo returns the distance between this vector and to.
func (Vector4) Floor ¶
Floor returns a new vector with all components rounded down (towards negative infinity).
func (Vector4) Inverse ¶
Inverse returns the inverse of the vector. This is the same as
Vector4{1.0 / v[X], 1.0 / v[Y], 1.0 / v[Z], 1.0 / v[W]}.
func (Vector4) IsApproximatelyEqual ¶
IsApproximatelyEqual returns true if this vector and to are approximately equal, by running IsApproximatelyEqual on each component.
func (Vector4) IsApproximatelyZero ¶
IsApproximatelyZero returns true if this vector's values are approximately zero, by running IsApproximatelyZero on each component.
This method is faster than using is_equal_approx with one value as a zero vector.
func (Vector4) IsFinite ¶
IsFinite returns true if this vector is finite, by calling IsFinite on each component.
func (Vector4) IsNormalized ¶
IsNormalized returns true if this vector is normalized, by checking if its length is approximately 1.0.
func (Vector4) LengthSquared ¶
LengthSquared returns the squared length (squared magnitude) of this vector.
func (Vector4) Lerp ¶
Lerp returns the result of the linear interpolation between this vector and to by amount weight. weight is on the range of 0.0 to 1.0, representing the amount of interpolation.
func (Vector4) MaxAxis ¶
MaxAxis returns the axis of the vector's highest value. See Axis constants. If all components are equal, this method returns X.
func (Vector4) MinAxis ¶
MinAxis returns the axis of the vector's lowest value. See Axis constants. If all components are equal, this method returns W.
func (Vector4) Normalized ¶
Normalized returns the result of scaling the vector to unit length. Equivalent to v / v.length(). See also Vector4.IsNormalized.
Note: This function may return incorrect values if the input vector length is near zero.
func (Vector4) Posmodf ¶
Posmod returns a vector composed of the Fposmod of this vector's components and mod.
func (Vector4) Posmodv ¶
Posmod returns a vector composed of the Fposmod of this vector's components and modv's components.
func (Vector4) Round ¶
Round returns a new vector with all components rounded to the nearest integer, with halfway cases rounded away from zero.
func (Vector4) Sign ¶
Sign returns a new vector with each component set to 1.0 if it's positive, -1.0 if it's negative, and 0.0 if it's zero. The result is identical to calling Signf on each component.
func (Vector4) Snapped ¶
Snapped returns a new vector with all components snapped to the nearest multiple of step. This can also be used to round the components to an arbitrary number of decimals.
func (Vector4) Transform ¶
func (v Vector4) Transform(p Projection) Vector4
Transform transform transforms (multiplies) the Vector4 by the given Projection's transformation matrix.
type Vector4i ¶
type Vector4i [4]int32
Vector4i is a 4-element structure that can be used to represent 4D grid coordinates or any other quadruplet of integers.
It uses integer coordinates and is therefore preferable to Vector4 when exact precision is required. Note that the values are limited to 32 bits, and unlike Vector4 this cannot be configured with an engine build option. Use [Int] or [PackedInt64Array] if 64-bit values are needed.
Note: In a boolean context, a Vector4i will evaluate to false if it's equal to Vector4i{0, 0, 0, 0}. Otherwise, a Vector3i will always evaluate to true.
func (Vector4i) Abs ¶
Abs returns a new vector with all components in absolute values (i.e. positive).
func (Vector4i) Clamp ¶
Clamp returns a new vector with all components clamped between the components of min and max, by running Clampi on each component.
func (Vector4i) LengthSquared ¶
LengthSquared returns the squared length (squared magnitude) of this vector.
This method runs faster than Vector4i.Length, so prefer it if you need to compare vectors or need the squared distance for some formula.
func (Vector4i) MaxAxis ¶
MaxAxis returns the axis of the vector's highest value. See Axis constants. If all components are equal, this method returns X.
func (Vector4i) MinAxis ¶
MinAxis returns the axis of the vector's lowest value. See Axis constants. If all components are equal, this method returns W.
func (Vector4i) Sign ¶
Sign returns a new vector with each component set to 1 if it's positive, -1 if it's negative, and 0 if it's 0. The result is identical to running Signi on each component.