gmath

package
v0.0.0-...-55a4dde Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DegToRad

func DegToRad[T constraints.Float](d T) T

func Morton2u32

func Morton2u32(x, y uint16) uint32

func Morton3u32

func Morton3u32(x, y, z uint16) uint32

10 bits per value so max value is 1023

func RadToDeg

func RadToDeg[T constraints.Float](r T) T

Types

type Bounds3f

type Bounds3f[T constraints.Float] struct {
	Min Vector3f[T]
	Max Vector3f[T]
}

type Bounds3f32

type Bounds3f32 = Bounds3f[float32]

type Bounds3f64

type Bounds3f64 = Bounds3f[float64]

type Bounds3i

type Bounds3i[T constraints.Integer] struct {
	Min Vector3i[T]
	Max Vector3i[T]
}

type Bounds3i32

type Bounds3i32 = Bounds3i[int32]

type Bounds3i64

type Bounds3i64 = Bounds3i[int64]

type Bounds3int

type Bounds3int = Bounds3i[int]

type Camera

type Camera[T constraints.Float] interface {
	ScreenPointToRay(x, y int) Ray[T]

	ViewMatrix() Matrix4x4f[T]
	ViewInverseMatrix() Matrix4x4f[T]

	ProjectionMatrix() Matrix4x4f[T]
	ProjectionInverseMatrix() Matrix4x4f[T]
}

type Cameraf32

type Cameraf32 = Camera[float32]

type Cameraf64

type Cameraf64 = Camera[float64]

type Extent3

type Extent3[T constraints.Integer | constraints.Float] struct {
	X, Y, Z T
}

func (Extent3[T]) Area

func (e Extent3[T]) Area() T

type Extent3f32

type Extent3f32 = Extent3[float32]

type Extent3f64

type Extent3f64 = Extent3[float64]

type Extent3i32

type Extent3i32 = Extent3[int32]

type Extent3i64

type Extent3i64 = Extent3[int64]

type Extent3int

type Extent3int = Extent3[int]

type Extent3u32

type Extent3u32 = Extent3[uint32]

type Extent3u64

type Extent3u64 = Extent3[uint64]

type Extent3uint

type Extent3uint = Extent3[uint]

type Grid

type Grid[T constraints.Float, U constraints.Integer] struct {
	Pos        Point3f[T]
	Bounds     Bounds3f[T]
	Scale      T
	CellBounds Bounds3i[U]
}

func (*Grid[T, U]) CellToWorldPos

func (g *Grid[T, U]) CellToWorldPos(gc GridCell[U]) Point3f[T]

func (*Grid[T, U]) Init

func (g *Grid[T, U]) Init(cellCount Vector3i[U], cellSize T)

func (*Grid[T, U]) WorldPosToCell

func (g *Grid[T, U]) WorldPosToCell(p Point3f[T]) GridCell[U]

type Grid32

type Grid32 = Grid[float32, int32]

type Grid64

type Grid64 = Grid[float64, int64]

type GridCell

type GridCell[T constraints.Integer] struct {
	X T
	Y T
	Z T
}

func (GridCell[T]) Clamp

func (gc GridCell[T]) Clamp(bounds Bounds3i[T]) GridCell[T]

func (GridCell[T]) ToArray

func (gc GridCell[T]) ToArray() [3]T

type GridCelli32

type GridCelli32 = GridCell[int32]

type GridCelli64

type GridCelli64 = GridCell[int64]

type Matrix4x4f

type Matrix4x4f[T constraints.Float] [4][4]T

func (Matrix4x4f[T]) Invert

func (m Matrix4x4f[T]) Invert() Matrix4x4f[T]

func (Matrix4x4f[T]) Multiply

func (m Matrix4x4f[T]) Multiply(m2 Matrix4x4f[T]) Matrix4x4f[T]

func (Matrix4x4f[T]) ToArrayf32

func (m Matrix4x4f[T]) ToArrayf32() [4][4]float32

func (Matrix4x4f[T]) Transpose

func (m Matrix4x4f[T]) Transpose() Matrix4x4f[T]

