Documentation ¶
Index ¶
- func FloatInRange(rnd Rnd, min float64, max float64) float64
- type Ray
- type Rnd
- type Unit
- type Vec
- func (v Vec) Add(v2 Vec) Vec
- func (v Vec) Cross(v2 Vec) Vec
- func (v Vec) Div(v2 Vec) Vec
- func (v Vec) Dot(v2 Vec) float64
- func (v Vec) Inv() Vec
- func (v Vec) Len() float64
- func (v Vec) LenSquared() float64
- func (v Vec) Max(v2 Vec) Vec
- func (v Vec) Min(v2 Vec) Vec
- func (v Vec) Mul(v2 Vec) Vec
- func (v Vec) Reflect(n Vec) Vec
- func (v Vec) Scale(n float64) Vec
- func (v Vec) Sub(v2 Vec) Vec
- func (v Vec) ToUnit() Unit
- func (v Vec) Zero() bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Ray ¶
Ray represents a ray defined by its origin and direction
type Unit ¶
type Unit struct {
Vec
}
Unit represents a unit vector of length 1.
type Vec ¶
Vec represents a 3-element vector.
func RandVecInDisk ¶
RandVecInDisk creates a random geometry.Vec within a unit disk.
func RandVecInSphere ¶
RandVecInSphere creates a random geometry.Vec within a unit sphere.
This algorithm works by selecting a random vector inside the unit cube, and then discarding the vector if it falls outside the sphere. On average, we discard the vector 47.6% of the time.
func (Vec) LenSquared ¶
LenSquared returns the square of the vector's length.
Click to show internal directories.
Click to hide internal directories.