package
Version:
v0.0.0-...-8dd99ce
Opens a new window with list of versions in this module.
Published: Jun 9, 2023
License: MIT
Opens a new window with license information.
Imports: 2
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
Documentation
¶
-
func Dot(a, b Tuple) float64
-
func Equal(a, b Tuple) bool
-
func Mag(vec Tuple) float64
-
type Tuple
-
func Add(a, b Tuple) Tuple
-
func Cross(a, b Tuple) Tuple
-
func Div(t Tuple, scalar float64) Tuple
-
func Mult(t Tuple, scalar float64) Tuple
-
func Neg(t Tuple) Tuple
-
func New(x, y, z, w float64) Tuple
-
func Norm(vec Tuple) Tuple
-
func Point(x, y, z float64) Tuple
-
func Reflect(in, norm Tuple) Tuple
-
func Sub(a, b Tuple) Tuple
-
func Vector(x, y, z float64) Tuple
Dot returns the dot-product of two vectors. Passing a point to Dot
is undefined.
Equal returns true if two Tuples are equal.
Mag calculates the magnitude of a vector. Passing a point to Mag is
undefined result.
type Tuple struct {
X, Y, Z float64
}
Tuple implements points and vectors using a common struct.
Add calculates the component-wise sum of two Tuples.
Cross returns the cross-product of two vectors. Passing a point to Cross
is undefined.
Div calculates the component-wise quotient of a Tuple and a scalar.
Mult calculates the component-wise product of a Tuple and a scalar.
Neg calculates the component-wise negation of a Tuple.
New creates a new 4-tuple. It is recommended to use Vector and Point
rather than using New directly.
Norm returns a new vector which is the norm of vec. Passing a point to Norm
is undefined.
Point creates a new point at (x,y,z).
Reflect returns the reflection of vector in along vector norm.
Sub calculates the component-wise difference of two Tuples.
Vector creates a new vector starting at the origin and ending at (x,y,z).
Add calculates the component-wise sum of two Tuples.
IsPoint returns true if a tuple is a point.
IsVector returns true if a given Tuple is a vector.
Sub calculates the component-wise difference of two Tuples.
W returns the w component of the Tuple. A w value of 0 represents a vector
and a value of 1 represents a point.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.