func (Matrix4x4f[T]) TransposedToArrayf32

func (m Matrix4x4f[T]) TransposedToArrayf32() [4][4]float32

type Matrix4x4f32

type Matrix4x4f32 = Matrix4x4f[float32]

type Matrix4x4f64

type Matrix4x4f64 = Matrix4x4f[float64]

type PerspectiveCamera

type PerspectiveCamera[T constraints.Float] struct {
	Transform[T]

	SizeX T
	SizeY T
	FOV   T

	ZNear T
}

func (*PerspectiveCamera[T]) ProjectionInverseMatrix

func (c *PerspectiveCamera[T]) ProjectionInverseMatrix() Matrix4x4f[T]

func (*PerspectiveCamera[T]) ProjectionMatrix

func (c *PerspectiveCamera[T]) ProjectionMatrix() Matrix4x4f[T]

func (*PerspectiveCamera[T]) ScreenPointToRay

func (c *PerspectiveCamera[T]) ScreenPointToRay(x, y int) Ray[T]

func (*PerspectiveCamera[T]) ViewInverseMatrix

func (c *PerspectiveCamera[T]) ViewInverseMatrix() Matrix4x4f[T]

func (*PerspectiveCamera[T]) ViewMatrix

func (c *PerspectiveCamera[T]) ViewMatrix() Matrix4x4f[T]

type PerspectiveCameraf32

type PerspectiveCameraf32 = PerspectiveCamera[float32]

type PerspectiveCameraf64

type PerspectiveCameraf64 = PerspectiveCamera[float64]

type Point3f

type Point3f[T constraints.Float] struct {
	X, Y, Z T
}

func Point3fFromArray

func Point3fFromArray[T constraints.Float](a [3]T) Point3f[T]

func (Point3f[T]) Add

func (p Point3f[T]) Add(v Vector3f[T]) Point3f[T]

func (Point3f[T]) IsNAN

func (p Point3f[T]) IsNAN() bool

func (Point3f[T]) Subtract

func (p Point3f[T]) Subtract(v Vector3f[T]) Point3f[T]

func (Point3f[T]) ToArray

func (p Point3f[T]) ToArray() [3]T

func (Point3f[T]) ToArrayf32

func (p Point3f[T]) ToArrayf32() [3]float32

func (Point3f[T]) VectorTo

func (p Point3f[T]) VectorTo(p2 Point3f[T]) Vector3f[T]

type Point3f32

type Point3f32 = Point3f[float32]

type Point3f64

type Point3f64 = Point3f[float64]

type Point3i

type Point3i[T constraints.Integer] struct {
	X, Y, Z T
}

func Point3iFromArray

func Point3iFromArray[T constraints.Integer](a [3]T) Point3i[T]

func (Point3i[T]) Add

func (p Point3i[T]) Add(v Vector3i[T]) Point3i[T]

func (Point3i[T]) Subtract

func (p Point3i[T]) Subtract(v Vector3i[T]) Point3i[T]

func (Point3i[T]) ToArray

func (p Point3i[T]) ToArray() [3]T

func (Point3i[T]) VectorTo

func (p Point3i[T]) VectorTo(p2 Point3i[T]) Vector3i[T]

type Point3i32

type Point3i32 = Point3i[int32]

type Point3i64

type Point3i64 = Point3i[int64]

type Point3int

type Point3int = Point3i[int]

type Quaternion

type Quaternion[T constraints.Float] struct {
	X, Y, Z, W T
}

func QuaternionFromAngleAxis

func QuaternionFromAngleAxis[T constraints.Float](t T, axis Vector3f[T]) Quaternion[T]

func QuaternionFromEuler

func QuaternionFromEuler[T constraints.Float](x, y, z T) Quaternion[T]

QuaternionFromEuler is creates a quaternion from euler rotation in the z x y order.

func (Quaternion[T]) Magnitude

func (q Quaternion[T]) Magnitude() T

func (Quaternion[T]) Multiply

func (q Quaternion[T]) Multiply(q2 Quaternion[T]) Quaternion[T]

