Documentation
¶
Overview ¶
Package vec contains basic vector math operations.
Index ¶
- Variables
- func ToDegrees(rad float64) float64
- func ToRadians(deg float64) float64
- type Vec
- func (v Vec) AsSpherical() (m float64, theta float64, phi float64)
- func (v Vec) Cross(w Vec) Vec
- func (v Vec) Distance(v2 Vec) float64
- func (v Vec) Dot(b Vec) float64
- func (v Vec) Info(str string)
- func (v Vec) Length() float64
- func (v Vec) Minus(v2 Vec) Vec
- func (v Vec) Mul(x float64) Vec
- func (v Vec) Plus(v2 Vec) Vec
Constants ¶
This section is empty.
Variables ¶
var I = Vec{1, 0, 0}
I is the unit vector on the x axis. Treat it as a const!
var J = Vec{0, 1, 0}
J is the unit vector on the y axis. Treat it as a const!
var K = Vec{0, 0, 1}
K is the unit vector on the z axis. Treat it as a const!
var Origin = Vec{0, 0, 0}
Origin is the point representing the zeo origin in 3D space. Treat it as a const!
Functions ¶
Types ¶
type Vec ¶
Vec is a 3 dimensional vector. It's represented as a point relative to the origin So we also use Vec as if they were points. But it's implementation should be considered as private
func Newd ¶
Newd creates new Vec vector from a magnitude and the direction angles m is the magnitude of the new vector, th is theta the angle from the x axis in the xy plane ph is phi the angle fron the xy plane toward the z axis.
func Newp ¶
Newp creates a new Vec vector from 2 points. The Vec represents the distance and angle from p1 to p1
func (Vec) AsSpherical ¶
AsSpherical returns the spherical coordinates of a Point returning length, theta, phi where theta is the angle from the the x axis in the xy plane and phi is the angle from the xy plane toward the z axis.