vec3

package
v0.0.0-...-adcb094 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Unlicense Imports: 2 Imported by: 0

Documentation

Overview

Package vec3 provides utility functions to work with vectors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dot

func Dot(v1 *Vec3Impl, v2 *Vec3Impl) float64

Dot computes the dot product of the two supplied vectors.

Types

type Vec3Impl

type Vec3Impl struct {
	X float64
	Y float64
	Z float64
	R float64
	G float64
	B float64
}

Vec3Impl defines a vector with its position and colour.

func Add

func Add(v1 *Vec3Impl, args ...*Vec3Impl) *Vec3Impl

Add returns the sum of two or more vectors.

func Cross

func Cross(v1 *Vec3Impl, v2 *Vec3Impl) *Vec3Impl

Cross computes the cross product of the two supplied vectors.

func DeNAN

func DeNAN(v *Vec3Impl) *Vec3Impl

DeNAN ensures that the vector elements are numbers.

func Div

func Div(v1 *Vec3Impl, v2 *Vec3Impl) *Vec3Impl

Div returns the division of two vectors.

func Mul

func Mul(v1 *Vec3Impl, v2 *Vec3Impl) *Vec3Impl

Mul returns the multiplication of two vectors.

func RandomCosineDirection

func RandomCosineDirection() *Vec3Impl

RandomCosineDirection returns a vector with a random cosine direction.

func RandomToSphere

func RandomToSphere(radius float64, distanceSquared float64) *Vec3Impl

RandomToSphere returns a new random sphere of the given radius at the given distance.

func ScalarDiv

func ScalarDiv(v1 *Vec3Impl, t float64) *Vec3Impl

ScalarMul returns the scalar division of the given vector and scalar values.

func ScalarMul

func ScalarMul(v1 *Vec3Impl, t float64) *Vec3Impl

ScalarMul returns the scalar multiplication of the given vector and scalar values.

func Sub

func Sub(v1 *Vec3Impl, args ...*Vec3Impl) *Vec3Impl

Sub returns the subtraction of two or more vectors.

func UnitVector

func UnitVector(v *Vec3Impl) *Vec3Impl

UnitVector returns a unit vector representation of the supplied vector.

func (*Vec3Impl) Length

func (v *Vec3Impl) Length() float64

Length returns the length of this vector.

func (*Vec3Impl) MakeUnitVector

func (v *Vec3Impl) MakeUnitVector()

MakeUnitVector transform the vector into its unit representation.

func (*Vec3Impl) SquaredLength

func (v *Vec3Impl) SquaredLength() float64

SquaredLength returns the squared length of this vector.

Jump to

Keyboard shortcuts

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