geo: github.com/golang/geo/r3 Index | Files

package r3

import "github.com/golang/geo/r3"

Package r3 implements types and functions for working with geometry in ℝ³.

See ../s2 for a more detailed overview.

Index

Package Files

doc.go precisevector.go vector.go

type Axis Uses

type Axis int

Axis enumerates the 3 axes of ℝ³.

const (
    XAxis Axis = iota
    YAxis
    ZAxis
)

The three axes of ℝ³.

type PreciseVector Uses

type PreciseVector struct {
    X, Y, Z *big.Float
}

PreciseVector represents a point in ℝ³ using high-precision values. Note that this is NOT a complete implementation because there are some operations that Vector supports that are not feasible with arbitrary precision math. (e.g., methods that need divison like Normalize, or methods needing a square root operation such as Norm)

func NewPreciseVector Uses

func NewPreciseVector(x, y, z float64) PreciseVector

NewPreciseVector creates a high precision vector from the given floating point values.

func PreciseVectorFromVector Uses

func PreciseVectorFromVector(v Vector) PreciseVector

PreciseVectorFromVector creates a high precision vector from the given Vector.

func (PreciseVector) Abs Uses

func (v PreciseVector) Abs() PreciseVector

Abs returns the vector with nonnegative components.

func (PreciseVector) Add Uses

func (v PreciseVector) Add(ov PreciseVector) PreciseVector

Add returns the standard vector sum of v and ov.

func (PreciseVector) Cross Uses

func (v PreciseVector) Cross(ov PreciseVector) PreciseVector

Cross returns the standard cross product of v and ov.

func (PreciseVector) Dot Uses

func (v PreciseVector) Dot(ov PreciseVector) *big.Float

Dot returns the standard dot product of v and ov.

func (PreciseVector) Equal Uses

func (v PreciseVector) Equal(ov PreciseVector) bool

Equal reports whether v and ov are equal.

func (PreciseVector) IsUnit Uses

func (v PreciseVector) IsUnit() bool

IsUnit reports whether this vector is of unit length.

func (PreciseVector) LargestComponent Uses

func (v PreciseVector) LargestComponent() Axis

LargestComponent returns the axis that represents the largest component in this vector.

func (PreciseVector) Mul Uses

func (v PreciseVector) Mul(f *big.Float) PreciseVector

Mul returns the standard scalar product of v and f.

func (PreciseVector) MulByFloat64 Uses

func (v PreciseVector) MulByFloat64(f float64) PreciseVector

MulByFloat64 returns the standard scalar product of v and f.

func (PreciseVector) Norm2 Uses

func (v PreciseVector) Norm2() *big.Float

Norm2 returns the square of the norm.

func (PreciseVector) SmallestComponent Uses

func (v PreciseVector) SmallestComponent() Axis

SmallestComponent returns the axis that represents the smallest component in this vector.

func (PreciseVector) String Uses

func (v PreciseVector) String() string

func (PreciseVector) Sub Uses

func (v PreciseVector) Sub(ov PreciseVector) PreciseVector

Sub returns the standard vector difference of v and ov.

func (PreciseVector) Vector Uses

func (v PreciseVector) Vector() Vector

Vector returns this precise vector converted to a Vector.

type Vector Uses

type Vector struct {
    X, Y, Z float64
}

Vector represents a point in ℝ³.

func (Vector) Abs Uses

func (v Vector) Abs() Vector

Abs returns the vector with nonnegative components.

func (Vector) Add Uses

func (v Vector) Add(ov Vector) Vector

Add returns the standard vector sum of v and ov.

func (Vector) Angle Uses

func (v Vector) Angle(ov Vector) s1.Angle

Angle returns the angle between v and ov.

func (Vector) ApproxEqual Uses

func (v Vector) ApproxEqual(ov Vector) bool

ApproxEqual reports whether v and ov are equal within a small epsilon.

func (Vector) Cmp Uses

func (v Vector) Cmp(ov Vector) int

Cmp compares v and ov lexicographically and returns:

-1 if v <  ov
 0 if v == ov
+1 if v >  ov

This method is based on C++'s std::lexicographical_compare. Two entities are compared element by element with the given operator. The first mismatch defines which is less (or greater) than the other. If both have equivalent values they are lexicographically equal.

func (Vector) Cross Uses

func (v Vector) Cross(ov Vector) Vector

Cross returns the standard cross product of v and ov.

func (Vector) Distance Uses

func (v Vector) Distance(ov Vector) float64

Distance returns the Euclidean distance between v and ov.

func (Vector) Dot Uses

func (v Vector) Dot(ov Vector) float64

Dot returns the standard dot product of v and ov.

func (Vector) IsUnit Uses

func (v Vector) IsUnit() bool

IsUnit returns whether this vector is of approximately unit length.

func (Vector) LargestComponent Uses

func (v Vector) LargestComponent() Axis

LargestComponent returns the axis that represents the largest component in this vector.

func (Vector) Mul Uses

func (v Vector) Mul(m float64) Vector

Mul returns the standard scalar product of v and m.

func (Vector) Norm Uses

func (v Vector) Norm() float64

Norm returns the vector's norm.

func (Vector) Norm2 Uses

func (v Vector) Norm2() float64

Norm2 returns the square of the norm.

func (Vector) Normalize Uses

func (v Vector) Normalize() Vector

Normalize returns a unit vector in the same direction as v.

func (Vector) Ortho Uses

func (v Vector) Ortho() Vector

Ortho returns a unit vector that is orthogonal to v. Ortho(-v) = -Ortho(v) for all v.

func (Vector) SmallestComponent Uses

func (v Vector) SmallestComponent() Axis

SmallestComponent returns the axis that represents the smallest component in this vector.

func (Vector) String Uses

func (v Vector) String() string

func (Vector) Sub Uses

func (v Vector) Sub(ov Vector) Vector

Sub returns the standard vector difference of v and ov.

Package r3 imports 4 packages (graph) and is imported by 16 packages. Updated 2017-11-07. Refresh now. Tools for package owners.