geom

package
v0.0.0-...-e996cf0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Epsilon = 0.01
View Source
var IdentityMatrix = identity.Matrix
View Source
var Right = NewVector(1, 0, 0)
View Source
var Up = NewVector(0, 1, 0)

Functions

func Add3

func Add3(t1, t2, t3 Tuple4, out *Tuple4)

func AddPtr

func AddPtr(t1, t2 Tuple4, t3 *Tuple4)

func AddPtr2

func AddPtr2(t1, t2 *Tuple4, t3 *Tuple4)

func AddPtr3

func AddPtr3(t1, t2, t3, out *Tuple4)

func Cofactor3x3

func Cofactor3x3(m1 Mat3x3, row, col int) float64

Cofactor3x3 may change the sign of the computed minor of the passed matrix

func Cofactor4x4

func Cofactor4x4(m1 Mat4x4, row, col int) float64

Cofactor4x4 may change the sign of the computed minor of the passed matrix

func Cross2

func Cross2(a *Tuple4, b *Tuple4, c *Tuple4)

func CrossProduct

func CrossProduct(f1, f2, out *Tuple4)

func DP

func DP(v1 *Tuple4, v2 *Tuple4) float64

func Determinant2x2

func Determinant2x2(m1 Mat2x2) float64

Determinant2x2 returns A-D minus B-C for a [A,B] [C,D] Matrix.

func Determinant3x3

func Determinant3x3(m1 Mat3x3) float64

Determinant3x3 takes the first row of the passed matrix, summing the colvalue * Cofactor of the same col

func Determinant4x4

func Determinant4x4(m1 Mat4x4) float64

Determinant4x4

func Dot

func Dot(t1 Tuple4, t2 Tuple4) float64

Dot product is the sum of the products of the corresponding entries of the two sequences of numbers a product is simply put the result of a multiplication. The dot product of two tuples is simply t1.x * t2.x + t1.y * t2.y + t1.z * t2.z + t1[3] * t2[3]

func DotProduct

func DotProduct(v1 *Tuple4, v2 *Tuple4, result *Tuple4)

func DotPtr

func DotPtr(t1 *Tuple4, t2 *Tuple4) float64

func Eq

func Eq(a, b float64) bool

func Equals

func Equals(m1, m2 Mat4x4) bool

func Equals2x2

func Equals2x2(m1, m2 Mat2x2) bool

func Equals3x3

func Equals3x3(m1, m2 Mat3x3) bool

func HadamardPtr

func HadamardPtr(t1 *Tuple4, t2 *Tuple4, out *Tuple4)

func IsInvertible

func IsInvertible(m1 Mat4x4) bool

func Magnitude

func Magnitude(t1 Tuple4) float64

Magnitude measures the length of the passed vector. It's basically pythagoras sqrt(x2 + y2 + z2 + w2)

func MagnitudePtr

func MagnitudePtr(t1 *Tuple4) float64

func Minor3x3

func Minor3x3(m1 Mat3x3, row, col int) float64

Minor3x3 computes the submatrix at row/col and returns the determinant of the computed matrix.

func Minor4x4

func Minor4x4(m1 Mat4x4, row, col int) float64

Minor4x4 computes the submatrix at row/col and returns the determinant of the computed matrix.

func MultiplyByScalarPtr

func MultiplyByScalarPtr(t1 Tuple4, scalar float64, out *Tuple4)

func MultiplyByTuplePtr

func MultiplyByTuplePtr(m *Mat4x4, f2 *Tuple4, _f4 *Tuple4)

func MultiplyByTupleUsingPointers

func MultiplyByTupleUsingPointers(m1 *Mat4x4, t, out *Tuple4)

func MultiplyByTupleUsingValues

func MultiplyByTupleUsingValues(m1 Mat4x4, t Tuple4, out *Tuple4)

func NegatePtr

func NegatePtr(t1 Tuple4, out *Tuple4)

func NormalizePtr

func NormalizePtr(t1 *Tuple4, out *Tuple4)

func NormalizePtr2

func NormalizePtr2(t1 Tuple4, out *Tuple4)

func SubPtr

func SubPtr(t1, t2 Tuple4, out *Tuple4)

func TupleEquals

func TupleEquals(t1, t2 Tuple4) bool

func TupleXYZEq

func TupleXYZEq(t1, t2 Tuple4) bool

Types

type Mat2x2

