r3

package
v0.0.0-...-4d4b827 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dot

func Dot(a, b Vec) float64

Dot returns a dot b.

func Mag

func Mag(v Vec) float64

Mag returns the magnitude of v.

func Mag2

func Mag2(v Vec) float64

Mag2 returns the magnitude squared of v.

Types

type Ray

type Ray struct {
	Origin, Direction Vec
}

type Vec

type Vec struct {
	X, Y, Z float64
}

Vec is a 3D vector.

func Add

func Add(a, b Vec) Vec

Add returns a+b.

func At

func At(r Ray, t float64) Vec

At returns the linear interpolation of r at t.

func Cross

func Cross(a, b Vec) Vec

Cross returns a cross b.

func NewVec

func NewVec(x, y, z float64) Vec

NewVec returns a new Vec with the given coordinates.

func Scale

func Scale(v Vec, f float64) Vec

Scale returns v scaled by f.

func Sub

func Sub(a, b Vec) Vec

Sub returns a-b.

func Unit

func Unit(v Vec) Vec

Unit returns the unit vector in the direction of v. It panics if v is the zero vector.

func (Vec) Color

func (v Vec) Color() color.RGBA

Color returns the color corresponding to v. [0, 1] for XYZ is mapped to [0, 255] for RGB. The alpha channel is always 255.

Jump to

Keyboard shortcuts

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