vec64

package
v0.0.0-...-e56f4fe Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2014 License: MIT Imports: 2 Imported by: 15

Documentation

Overview

Package vec64 operates on four-dimensional float64 vectors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dot

func Dot(v1, v2 Vector) float64

Dot computes the dot product of two vectors.

Types

type Vector

type Vector [4]float64

Vector holds a four-dimensional vector. The default value is a zero vector.

func Add

func Add(v1, v2 Vector) Vector

Add computes the sum of two vectors.

func CreateCS

func CreateCS(normal Vector) (u, v Vector)

CreateCS finds two normalized vectors orthogonal to the given one that can be used as a coordinate system.

All calculations are done in three-dimensional space. This is particularly useful for UV-mapping and the like.

func Cross

func Cross(v1, v2 Vector) Vector

Cross computes the three-dimensional cross product of two vectors.

func Mul

func Mul(v1, v2 Vector) Vector

Mul multiplies the components of two vectors together.

func Reflect

func Reflect(v, n Vector) Vector

Reflect calculates a reflection of a vector based on a normal.

func Sub

func Sub(v1, v2 Vector) Vector

Sub computes the difference of two vectors.

func Sum

func Sum(v1, v2 Vector, vn ...Vector) Vector

Sum computes the sum of two or more vectors.

func (Vector) Abs

func (v Vector) Abs() Vector

Abs returns a new vector with all positive components.

func (Vector) GoString

func (v Vector) GoString() string

func (Vector) Inverse

func (v Vector) Inverse() Vector

Inverse returns a new vector that is the result of 1.0 / v[i] for all i. Any zero value is left as zero.

func (Vector) IsZero

func (v Vector) IsZero() bool

IsZero indicates whether the vector is the zero vector.

func (Vector) Length

func (v Vector) Length() float64

Length returns the magnitude of the vector.

func (Vector) LengthSqr

func (v Vector) LengthSqr() float64

LengthSqr returns the magnitude squared of the vector. This is cheaper to compute than Length.

func (Vector) Negate

func (v Vector) Negate() Vector

Negate returns a new vector in the opposite direction.

func (Vector) Normalize

func (v Vector) Normalize() Vector

Normalize creates a new vector that is of unit length in the same direction as the vector.

func (Vector) Scale

func (v Vector) Scale(s float64) Vector

Scale multiplies all of a vector's components by a scalar.

func (Vector) String

func (v Vector) String() string

func (Vector) Vec3

func (v Vector) Vec3() Vector

Vec3 returns a copy of the vector with the 4th component set to zero.

Jump to

Keyboard shortcuts

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