type Mat2x2 [4]float64

func NewMat2x2

func NewMat2x2(elems []float64) Mat2x2

func Submatrix3x3

func Submatrix3x3(m1 Mat3x3, deleteRow, deleteCol int) Mat2x2

Submatrix3x3 extracts the 2x2 submatrix after deleting row and col from the passed 3x3

func (Mat2x2) Get

func (m Mat2x2) Get(row int, col int) float64

type Mat3x3

type Mat3x3 [9]float64

func NewMat3x3

func NewMat3x3(elems []float64) Mat3x3

func Submatrix4x4

func Submatrix4x4(m1 Mat4x4, deleteRow, deleteCol int) Mat3x3

Submatrix4x4 extracts the 3x3 submatrix after deleting row and col from the passed 4x4

func (Mat3x3) Get

func (m Mat3x3) Get(row int, col int) float64

type Mat4x4

type Mat4x4 [16]float64

func Inverse

func Inverse(m1 Mat4x4) Mat4x4

func Multiply

func Multiply(m1 Mat4x4, m2 Mat4x4) Mat4x4

func New4x4

func New4x4() Mat4x4

func NewIdentityMatrix

func NewIdentityMatrix() Mat4x4

func NewMat4x4

func NewMat4x4(elems []float64) Mat4x4

func RotateX

func RotateX(radians float64) Mat4x4

func RotateY

func RotateY(radians float64) Mat4x4

func RotateZ

func RotateZ(radians float64) Mat4x4

func Scale

func Scale(x, y, z float64) Mat4x4

func Translate

func Translate(x, y, z float64) Mat4x4

Translate creates a translation matrix from the identity matrix, setting wx, wy, wz to the passed xyz coords.

func Transpose

func Transpose(m1 Mat4x4) Mat4x4

Transpose flips rows and cols in the matrix.

func (Mat4x4) Get

func (m Mat4x4) Get(row int, col int) float64

type Ray

type Ray struct {
	Origin    Tuple4
	Direction Tuple4
}

func NewEmptyRay

func NewEmptyRay() Ray

func NewRay

func NewRay(origin Tuple4, direction Tuple4) Ray

type Tuple4

type Tuple4 [4]float64

func Add

func Add(t1, t2 Tuple4) Tuple4

func Cross

func Cross(t1 Tuple4, t2 Tuple4) Tuple4

func DivideByScalar

func DivideByScalar(t1 Tuple4, scalar float64) Tuple4

func Hadamard

func Hadamard(t1 Tuple4, t2 Tuple4) Tuple4

func MultiplyByScalar

func MultiplyByScalar(t1 Tuple4, scalar float64) Tuple4

func MultiplyByTuple

func MultiplyByTuple(m1 Mat4x4, t Tuple4) Tuple4

func Negate

func Negate(t1 Tuple4) Tuple4

func NewColor

func NewColor(r, g, b float64) Tuple4

func NewPoint

func NewPoint(x, y, z float64) Tuple4

func NewTuple

func NewTuple() Tuple4

func NewTupleOf

func NewTupleOf(x, y, z, w float64) Tuple4

func NewVector

func NewVector(x, y, z float64) Tuple4

func Normalize

func Normalize(t1 Tuple4) Tuple4

Normalize measures the length (magnitude) of the passed Vector. Each component in t1 is then divided my the magnitude in order to Normalize it to unit (1) size.

func Sub

func Sub(t1, t2 Tuple4) Tuple4

func T4F32

func T4F32(x, y, z float32, w float64) Tuple4

func (Tuple4) Add

func (t Tuple4) Add(t2 Tuple4) Tuple4

func (*Tuple4) AddNoRet

func (t *Tuple4) AddNoRet(t2 Tuple4)

func (*Tuple4) AddNoRetPtr

func (t *Tuple4) AddNoRetPtr(t2 *Tuple4)

func (Tuple4) Get

func (t Tuple4) Get(row int) float64

func (Tuple4) IsPoint

func (t Tuple4) IsPoint() bool

func (Tuple4) IsVector

func (t Tuple4) IsVector() bool

func (Tuple4) Multiply

func (t Tuple4) Multiply(scalar float64) Tuple4

func (Tuple4) ResetPoint

func (t Tuple4) ResetPoint() Tuple4

func (Tuple4) ResetVector

func (t Tuple4) ResetVector() Tuple4

Jump to

Keyboard shortcuts

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