ray

package
v0.0.0-...-534c38e Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ZeroVector       = NewVec(0, 0, 0)
	ZeroPoint        = NewPoint(0, 0, 0)
	NonInvertibleErr = errors.New("non-invertible")
)

Functions

func Dot

func Dot(a, b Vector) float64

Types

type Axis

type Axis int
const (
	X Axis = iota
	Y
	Z
)

type Matrix

type Matrix [][]float64

func DefaultIdentityMatrix

func DefaultIdentityMatrix() (identityMatrix Matrix)

func DefaultIdentityMatrixInverse

func DefaultIdentityMatrixInverse() (identityMatrixInverse Matrix)

func IdentityMatrix

func IdentityMatrix(rows, cols int) (identityMatrix Matrix)

func NewMatrix

func NewMatrix(rows, columns int, rowsValues ...RowValues) Matrix

func Rotation

func Rotation(axis Axis, by float64) (rotation Matrix)

func Scaling

func Scaling(x, y, z float64) Matrix

func Translation

func Translation(x, y, z float64) Matrix

func ViewTransform

func ViewTransform(from, to, up Vector) (result Matrix)

func (Matrix) Cofactor

func (m Matrix) Cofactor(row, col int) float64

func (Matrix) Determinant

func (m Matrix) Determinant() float64

func (Matrix) Get

func (m Matrix) Get(row, column int) float64

func (Matrix) Inverse

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

func (Matrix) Minor

func (m Matrix) Minor(row, col int) float64

func (Matrix) Multiply

func (m Matrix) Multiply(by Matrix) (result Matrix)

func (Matrix) MultiplyByTuple

func (m Matrix) MultiplyByTuple(vals ...float64) (result Matrix)

func (Matrix) MultiplyByVector

func (m Matrix) MultiplyByVector(vec Vector) (result Vector)

func (Matrix) Set

func (m Matrix) Set(row, column int, val float64)

func (Matrix) SetRow

func (m Matrix) SetRow(row int, vals ...float64)

func (Matrix) String

func (m Matrix) String() string

func (Matrix) SubMatrix

func (m Matrix) SubMatrix(row, col int) (result Matrix)

func (Matrix) Transpose

func (m Matrix) Transpose() (result Matrix)

type Point

type Point Vector

type Ray

type Ray interface {
	color.Color
	Origin() Vector
	Direction() Vector
	PointAt(parameter float64) Vector
	SetR(redVal uint8)
	SetG(greenVal uint8)
	SetB(blueVal uint8)
	Transform(transformation Matrix) (transformed Ray)
}

func NewRay

func NewRay(x, y, z float64, r, g, b uint8) Ray

func NewRayAt

func NewRayAt(point, vector Vector) Ray

type RowValues

type RowValues []float64

type Vector

type Vector interface {
	GetX() float64
	SetX(x float64) Vector
	GetY() float64
	SetY(y float64) Vector
	GetZ() float64
	SetZ(z float64) Vector
	GetW() float64
	SetW(w float64) Vector
	Multiply(by float64) Vector
	Multiplied(by Matrix) Vector
	Add(vec Vector) Vector
	Divide(by float64) Vector
	Subtract(vec Vector) Vector
	Magnitude() float64
	Normalize() Vector
	Negate() Vector
	Reflect(normal Vector) Vector
	Dot(n Vector) float64
}

func Cross

func Cross(a, b Vector) Vector

func NewPoint

func NewPoint(x, y, z float64) Vector

func NewVec

func NewVec(x, y, z float64) Vector

Jump to

Keyboard shortcuts

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