func (Quaternion[T]) Normalize

func (q Quaternion[T]) Normalize() Quaternion[T]

func (Quaternion[T]) Rotate

func (q Quaternion[T]) Rotate(v Vector3f[T]) Vector3f[T]

type Quaternionf32

type Quaternionf32 = Quaternion[float32]

type Quaternionf64

type Quaternionf64 = Quaternion[float64]

type Ray

type Ray[T constraints.Float] struct {
	Dir    Vector3f[T]
	InvDir Vector3f[T]
	Org    Point3f[T]
}

func (*Ray[T]) IntersectionAABB

func (r *Ray[T]) IntersectionAABB(p Point3f[T], b Bounds3f[T]) T

type Rayf32

type Rayf32 = Ray[float32]

type Rayf64

type Rayf64 = Ray[float64]

type Rect

type Rect[T constraints.Integer | constraints.Float] struct {
	X, Y, W, H T
}

type Rectf32

type Rectf32 = Rect[float32]

type Rectf64

type Rectf64 = Rect[float64]

type Recti32

type Recti32 = Rect[int32]

type Recti64

type Recti64 = Rect[int64]

type Rectint

type Rectint = Rect[int]

type Transform

type Transform[T constraints.Float] struct {
	Pos   Point3f[T]
	Rot   Quaternion[T]
	Scale Vector3f[T]
	Pivot Point3f[T]
}

func (*Transform[T]) LookAt

func (t *Transform[T]) LookAt(up Vector3f[T], target Point3f[T])

func (*Transform[T]) ModelInverseMatrix

func (t *Transform[T]) ModelInverseMatrix() Matrix4x4f[T]

func (*Transform[T]) ModelMatrix

func (t *Transform[T]) ModelMatrix() Matrix4x4f[T]

func (*Transform[T]) PivotMatrix

func (t *Transform[T]) PivotMatrix() Matrix4x4f[T]

func (*Transform[T]) RotationMatrix

func (t *Transform[T]) RotationMatrix() Matrix4x4f[T]

func (*Transform[T]) ScaleMatrix

func (t *Transform[T]) ScaleMatrix() Matrix4x4f[T]

func (*Transform[T]) TransformDirection

func (t *Transform[T]) TransformDirection(v Vector3f[T]) Vector3f[T]

func (*Transform[T]) TransformPoint

func (t *Transform[T]) TransformPoint(p Point3f[T]) Point3f[T]

func (*Transform[T]) TransformVector

func (t *Transform[T]) TransformVector(v Vector3f[T]) Vector3f[T]

func (*Transform[T]) TranslationMatrix

func (t *Transform[T]) TranslationMatrix() Matrix4x4f[T]

type Transformf32

type Transformf32 = Transform[float32]

type Transformf64

type Transformf64 = Transform[float64]

type Vector3f

type Vector3f[T constraints.Float] struct {
	X, Y, Z T
}

func Vector3fFromArray

func Vector3fFromArray[T constraints.Float](a [3]T) Vector3f[T]

func (Vector3f[T]) Abs

func (v Vector3f[T]) Abs() Vector3f[T]

func (Vector3f[T]) Add

func (v Vector3f[T]) Add(v2 Vector3f[T]) Vector3f[T]

func (Vector3f[T]) AddUniform

func (v Vector3f[T]) AddUniform(f T) Vector3f[T]

func (Vector3f[T]) Angle

func (v Vector3f[T]) Angle(v2 Vector3f[T]) T

func (Vector3f[T]) AngleAxis

func (v Vector3f[T]) AngleAxis(v2 Vector3f[T]) (T, Vector3f[T])

func (Vector3f[T]) Clamp

func (v Vector3f[T]) Clamp(lo, hi Vector3f[T]) Vector3f[T]

func (Vector3f[T]) Cross

func (v Vector3f[T]) Cross(v2 Vector3f[T]) Vector3f[T]

func (Vector3f[T]) Dot

func (v Vector3f[T]) Dot(v2 Vector3f[T]) T

func (Vector3f[T]) IsNAN

