primitives

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EPSILON float64 = 0.00000001

EPSILON Value used for approximation

Functions

This section is empty.

Types

type Matrix

type Matrix [][]float64

Matrix A square matrix

func MakeIdentityMatrix

func MakeIdentityMatrix(size uint8) Matrix

MakeIdentityMatrix Make an identity matrix of the given size

func MakeMatrix

func MakeMatrix(size uint8) Matrix

MakeMatrix Makes an emptry square matrix of the given size

func RotationX

func RotationX(rad float64) Matrix

RotationX Rotate around the X-Axis

func RotationY

func RotationY(rad float64) Matrix

RotationY Rotate around the Y-Axis

func RotationZ

func RotationZ(rad float64) Matrix

RotationZ Rotate around the Z-Axis

func Scaling

func Scaling(x, y, z float64) Matrix

Scaling Scale the point/vector

func Shearing

func Shearing(xy, xz, yx, yz, zx, zy float64) Matrix

Shearing Shear an axis along another axis

func Translation

func Translation(x, y, z float64) Matrix

Translation Move a point, not a vector

func (Matrix) Cofactor

func (m Matrix) Cofactor(row, column uint8) float64

Cofactor Calculate minor and negate if necessary

func (Matrix) Determinant

func (m Matrix) Determinant() float64

Determinant Calculates the determinant of a 2x2 matrix

func (Matrix) Equals

func (m Matrix) Equals(o Matrix) bool

Equals Compares two matrices with an amount for approximation

func (Matrix) Inverse

func (m Matrix) Inverse() (Matrix, error)

Inverse Invert the function if possible

func (Matrix) Minor

func (m Matrix) Minor(row, column uint8) float64

Minor Calculate the determinant of the submatrix

func (Matrix) Multiply

func (m Matrix) Multiply(o Matrix) Matrix

Multiply Matrix multiplication function

func (Matrix) Submatrix

func (m Matrix) Submatrix(row uint8, column uint8) Matrix

Submatrix Return a smaller matrix that exists within

func (Matrix) Transpose

func (m Matrix) Transpose() Matrix

Transpose Flip the rows with the columns of a matrix

type PV

type PV struct{ X, Y, Z, W float64 }

PV represents 3D coordinates and a w variable for distinction between point and vector

func MakePoint

func MakePoint(x, y, z float64) PV

MakePoint Create a point PV type

func MakeVector

func MakeVector(x, y, z float64) PV

MakeVector Create a vector PV type

func (PV) Add

func (p PV) Add(o PV) PV

Add adds one PV to another and returns the result

func (PV) CrossProduct

func (p PV) CrossProduct(o PV) PV

CrossProduct Returns the cross product with the PV passed in as a PV

func (PV) DotProduct

func (p PV) DotProduct(o PV) float64

DotProduct Return the dot product with the passed in PV

func (PV) Equals

func (p PV) Equals(o PV) bool

Equals Compares two PVs with an amount for approximation

func (PV) Magnitude

func (p PV) Magnitude() float64

Magnitude Returns the magnitude of the PV

func (PV) Negate

func (p PV) Negate() PV

Negate Negate the PV to return its opposite

func (PV) Normalize

func (p PV) Normalize() PV

Normalize Returns the normalized version of the PV

func (PV) Reflect

func (p PV) Reflect(normal PV) PV

Reflect Calculate the reflection vector from a normal

func (PV) Scalar

func (p PV) Scalar(s float64) PV

Scalar Scale a PV by a given value and return the result as a PV

func (PV) Subtract

func (p PV) Subtract(o PV) PV

Subtract subtracts one PV from another and returns the result

func (PV) Transform

func (p PV) Transform(m Matrix) PV

Transform Transform the PV by a matrix

type Ray

type Ray struct {
	Origin, Direction PV
}

Ray Contains a point and vector

func (Ray) Equals

func (ray Ray) Equals(o Ray) bool

Equals Compare two rays with an amount for approximation

func (Ray) Position

func (ray Ray) Position(time float64) PV

Position Calculate ray's position after a set amount of time

func (Ray) Transform

func (ray Ray) Transform(m Matrix) Ray

Transform Transform the origin and direciton by a matrix

Jump to

Keyboard shortcuts

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