## Documentation ¶

### Overview ¶

Package r3 provides 3D vectors and boxes and operations on them.

### Constants ¶

This section is empty.

### Variables ¶

This section is empty.

### Functions ¶

#### func Cos ¶

func Cos(p, q Vec) float64

Cos returns the cosine of the opening angle between p and q.

#### func Dot ¶

func Dot(p, q Vec) float64

Dot returns the dot product p·q.

#### func Norm ¶

func Norm(p Vec) float64

Norm returns the Euclidean norm of p

|p| = sqrt(p_x^2 + p_y^2 + p_z^2).

#### func Norm2 ¶

func Norm2(p Vec) float64

Norm returns the Euclidean squared norm of p

|p|^2 = p_x^2 + p_y^2 + p_z^2.

### Types ¶

#### type Box ¶

type Box struct {
Min, Max Vec
}

Box is a 3D bounding box.

#### type Rotation ¶

type Rotation quat.Number

Rotation describes a rotation in space.

#### func NewRotation ¶

func NewRotation(alpha float64, axis Vec) Rotation

NewRotation creates a rotation by alpha, around axis.

#### func (Rotation) Rotate ¶

func (r Rotation) Rotate(p Vec) Vec

Rotate returns the rotated vector according to the definition of rot.

#### type Vec ¶

type Vec struct {
X, Y, Z float64
}

Vec is a 3D vector.

Add returns the vector sum of p and q.

#### func Cross ¶

func Cross(p, q Vec) Vec

Cross returns the cross product p×q.

#### func Rotate ¶

func Rotate(p Vec, alpha float64, axis Vec) Vec

Rotate returns a new vector, rotated by alpha around the provided axis.

#### func Scale ¶

func Scale(f float64, p Vec) Vec

Scale returns the vector p scaled by f.

#### func Sub ¶

func Sub(p, q Vec) Vec

Sub returns the vector sum of p and -q.

#### func Unit ¶

func Unit(p Vec) Vec

Unit returns the unit vector colinear to p. Unit returns {NaN,NaN,NaN} for the zero vector.

func (p Vec) Add(q Vec) Vec

Add returns the vector sum of p and q.

#### func (Vec) Cross ¶

func (p Vec) Cross(q Vec) Vec

Cross returns the cross product p×q.

DEPRECATED: use r3.Cross.

#### func (Vec) Dot ¶

func (p Vec) Dot(q Vec) float64

Dot returns the dot product p·q.

DEPRECATED: use r3.Dot.

#### func (Vec) Rotate ¶

func (p Vec) Rotate(alpha float64, axis Vec) Vec

Rotate returns a new vector, rotated by alpha around the provided axis.

DEPRECATED: use r3.Rotate

#### func (Vec) Scale ¶

func (p Vec) Scale(f float64) Vec

Scale returns the vector p scaled by f.

DEPRECATED: use r3.Scale.

#### func (Vec) Sub ¶

func (p Vec) Sub(q Vec) Vec

Sub returns the vector sum of p and -q.

DEPRECATED: use r3.Sub.