Documentation
¶
Index ¶
- Constants
- func Absf[T ~float32 | ~float64](x T) T
- func Absi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x T) T
- func Acos[T ~float32 | ~float64](x T) float64
- func Acosh[T ~float32 | ~float64](x T) float64
- func AngleDifference[T ~float32 | ~float64](from, to T) T
- func Asin[T ~float32 | ~float64](x T) float64
- func Asinh[T ~float32 | ~float64](x T) float64
- func Atan[T ~float32 | ~float64](x T) float64
- func Atan2[T ~float32 | ~float64](y, x T) float64
- func Atanh[T ~float32 | ~float64](x T) float64
- 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 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 Clamp01f[T ~float32 | ~float64](value T) T
- func Clamp01i[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](value 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 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 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 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 Roundf[T ~float32 | ~float64](x T) T
- func Roundi[T ~int8 | ~int16 | ~int32 | ~int64 | ~int](x 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 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
- type Color
- func ColorBlack() Color
- func ColorBlue() Color
- func ColorCyan() Color
- func ColorGreen() Color
- func ColorMagenta() Color
- func ColorRed() Color
- func ColorTransparent() Color
- func ColorWhite() Color
- func ColorYellow() Color
- func LerpColor(from Color, to Color, t float64) Color
- func NewColor(r, g, b, a float64) Color
- func NewColorAny(s interface{}) (Color, error)
- func NewColorHSV(h, s, v float64) Color
- func NewColorRGB(r, g, b float64) Color
- func NewColorRGBA(r, g, b, a float64) Color
- func NewColorRGBAi(r, g, b, a uint8) Color
- func NewColorRGBi(r, g, b uint8) Color
- func RandomColor() Color
- func (c Color) Add(other Color) Color
- func (c Color) Clamp() Color
- func (c *Color) FromHSV(h, s, v float64)
- func (c Color) Invert() Color
- func (c Color) Lerp(to Color, t float64) Color
- func (c Color) Mul(other Color) Color
- func (c Color) Mulf(f float64) Color
- func (c *Color) ScaleBrightness(scale float64)
- func (val Color) String() string
- func (c Color) Sub(other Color) Color
- func (c *Color) ToHSV() (h, s, v float64)
- type Float
- type Int
- type Matrix3
- func (pself *Matrix3) Add(otherMat *Matrix3) *Matrix3
- func (pself *Matrix3) Addf(value float64) *Matrix3
- func (pself *Matrix3) Clone() *Matrix3
- func (pself *Matrix3) Div(otherMat *Matrix3) *Matrix3
- func (pself *Matrix3) Divf(value float64) *Matrix3
- func (pself *Matrix3) Equals(otherMat *Matrix3) bool
- func (pself *Matrix3) Get(row int, col int) float64
- func (pself *Matrix3) Mul(value Matrix3) *Matrix3
- func (pself *Matrix3) Mulv(value Vec2) Vec2
- func (pself *Matrix3) Scale(otherMat *Matrix3) *Matrix3
- func (pself *Matrix3) Scalef(value float64) *Matrix3
- func (pself *Matrix3) Set(row int, col int, value float64)
- func (pself *Matrix3) String() string
- func (pself *Matrix3) Sub(otherMat *Matrix3) *Matrix3
- func (pself *Matrix3) Subf(value float64) *Matrix3
- type Quaternion
- func (q Quaternion) Add(other Quaternion) Quaternion
- func (q Quaternion) Conjugate() Quaternion
- func (q Quaternion) Dot(other Quaternion) float64
- func (q Quaternion) GetEuler() Vec3
- func (q Quaternion) Inverse() Quaternion
- func (q Quaternion) IsFinite() bool
- func (q Quaternion) IsNormalized() bool
- func (q Quaternion) Length() float64
- func (q Quaternion) LengthSquared() float64
- func (q Quaternion) Lerp(to Quaternion, weight float64) Quaternion
- func (q Quaternion) Lerpf(to Quaternion, weight float64) Quaternion
- func (q Quaternion) Mul(other Quaternion) Quaternion
- func (q Quaternion) Mulf(f float64) Quaternion
- func (q Quaternion) Neg() Quaternion
- func (q Quaternion) Normalize() Quaternion
- func (q Quaternion) RotateVec3(v Vec3) Vec3
- func (q Quaternion) Slerp(to Quaternion, weight float64) Quaternion
- func (q Quaternion) Slerpf(to Quaternion, weight float64) Quaternion
- func (q Quaternion) String() string
- func (q Quaternion) Sub(other Quaternion) Quaternion
- type Rect2
- func (r Rect2) Abs() Rect2
- func (r Rect2) Area() float64
- func (r Rect2) Center() Vec2
- func (r Rect2) Encloses(b Rect2) bool
- func (r *Rect2) End() Vec2
- func (r Rect2) Expand(to Vec2) 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 Vec2) bool
- func (r Rect2) Intersection(b Rect2) Rect2
- func (r Rect2) Intersects(b Rect2, includeBorders bool) bool
- func (r Rect2) Merge(b Rect2) Rect2
- func (r Rect2) Rect2i() Rect2i
- func (r *Rect2) SetEnd(end Vec2)
- func (r Rect2) String() string
- type Rect2i
- func (r *Rect2i) Abs() Rect2i
- func (r *Rect2i) Area() int64
- func (r *Rect2i) Center() Vec2i
- func (r *Rect2i) Encloses(b Rect2i) bool
- func (r *Rect2i) End() Vec2i
- func (r *Rect2i) Expand(to Vec2i) 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 Vec2i) bool
- func (r *Rect2i) Intersection(b Rect2i) Rect2i
- func (r *Rect2i) Intersects(b Rect2i, includeBorders bool) bool
- func (r *Rect2i) Merge(b Rect2i) Rect2i
- func (r *Rect2i) Rect2() Rect2
- func (r *Rect2i) SetEnd(end Vec2i)
- func (r Rect2i) String() string
- type Side
- type Vec2
- func (v Vec2) Abs() Vec2
- func (v Vec2) Add(other Vec2) Vec2
- func (v Vec2) Addf(f float64) Vec2
- func (v Vec2) Ceil() Vec2
- func (v Vec2) Clamp(min, max Vec2) Vec2
- func (v Vec2) Cross(other Vec2) float64
- func (v Vec2) DistanceSquaredTo(other Vec2) float64
- func (v Vec2) DistanceTo(other Vec2) float64
- func (v Vec2) Div(other Vec2) Vec2
- func (v Vec2) Divf(f float64) Vec2
- func (v Vec2) Dot(other Vec2) float64
- func (v Vec2) Floor() Vec2
- func (v Vec2) IsApproximatelyZero() bool
- func (v Vec2) IsFinite() bool
- func (v Vec2) IsNormalized() bool
- func (v Vec2) Length() float64
- func (v Vec2) LengthSquared() float64
- func (v Vec2) Lerp(to Vec2, weight float64) Vec2
- func (v Vec2) Lerpf(to Vec2, weight float64) Vec2
- func (v Vec2) Mul(other Vec2) Vec2
- func (v Vec2) Mulf(f float64) Vec2
- func (v Vec2) Neg() Vec2
- func (v Vec2) Normalize() Vec2
- func (v Vec2) Round() Vec2
- func (v Vec2) Sign() Vec2
- func (v Vec2) String() string
- func (v Vec2) Sub(other Vec2) Vec2
- func (v Vec2) Subf(f float64) Vec2
- type Vec2i
- func (v Vec2i) Abs() Vec2i
- func (v Vec2i) Add(other Vec2i) Vec2i
- func (v Vec2i) Addi(i int) Vec2i
- func (v Vec2i) Clamp(min, max Vec2i) Vec2i
- func (v Vec2i) DistanceSquaredTo(other Vec2i) float64
- func (v Vec2i) DistanceTo(other Vec2i) float64
- func (v Vec2i) Div(other Vec2i) Vec2i
- func (v Vec2i) Divi(i int) Vec2i
- func (v Vec2i) Dot(other Vec2i) float64
- func (v Vec2i) Length() float64
- func (v Vec2i) LengthSquared() float64
- func (v Vec2i) Mul(other Vec2i) Vec2i
- func (v Vec2i) Muli(i int) Vec2i
- func (v Vec2i) Neg() Vec2i
- func (v Vec2i) Sign() Vec2i
- func (v Vec2i) String() string
- func (v Vec2i) Sub(other Vec2i) Vec2i
- func (v Vec2i) Subi(i int) Vec2i
- type Vec3
- func (v *Vec3) Abs() Vec3
- func (v *Vec3) Add(other Vec3) Vec3
- func (v *Vec3) Addf(f float64) Vec3
- func (v *Vec3) Ceil() Vec3
- func (v *Vec3) Clamp(min, max Vec3) Vec3
- func (v *Vec3) Cross(other Vec3) Vec3
- func (v *Vec3) DistanceSquaredTo(other Vec3) float64
- func (v *Vec3) DistanceTo(other Vec3) float64
- func (v *Vec3) Div(other Vec3) Vec3
- func (v *Vec3) Divf(f float64) Vec3
- func (v *Vec3) Dot(other Vec3) float64
- func (v *Vec3) Floor() Vec3
- func (v *Vec3) IsApproximatelyZero() bool
- func (v *Vec3) IsFinite() bool
- func (v *Vec3) IsNormalized() bool
- func (v *Vec3) Length() float64
- func (v *Vec3) LengthSquared() float64
- func (v *Vec3) Lerp(to Vec3, weight float64) Vec3
- func (v *Vec3) Lerpf(to Vec3, weight float64) Vec3
- func (v *Vec3) Mul(other Vec3) Vec3
- func (v *Vec3) Mulf(f float64) Vec3
- func (v *Vec3) Neg() Vec3
- func (v *Vec3) Normalize() Vec3
- func (v *Vec3) Round() Vec3
- func (v Vec3) String() string
- func (v *Vec3) Sub(other Vec3) Vec3
- func (v *Vec3) Subf(f float64) Vec3
- type Vec3i
- func (v Vec3i) Abs() Vec3i
- func (v Vec3i) Add(other Vec3i) Vec3i
- func (v Vec3i) Addi(i int) Vec3i
- func (v Vec3i) Clamp(min, max Vec3i) Vec3i
- func (v Vec3i) Cross(other Vec3i) Vec3i
- func (v Vec3i) DistanceSquaredTo(other Vec3i) float64
- func (v Vec3i) DistanceTo(other Vec3i) float64
- func (v Vec3i) Div(other Vec3i) Vec3i
- func (v Vec3i) Divi(i int) Vec3i
- func (v Vec3i) Dot(other Vec3i) float64
- func (v Vec3i) Length() float64
- func (v Vec3i) LengthSquared() float64
- func (v Vec3i) Mul(other Vec3i) Vec3i
- func (v Vec3i) Muli(i int) Vec3i
- func (v Vec3i) Neg() Vec3i
- func (v Vec3i) Sign() Vec3i
- func (v Vec3i) String() string
- func (v Vec3i) Sub(other Vec3i) Vec3i
- func (v Vec3i) Subi(i int) Vec3i
- type Vec4
- func (v *Vec4) Abs() Vec4
- func (v *Vec4) Add(other Vec4) Vec4
- func (v *Vec4) Addf(f float64) Vec4
- func (v *Vec4) Ceil() Vec4
- func (v *Vec4) Clamp(min, max Vec4) Vec4
- func (v *Vec4) DistanceSquaredTo(other Vec4) float64
- func (v *Vec4) DistanceTo(other Vec4) float64
- func (v *Vec4) Div(other Vec4) Vec4
- func (v *Vec4) Divf(f float64) Vec4
- func (v *Vec4) Dot(other Vec4) float64
- func (v *Vec4) Floor() Vec4
- func (v *Vec4) IsApproximatelyZero() bool
- func (v *Vec4) IsFinite() bool
- func (v *Vec4) IsNormalized() bool
- func (v *Vec4) Length() float64
- func (v *Vec4) LengthSquared() float64
- func (v *Vec4) Lerp(to Vec4, weight float64) Vec4
- func (v *Vec4) Lerpf(to Vec4, weight float64) Vec4
- func (v *Vec4) Mul(other Vec4) Vec4
- func (v *Vec4) Mulf(f float64) Vec4
- func (v *Vec4) Neg() Vec4
- func (v Vec4) Normalize() Vec4
- func (v *Vec4) Round() Vec4
- func (v *Vec4) Sign() Vec4
- func (v Vec4) String() string
- func (v *Vec4) Sub(other Vec4) Vec4
- func (v *Vec4) Subf(f float64) Vec4
- type Vec4i
- func (v Vec4i) Abs() Vec4i
- func (v Vec4i) Add(other Vec4i) Vec4i
- func (v Vec4i) Addi(i int) Vec4i
- func (v Vec4i) Clamp(min, max Vec4i) Vec4i
- func (v Vec4i) DistanceSquaredTo(other Vec4i) float64
- func (v Vec4i) DistanceTo(other Vec4i) float64
- func (v Vec4i) Div(other Vec4i) Vec4i
- func (v Vec4i) Divi(i int) Vec4i
- func (v Vec4i) Dot(other Vec4i) float64
- func (v Vec4i) Length() float64
- func (v Vec4i) LengthSquared() float64
- func (v Vec4i) Mul(other Vec4i) Vec4i
- func (v Vec4i) Muli(i int) Vec4i
- func (v Vec4i) Neg() Vec4i
- func (v Vec4i) Sign() Vec4i
- func (v Vec4i) String() string
- func (v Vec4i) Sub(other Vec4i) Vec4i
- func (v Vec4i) Subi(i int) Vec4i
Constants ¶
const ( Pi = math.Pi Tau = math.Pi * 2 )
Variables ¶
This section is empty.
Functions ¶
func Acos ¶
Acos returns the arc cosine of x in float64. 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 float64. 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 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 Asin ¶
Asin returns the arc sine of x in float64. 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 float64. Use it to get the angle from an angle's sine in hyperbolic space.
func Atan ¶
Atan returns the arc tangent of x in float64. 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 float64. 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 float64. 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.
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 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 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 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 LerpAngle ¶
LerpAngle linearly interpolates between two angles (in float64) 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 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 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 Color ¶
type Color struct {
R, G, B, A float64
}
func ColorBlack ¶
func ColorBlack() Color
func ColorGreen ¶
func ColorGreen() Color
func ColorMagenta ¶
func ColorMagenta() Color
func ColorTransparent ¶
func ColorTransparent() Color
func ColorWhite ¶
func ColorWhite() Color
func ColorYellow ¶
func ColorYellow() Color
func NewColorAny ¶
New a color, s can be int, float64 or string
func NewColorHSV ¶
func NewColorRGB ¶
func NewColorRGBA ¶
func NewColorRGBAi ¶
func NewColorRGBi ¶
func (*Color) FromHSV ¶
HSV2RGB converts hue (0-360), saturation (0-1), and brightness (0-1) to RGB.
func (*Color) ScaleBrightness ¶
ScaleBrightness changes color brightness.
type Matrix3 ¶
type Matrix3 [9]Float
func NewMatrix3Indentity ¶
func NewMatrix3Indentity() *Matrix3
func NewMatrix3Zero ¶
func NewMatrix3Zero() *Matrix3
type Quaternion ¶
type Quaternion struct {
X, Y, Z, W Float
}
func NewQuaternion ¶
func NewQuaternion(x, y, z, w float64) Quaternion
func NewQuaternionFromAxisAngle ¶
func NewQuaternionFromAxisAngle(axis Vec3, angle float64) Quaternion
func (Quaternion) Add ¶
func (q Quaternion) Add(other Quaternion) Quaternion
func (Quaternion) Conjugate ¶
func (q Quaternion) Conjugate() Quaternion
func (Quaternion) Dot ¶
func (q Quaternion) Dot(other Quaternion) float64
func (Quaternion) GetEuler ¶
func (q Quaternion) GetEuler() Vec3
func (Quaternion) Inverse ¶
func (q Quaternion) Inverse() Quaternion
func (Quaternion) IsFinite ¶
func (q Quaternion) IsFinite() bool
func (Quaternion) IsNormalized ¶
func (q Quaternion) IsNormalized() bool
func (Quaternion) Length ¶
func (q Quaternion) Length() float64
func (Quaternion) LengthSquared ¶
func (q Quaternion) LengthSquared() float64
func (Quaternion) Lerp ¶
func (q Quaternion) Lerp(to Quaternion, weight float64) Quaternion
func (Quaternion) Lerpf ¶
func (q Quaternion) Lerpf(to Quaternion, weight float64) Quaternion
func (Quaternion) Mul ¶
func (q Quaternion) Mul(other Quaternion) Quaternion
func (Quaternion) Mulf ¶
func (q Quaternion) Mulf(f float64) Quaternion
func (Quaternion) Neg ¶
func (q Quaternion) Neg() Quaternion
func (Quaternion) Normalize ¶
func (q Quaternion) Normalize() Quaternion
func (Quaternion) RotateVec3 ¶
func (q Quaternion) RotateVec3(v Vec3) Vec3
func (Quaternion) Slerp ¶
func (q Quaternion) Slerp(to Quaternion, weight float64) Quaternion
func (Quaternion) Slerpf ¶
func (q Quaternion) Slerpf(to Quaternion, weight float64) Quaternion
func (Quaternion) String ¶
func (q Quaternion) String() string
func (Quaternion) Sub ¶
func (q Quaternion) Sub(other Quaternion) Quaternion
type Vec2 ¶
type Vec2 struct {
X, Y Float
}
func (Vec2) DistanceSquaredTo ¶
func (Vec2) DistanceTo ¶
func (Vec2) IsApproximatelyZero ¶
func (Vec2) IsNormalized ¶
func (Vec2) LengthSquared ¶
type Vec2i ¶
type Vec2i struct {
X, Y Int
}
func (Vec2i) DistanceSquaredTo ¶
func (Vec2i) DistanceTo ¶
func (Vec2i) LengthSquared ¶
type Vec3 ¶
type Vec3 struct {
X, Y, Z Float
}
func NewVec3FromImpl ¶
func (*Vec3) DistanceSquaredTo ¶
func (*Vec3) DistanceTo ¶
func (*Vec3) IsApproximatelyZero ¶
func (*Vec3) IsNormalized ¶
func (*Vec3) LengthSquared ¶
type Vec3i ¶
type Vec3i struct {
X, Y, Z Int
}
func (Vec3i) DistanceSquaredTo ¶
func (Vec3i) DistanceTo ¶
func (Vec3i) LengthSquared ¶
type Vec4 ¶
type Vec4 struct {
X, Y, Z, W Float
}
func (*Vec4) DistanceSquaredTo ¶
func (*Vec4) DistanceTo ¶
func (*Vec4) IsApproximatelyZero ¶
func (*Vec4) IsNormalized ¶
func (*Vec4) LengthSquared ¶
type Vec4i ¶
type Vec4i struct {
X, Y, Z, W Int
}