glm

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: MIT Imports: 5 Imported by: 9

README

glm

glm

Documentation

Index

Constants

View Source
const (
	//Pi float32 Pi
	Pi = float32(math.Pi)
	//Pi2 Pi*2
	Pi2 = float32(math.Pi * 2)
	//Pi180 Pi / 180.0
	Pi180 = float32(math.Pi / 180.0)
	//Epsilon
	Epsilon = 0.000001
)

Variables

View Source
var Mat3x3_Ident = Mat3x3{
	1, 0, 0,
	0, 1, 0,
	0, 0, 1}
View Source
var Mat4x4_Ident = Mat4x4{
	1, 0, 0, 0,
	0, 1, 0, 0,
	0, 0, 1, 0,
	0, 0, 0, 1}
View Source
var TransformIdent = Transform{
	Position: Vec3{0, 0, 0},
	Rotation: Vec3{0, 0, 0},
	Scale:    Vec3{1, 1, 1}}

Functions

func Abs

func Abs(f float32) float32

func AbsI

func AbsI(i int32) int32

func Asin

func Asin(f float32) float32

func Atan2

func Atan2(y, x float32) float32

func Clamp

func Clamp(value, min, max float32) float32

func Deg2Rad

func Deg2Rad(deg float32) float32

Deg2Rad converts the number in degrees to the radian equivalent

func DotProduct

func DotProduct(v1, v2 *Vec3) float32

func Equal

func Equal(y, x float32) bool

func FastInvSqrt

func FastInvSqrt(x float32) float32

func LengthSquared

func LengthSquared(x, y, z float32) float32

func LengthXY

func LengthXY(x, y float32) float32

func LengthXYZ

func LengthXYZ(x, y, z float32) float32

func Lerp

func Lerp(start, end, t float32) float32

func Max

func Max(a, b float32) float32

func MaxI

func MaxI(a, b int32) int32

func Min

func Min(a, b float32) float32

func MinI

func MinI(a, b int32) int32

func MinMaxI

func MinMaxI(a, b int32) (int32, int32)

func NextPow2

func NextPow2(x uint32) uint32

func SinCos

func SinCos(angle float32) (s, c float32)

func Sqrt

func Sqrt(f float32) float32

func Tan

func Tan(f float32) float32

func Vec2Equals

func Vec2Equals(v1, v2 *Vec2) bool

func Vec3Equals

func Vec3Equals(v1, v2 *Vec3) bool

Types

type AABB

type AABB struct {
	Min, Max Vec3
}

func (*AABB) ContainsVec3

func (aabb *AABB) ContainsVec3(k Vec3) bool

func (*AABB) IntersectAABB

func (aabb *AABB) IntersectAABB(o *AABB) bool

func (*AABB) IntersectSphere

func (aabb *AABB) IntersectSphere(sphere *Sphere) bool

type Frustrum

type Frustrum [6]Plane

func (*Frustrum) ContainsVec3

func (f *Frustrum) ContainsVec3(k *Vec3) bool

func (*Frustrum) IntersectSphere

func (f *Frustrum) IntersectSphere(s *Sphere) bool

func (*Frustrum) Normalize

func (f *Frustrum) Normalize()

func (*Frustrum) SetMatrix

func (f *Frustrum) SetMatrix(m Mat4x4)

type Line2I

type Line2I struct {
	Start Vec2I
	End   Vec2I
}

func (*Line2I) NaiveLineDrawing

func (l *Line2I) NaiveLineDrawing(plot func(int32, int32))

type Mat3x3

type Mat3x3 [9]float32

func (*Mat3x3) FromQuaternion

func (m *Mat3x3) FromQuaternion(q *Quat)

func (*Mat3x3) SetFormEulerXYZ

func (m *Mat3x3) SetFormEulerXYZ(angleX, angleY, angleZ float32)

func (*Mat3x3) SetIdentity

func (m *Mat3x3) SetIdentity()

type Mat4x4

type Mat4x4 [16]float32

func (*Mat4x4) CopyInverseFrom

func (m *Mat4x4) CopyInverseFrom(src Mat4x4) error

func (*Mat4x4) Frustum

