geometry

package
v0.0.0-...-e407d5c Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ray

type Ray struct {
	Origin    Vector
	Direction Vector
}

Ray represents a ray in 3D space. A ray has an origin and direction

func (Ray) OffsetOrigin

func (r Ray) OffsetOrigin(offset ...float64) Ray

OffsetOrigin computes a new Ray similar to r with the only difference being its origin is slightly offset in the direction of r. Argument is optional and the default value offset is 0.0001

func (Ray) PointOnRay

func (r Ray) PointOnRay(t float64) Vector

PointOnRay computes the point on Ray r that is a of distance t from its origin

func (Ray) ReflectRay

func (r Ray) ReflectRay(collision Vector, normal Vector) Ray

ReflectRay calculates the reflected ray at a collison point over a normal vector

func (Ray) String

func (r Ray) String() string

type Vector

type Vector struct {
	X, Y, Z float64
}

Vector represents a vector or point in 3d space

func (Vector) Add

func (v1 Vector) Add(v2 Vector) Vector

Add computes the vector addition of v1 + v2

func (Vector) Cross

func (v1 Vector) Cross(v2 Vector) Vector

Cross computes the vector cross product of v1 x v2

func (Vector) Dot

func (v1 Vector) Dot(v2 Vector) float64

Dot computes the vector dot product of v1 · v2

func (Vector) Length

func (v Vector) Length() float64

Length computes the vector length or magnitude of v1

func (Vector) Normalize

func (v Vector) Normalize() Vector

Normalize computes the normalized vector of v1

func (Vector) Reflect

func (v Vector) Reflect(normal Vector) Vector

Reflect computes the reflected vector of v across a normal vector

func (Vector) Scale

func (v Vector) Scale(s float64) Vector

Scale computes the vector scalar of v1 * s

func (Vector) String

func (v Vector) String() string

func (Vector) Sub

func (v1 Vector) Sub(v2 Vector) Vector

Sub computes the vector subtraction of v1 - v2

func (Vector) VectorTo

func (p1 Vector) VectorTo(p2 Vector) Vector

VectorTo computes the vector from point v1 to point v2, which is simply v2 - v1

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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