Documentation ¶
Overview ¶
Package r3 implements types and functions for working with geometry in ℝ³.
See ../s2 for a more detailed overview.
Index ¶
- type Axis
- type PreciseVector
- func (v PreciseVector) Abs() PreciseVector
- func (v PreciseVector) Add(ov PreciseVector) PreciseVector
- func (v PreciseVector) Cross(ov PreciseVector) PreciseVector
- func (v PreciseVector) Dot(ov PreciseVector) *big.Float
- func (v PreciseVector) Equal(ov PreciseVector) bool
- func (v PreciseVector) IsUnit() bool
- func (v PreciseVector) IsZero() bool
- func (v PreciseVector) LargestComponent() Axis
- func (v PreciseVector) Mul(f *big.Float) PreciseVector
- func (v PreciseVector) MulByFloat64(f float64) PreciseVector
- func (v PreciseVector) Norm2() *big.Float
- func (v PreciseVector) SmallestComponent() Axis
- func (v PreciseVector) String() string
- func (v PreciseVector) Sub(ov PreciseVector) PreciseVector
- func (v PreciseVector) Vector() Vector
- type Vector
- func (v Vector) Abs() Vector
- func (v Vector) Add(ov Vector) Vector
- func (v Vector) Angle(ov Vector) s1.Angle
- func (v Vector) ApproxEqual(ov Vector) bool
- func (v Vector) Cmp(ov Vector) int
- func (v Vector) Cross(ov Vector) Vector
- func (v Vector) Distance(ov Vector) float64
- func (v Vector) Dot(ov Vector) float64
- func (v Vector) IsUnit() bool
- func (v Vector) LargestComponent() Axis
- func (v Vector) Mul(m float64) Vector
- func (v Vector) Norm() float64
- func (v Vector) Norm2() float64
- func (v Vector) Normalize() Vector
- func (v Vector) Ortho() Vector
- func (v Vector) SmallestComponent() Axis
- func (v Vector) String() string
- func (v Vector) Sub(ov Vector) Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PreciseVector ¶
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 division like Normalize, or methods needing a square root operation such as Norm)
func NewPreciseVector ¶
func NewPreciseVector(x, y, z float64) PreciseVector
NewPreciseVector creates a high precision vector from the given floating point values.
func PreciseVectorFromVector ¶
func PreciseVectorFromVector(v Vector) PreciseVector
PreciseVectorFromVector creates a high precision vector from the given Vector.
func (PreciseVector) Abs ¶
func (v PreciseVector) Abs() PreciseVector
Abs returns the vector with nonnegative components.
func (PreciseVector) Add ¶
func (v PreciseVector) Add(ov PreciseVector) PreciseVector
Add returns the standard vector sum of v and ov.
func (PreciseVector) Cross ¶
func (v PreciseVector) Cross(ov PreciseVector) PreciseVector
Cross returns the standard cross product of v and ov.
func (PreciseVector) Dot ¶
func (v PreciseVector) Dot(ov PreciseVector) *big.Float
Dot returns the standard dot product of v and ov.
func (PreciseVector) Equal ¶
func (v PreciseVector) Equal(ov PreciseVector) bool
Equal reports whether v and ov are equal.
func (PreciseVector) IsUnit ¶
func (v PreciseVector) IsUnit() bool
IsUnit reports whether this vector is of unit length.
func (PreciseVector) IsZero ¶
func (v PreciseVector) IsZero() bool
IsZero reports if this vector is exactly 0 efficiently.
func (PreciseVector) LargestComponent ¶
func (v PreciseVector) LargestComponent() Axis
LargestComponent returns the axis that represents the largest component in this vector.
func (PreciseVector) Mul ¶
func (v PreciseVector) Mul(f *big.Float) PreciseVector
Mul returns the standard scalar product of v and f.
func (PreciseVector) MulByFloat64 ¶
func (v PreciseVector) MulByFloat64(f float64) PreciseVector
MulByFloat64 returns the standard scalar product of v and f.
func (PreciseVector) Norm2 ¶
func (v PreciseVector) Norm2() *big.Float
Norm2 returns the square of the norm.
func (PreciseVector) SmallestComponent ¶
func (v PreciseVector) SmallestComponent() Axis
SmallestComponent returns the axis that represents the smallest component in this vector.
func (PreciseVector) String ¶
func (v PreciseVector) String() string
func (PreciseVector) Sub ¶
func (v PreciseVector) Sub(ov PreciseVector) PreciseVector
Sub returns the standard vector difference of v and ov.
func (PreciseVector) Vector ¶
func (v PreciseVector) Vector() Vector
Vector returns this precise vector converted to a Vector.
type Vector ¶
type Vector struct {
X, Y, Z float64
}
Vector represents a point in ℝ³.
func (Vector) ApproxEqual ¶
ApproxEqual reports whether v and ov are equal within a small epsilon.
func (Vector) Cmp ¶
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) LargestComponent ¶
LargestComponent returns the axis that represents the largest component in this vector.
func (Vector) Ortho ¶
Ortho returns a unit vector that is orthogonal to v. Ortho(-v) = -Ortho(v) for all v.
func (Vector) SmallestComponent ¶
SmallestComponent returns the axis that represents the smallest component in this vector.