func (m *Mat4x4) Frustum(left, right, bottom, top, near, far float32)

func (*Mat4x4) LookAt

func (m *Mat4x4) LookAt(eye, target, up Vec3)

func (*Mat4x4) MulVec4

func (m *Mat4x4) MulVec4(v Vec4) Vec4

func (*Mat4x4) Ortho

func (m *Mat4x4) Ortho(left, right, bottom, top, near, far float32)

func (*Mat4x4) Perspective

func (m *Mat4x4) Perspective(zNear, zFar, fovy, aspect float32)

func (*Mat4x4) Ptr

func (m *Mat4x4) Ptr() uintptr

func (Mat4x4) SetIdentity

func (m Mat4x4) SetIdentity()

func (*Mat4x4) SetMul

func (m *Mat4x4) SetMul(m1, m2 Mat4x4)

func (*Mat4x4) SetRotateX

func (m *Mat4x4) SetRotateX(radians float32)

func (*Mat4x4) SetRotateY

func (m *Mat4x4) SetRotateY(radians float32)

func (*Mat4x4) SetRotateZ

func (m *Mat4x4) SetRotateZ(radians float32)

func (*Mat4x4) SetTransform

func (m *Mat4x4) SetTransform(t *Transform)

Transform Order is : Scale, Rotate, Translate

func (*Mat4x4) String

func (m *Mat4x4) String() string

func (*Mat4x4) Transform2

func (m *Mat4x4) Transform2(location *Vec3, scale *Vec3, orient *Quat)

TODO: do not remember if this correct

func (*Mat4x4) TranslateXYZ

func (m *Mat4x4) TranslateXYZ(x, y, z float32)

func (*Mat4x4) Transpose

func (m *Mat4x4) Transpose()

type Plane

type Plane struct {
	Normal   Vec3
	Constant float32
}

func (*Plane) DistanceToVec3

func (p *Plane) DistanceToVec3(k *Vec3) float32

func (*Plane) IntersectRay

func (p *Plane) IntersectRay(r *Ray) *Vec3

func (*Plane) Normalize

func (p *Plane) Normalize()

func (*Plane) Set

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

func (*Plane) String

func (p *Plane) String() string

type Quat

type Quat struct {
	X, Y, Z, W float32
}

func ZeroQuat

func ZeroQuat() *Quat

func (*Quat) FromEuler

func (q *Quat) FromEuler(v *Vec3)

func (*Quat) FromEulerXYZ

func (q *Quat) FromEulerXYZ(x, y, z float32)

func (*Quat) Mul

func (q *Quat) Mul(k *Quat)

func (*Quat) Normalize

func (q *Quat) Normalize()

func (*Quat) Set

func (q *Quat) Set(k *Quat)

func (*Quat) SetEulerXYZ

func (q *Quat) SetEulerXYZ(x, y, z float32)

func (*Quat) SetMul

func (q *Quat) SetMul(v, k *Quat)

func (*Quat) SetQuat

func (q *Quat) SetQuat(a *Quat)

func (*Quat) SetSum

func (q *Quat) SetSum(a, b *Quat)

func (*Quat) SetXYZW

func (q *Quat) SetXYZW(x, y, z, w float32)

func (*Quat) SetZeroRotation

func (q *Quat) SetZeroRotation()

func (*Quat) ToEuler

func (q *Quat) ToEuler() (yaw, pitch, roll float32)

type Ray

type Ray struct {
	Origin    Vec3
	Direction Vec3
}

func RayCast

func RayCast(touch Vec2, origin Vec3, proj, view Mat4x4) *Ray

type Rect

type Rect struct {
	X, Y, W, H float32
}

func (*Rect) Aspect

func (r *Rect) Aspect() float32

func (*Rect) Set

func (r *Rect) Set(x, y, w, h float32)

func (*Rect) String

func (r *Rect) String() string

type RectI

type RectI struct {
	X, Y, W, H int32
}

type Sphere

type Sphere struct {
	Center Vec3
	Radius float32
}

func NewSphere

func NewSphere(v *Vec3, r float32) *Sphere

func (*Sphere) ContainsVec3

func (s *Sphere) ContainsVec3(k *Vec3) bool

func (*Sphere) CylinderCoord

