types

package
v0.0.0-...-e791307 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApproxEqual

func ApproxEqual(v1, v2 Vec3, epsilon float32) bool

Check if two vectors are equal based on a comparison epsilon.

Types

type Mat3

type Mat3 f32.Mat3

func Ident3

func Ident3() Mat3

Create a 3x3 identity matrix

func (Mat3) Mul3x1

func (m Mat3) Mul3x1(v Vec3) Vec3

Multiply a 3x3 matrix with a Vec3. The vector is treated as a 3x1 matrix

type Mat4

type Mat4 f32.Mat4

func Ident4

func Ident4() Mat4

Create a 4x4 identity matrix.

func LookAtV

func LookAtV(eye, center, up Vec3) Mat4

Generates a transform matrix from world space into the specific eye space.

func Perspective4

func Perspective4(fovy, aspect, near, far float32) Mat4

Create a perspective projection 4x4 matrix

func Scale4

func Scale4(scale Vec3) Mat4

Create a 4x4 scale matrix.

func Translate4

func Translate4(translation Vec3) Mat4

Create a 4x4 translation matrix.

func (Mat4) Col

func (m Mat4) Col(col int) Vec4

Extract matrix column as a Vector

func (Mat4) Inv

func (m Mat4) Inv() Mat4

Invert matrix

func (Mat4) Mat3

func (m Mat4) Mat3() Mat3

Extract the top-left 3x3 matrix from a 4x4 matrix.

func (Mat4) Mul

func (m Mat4) Mul(s float32) Mat4

Multiply matrix with scalar.

func (Mat4) Mul4

func (m1 Mat4) Mul4(m2 Mat4) Mat4

Multiply two 4x4 matrices.

func (Mat4) Mul4x1

func (m Mat4) Mul4x1(v Vec4) Vec4

Multiply a 4x4 matrix with a Vec4. The vector is treated as a 4x1 matrix

func (Mat4) Row

func (m Mat4) Row(row int) Vec4

Extract matrix row as a Vector

func (Mat4) String

func (m Mat4) String() string

type Quat

type Quat struct {
	V Vec3
	W float32
}

Quaternion implementation taken from https://github.com/go-gl/mathgl/blob/master/mgl32/quat.go

func QuatFromAxisAngle

func QuatFromAxisAngle(axis Vec3, angle float32) Quat

Create a quaternion from an axis vector and an angle.

func QuatIdent

func QuatIdent() Quat

Create identity quaternion.

func (Quat) Inverse

func (q1 Quat) Inverse() Quat

The inverse of a quaternion. The inverse is equivalent to the conjugate divided by the square of the length.

func (Quat) Len

func (q1 Quat) Len() float32

Returns the Length of the quaternion, also known as its Norm. This is the same thing as the Len of a Vec4

func (Quat) Mat4

func (q1 Quat) Mat4() Mat4

Returns the homogeneous 3D rotation matrix corresponding to the quaternion.

func (Quat) Mul

func (q1 Quat) Mul(q2 Quat) Quat

Multiplies two quaternions. This can be seen as a rotation. Note that Multiplication is NOT commutative, meaning q1.Mul(q2) does not necessarily equal q2.Mul(q1).

func (Quat) Normalize

func (q1 Quat) Normalize() Quat

Normalizes the quaternion, returning its versor (unit quaternion).

This is the same as normalizing it as a Vec4.

func (Quat) Rotate

func (q1 Quat) Rotate(v Vec3) Vec3

Rotates a vector by the rotation this quaternion represents. This will result in a 3D vector.

type Vec2

type Vec2 f32.Vec2

func XY

func XY(x, y float32) Vec2

Define a 2 component vector.

func (Vec2) Dot

func (v Vec2) Dot(v2 Vec2) float32

Calculate dot product of 2 vectors

func (Vec2) Sub

func (v Vec2) Sub(v2 Vec2) Vec2

Subtract a vector.

func (Vec2) Vec3

func (v Vec2) Vec3(z float32) Vec3

Expand a 2 component vector to a Vec3

type Vec3

type Vec3 f32.Vec3

func MaxVec3

func MaxVec3(v1, v2 Vec3) Vec3

Calc maxcomponent from two vectors.

func MinVec3

func MinVec3(v1, v2 Vec3) Vec3

Calc min component from two vectors.

func XYZ

func XYZ(x, y, z float32) Vec3

Define a 3 component vector.

func (Vec3) Add

func (v Vec3) Add(v2 Vec3) Vec3

Add a vector.

func (Vec3) Cross

func (v Vec3) Cross(v2 Vec3) Vec3

Calculate cross product of 2 vectors.

func (Vec3) Dot

func (v Vec3) Dot(v2 Vec3) float32

Calculate dot product of 2 vectors

func (Vec3) Len

func (v Vec3) Len() float32

Get 3 component vector length.

func (Vec3) MaxComponent

func (v Vec3) MaxComponent() float32

Return max vector component.

func (Vec3) Mul

func (v Vec3) Mul(s float32) Vec3

Multiply a 3 component vector with a scalar.

func (Vec3) Normalize

func (v Vec3) Normalize() Vec3

Normalize 3 component vector.

func (Vec3) String

func (v Vec3) String() string

func (Vec3) Sub

func (v Vec3) Sub(v2 Vec3) Vec3

Subtract a vector.

func (Vec3) Vec4

func (v Vec3) Vec4(w float32) Vec4

Expand a 3 component vector to a Vec4.

type Vec4

type Vec4 f32.Vec4

func XYZW

func XYZW(x, y, z, w float32) Vec4

Define a 4 component vector.

func (Vec4) Len

func (v Vec4) Len() float32

Get 4 component vector length.

func (Vec4) MaxComponent

func (v Vec4) MaxComponent() float32

Return max vector component

func (Vec4) Mul

func (v Vec4) Mul(s float32) Vec4

Multiply 4 component vector with scalar.

func (Vec4) Normalize

func (v Vec4) Normalize() Vec4

Normalize 4 component vector.

func (Vec4) Sub

func (v Vec4) Sub(v2 Vec4) Vec4

Subtract a vector.

func (Vec4) Vec3

func (v Vec4) Vec3() Vec3

Reduce a 4 component vector to a Vec3.

Jump to

Keyboard shortcuts

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