math3

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package math3 provides basic 3D math utils.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Axis

type Axis byte

Axis enum type.

const (
	AxisNone Axis = iota
	AxisX
	AxisY
	AxisZ
)

Axis enum values.

type Matrix

type Matrix [3][3]float64

Matrix is a 3x3 matrix.

func GetRotationMatrix

func GetRotationMatrix(deg float64, axis Axis) Matrix

GetRotationMatrix returns the populated matrix to rotate along the given axis.

Ref: https://en.wikipedia.org/wiki/Rotation_matrix#Basic_3D_rotations.

func (Matrix) Multiply

func (m Matrix) Multiply(m2 Matrix) Matrix

Multiply 2 3x3 matrices.

type Vec

type Vec struct {
	X, Y, Z float64
}

Vec is a 3d vector.

func (Vec) MultiplyMatrix

func (v Vec) MultiplyMatrix(m Matrix) Vec

MultiplyMatrix multiplies the given matrix with the current vector.

func (Vec) Rotate

func (v Vec) Rotate(angle Vec) Vec

Rotate the vector.

func (Vec) ScaleAll

func (v Vec) ScaleAll(scale float64) Vec

ScaleAll the vector by the given factor.

func (Vec) ScaleZ

func (v Vec) ScaleZ(scale float64) Vec

ScaleZ scales only Z.

func (Vec) Translate

func (v Vec) Translate(offset Vec) Vec

Translate the vector.

Jump to

Keyboard shortcuts

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