func (s *Sphere) CylinderCoord(n *Vec3) *Vec2

func (*Sphere) DistanceToVec3

func (s *Sphere) DistanceToVec3(k *Vec3) float32

func (*Sphere) IntersectSphere

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

func (*Sphere) Midpoint

func (s *Sphere) Midpoint(a, b *Vec3) (mid *Vec3)

func (*Sphere) String

func (s *Sphere) String() string

type Transform

type Transform struct {
	Position Vec3
	Rotation Vec3
	Scale    Vec3
}

func (*Transform) Set

func (t *Transform) Set(a *Transform)

func (*Transform) SetSum

func (t *Transform) SetSum(a, b *Transform)

type Vec2

type Vec2 struct{ X, Y float32 }

func Vec2Sub

func Vec2Sub(v1, v2 *Vec2) *Vec2

func (*Vec2) DistanceTo

func (v *Vec2) DistanceTo(k *Vec2) float32

func (*Vec2) Length

func (v *Vec2) Length() float32

func (*Vec2) Normalize

func (v *Vec2) Normalize()

func (*Vec2) SetSub

func (v *Vec2) SetSub(a, b *Vec2)

func (*Vec2) SetXY

func (v *Vec2) SetXY(x, y float32)

type Vec2I

type Vec2I struct{ X, Y int32 }

func Vec2ISum

func Vec2ISum(a, b Vec2I) Vec2I

type Vec3

type Vec3 struct{ X, Y, Z float32 }

func CrossProduct

func CrossProduct(v1, v2 Vec3) Vec3

func Vec3Add

func Vec3Add(v1, v2 *Vec3) *Vec3

func Vec3Sub

func Vec3Sub(v1, v2 Vec3) Vec3

func (*Vec3) Add

func (v *Vec3) Add(k Vec3)

func (*Vec3) AddVec3

func (v *Vec3) AddVec3(k *Vec3)

func (*Vec3) AddXYZ

func (v *Vec3) AddXYZ(x, y, z float32)

func (*Vec3) ApplyMat3x3

func (v *Vec3) ApplyMat3x3(m *Mat3x3)

func (*Vec3) ApplyMat4x4

func (v *Vec3) ApplyMat4x4(m *Mat4x4)

func (*Vec3) ApplyQuat

func (v *Vec3) ApplyQuat(q *Quat)

func (*Vec3) Distance

func (v *Vec3) Distance(k Vec3) float32

func (*Vec3) DistanceTo

func (v *Vec3) DistanceTo(k *Vec3) float32

func (*Vec3) DistanceToSquared

func (v *Vec3) DistanceToSquared(k *Vec3) float32

func (*Vec3) EqEpsilon

func (v *Vec3) EqEpsilon(k Vec3) bool

func (*Vec3) Length

func (v *Vec3) Length() float32

func (*Vec3) MarshalJSON

func (v *Vec3) MarshalJSON() ([]byte, error)

func (*Vec3) Normalize

func (v *Vec3) Normalize()

func (*Vec3) Scale

func (v *Vec3) Scale(factor float32)

func (*Vec3) Set

func (v *Vec3) Set(a *Vec3)

func (*Vec3) SetMax

func (v *Vec3) SetMax(x, y, z float32)

func (*Vec3) SetMin

func (v *Vec3) SetMin(x, y, z float32)

func (*Vec3) SetMul

func (v *Vec3) SetMul(a, b *Vec3)

func (*Vec3) SetSub

func (v *Vec3) SetSub(a, b *Vec3)

func (*Vec3) SetSubVec3

func (v *Vec3) SetSubVec3(k *Vec3)

func (*Vec3) SetSum

func (v *Vec3) SetSum(a, b *Vec3)

func (*Vec3) SetXYZ

func (v *Vec3) SetXYZ(x, y, z float32)

func (*Vec3) String

func (v *Vec3) String() string

func (*Vec3) Sub

func (v *Vec3) Sub(k Vec3)

func (*Vec3) UnmarshalJSON

func (v *Vec3) UnmarshalJSON(data []byte) error

type Vec4

type Vec4 struct {
	X, Y, Z, W float32
}

Jump to

Keyboard shortcuts

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