func (v Vector3f[T]) IsNAN() bool

func (Vector3f[T]) Magnitude

func (v Vector3f[T]) Magnitude() T

func (Vector3f[T]) Max

func (v Vector3f[T]) Max(v2 Vector3f[T]) Vector3f[T]

func (Vector3f[T]) Min

func (v Vector3f[T]) Min(v2 Vector3f[T]) Vector3f[T]

func (Vector3f[T]) Normalize

func (v Vector3f[T]) Normalize() Vector3f[T]

func (Vector3f[T]) OrthoNormalize

func (v Vector3f[T]) OrthoNormalize(tangent Vector3f[T]) Vector3f[T]

func (Vector3f[T]) Scale

func (v Vector3f[T]) Scale(v2 Vector3f[T]) Vector3f[T]

func (Vector3f[T]) ScaleInverse

func (v Vector3f[T]) ScaleInverse(v2 Vector3f[T]) Vector3f[T]

func (Vector3f[T]) ScaleInverseUniform

func (v Vector3f[T]) ScaleInverseUniform(s T) Vector3f[T]

func (Vector3f[T]) ScaleUniform

func (v Vector3f[T]) ScaleUniform(s T) Vector3f[T]

func (Vector3f[T]) Subtract

func (v Vector3f[T]) Subtract(v2 Vector3f[T]) Vector3f[T]

func (Vector3f[T]) SubtractUniform

func (v Vector3f[T]) SubtractUniform(f T) Vector3f[T]

func (Vector3f[T]) ToArray

func (v Vector3f[T]) ToArray() [3]T

func (Vector3f[T]) ToArrayf32

func (v Vector3f[T]) ToArrayf32() [3]float32

type Vector3f32

type Vector3f32 = Vector3f[float32]

type Vector3f64

type Vector3f64 = Vector3f[float64]

type Vector3i

type Vector3i[T constraints.Integer] struct {
	X, Y, Z T
}

func Vector3iFromArray

func Vector3iFromArray[T constraints.Integer](a [3]T) Vector3i[T]

func (Vector3i[T]) Abs

func (v Vector3i[T]) Abs() Vector3i[T]

func (Vector3i[T]) Add

func (v Vector3i[T]) Add(v2 Vector3i[T]) Vector3i[T]

func (Vector3i[T]) AddUniform

func (v Vector3i[T]) AddUniform(i T) Vector3i[T]

func (Vector3i[T]) Clamp

func (v Vector3i[T]) Clamp(lo, hi Vector3i[T]) Vector3i[T]

func (Vector3i[T]) Max

func (v Vector3i[T]) Max(v2 Vector3i[T]) Vector3i[T]

func (Vector3i[T]) Min

func (v Vector3i[T]) Min(v2 Vector3i[T]) Vector3i[T]

func (Vector3i[T]) Scale

func (v Vector3i[T]) Scale(v2 Vector3i[T]) Vector3i[T]

func (Vector3i[T]) ScaleInverse

func (v Vector3i[T]) ScaleInverse(v2 Vector3i[T]) Vector3i[T]

func (Vector3i[T]) ScaleInverseUniform

func (v Vector3i[T]) ScaleInverseUniform(s T) Vector3i[T]

func (Vector3i[T]) ScaleUniform

func (v Vector3i[T]) ScaleUniform(s T) Vector3i[T]

func (Vector3i[T]) Subtract

func (v Vector3i[T]) Subtract(v2 Vector3i[T]) Vector3i[T]

func (Vector3i[T]) SubtractUniform

func (v Vector3i[T]) SubtractUniform(i T) Vector3i[T]

func (Vector3i[T]) ToArray

func (v Vector3i[T]) ToArray() [3]T

func (Vector3i[T]) ToArrayi32

func (v Vector3i[T]) ToArrayi32() [3]int32

type Vector3i32

type Vector3i32 = Vector3i[int32]

type Vector3i64

type Vector3i64 = Vector3i[int64]

type Vector3int

type Vector3int = Vector3i[int]

Jump to

Keyboard shortcuts

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