Documentation ¶
Index ¶
- func ByteQuadToVec2(b byte) vector.Vector2
- func Clamp(num float64, min float64, max float64) float64
- func FourByteQuadToVec2(b []byte) vector.Vector2
- func FromOctUV(e vector.Vector2) vector.Vector3
- func MapToOctUV(v vector.Vector3) vector.Vector2
- func MapToOctUVPrecise(v vector.Vector3, n int) vector.Vector2
- func PackAlg24(v vector.Vector3) []byte
- func PackCoarse24(v vector.Vector3) []byte
- func PackOct16(v vector.Vector3) []byte
- func PackOct24(v vector.Vector3) []byte
- func PackOct32(v vector.Vector3) []byte
- func PackOctQuad16(v vector.Vector3) []byte
- func PackOctQuad24(v vector.Vector3) []byte
- func PackOctQuad32(v vector.Vector3) []byte
- func ThreeByteQuadToVec2(b []byte) vector.Vector2
- func TwoByteQuadToVec2(b []byte) vector.Vector2
- func UnpackAlg24(b []byte) vector.Vector3
- func UnpackCoarse24(in []byte) vector.Vector3
- func UnpackOct16(b []byte) vector.Vector3
- func UnpackOct24(b []byte) vector.Vector3
- func UnpackOct32(b []byte) vector.Vector3
- func UnpackOctQuad16(b []byte) vector.Vector3
- func UnpackOctQuad24(b []byte) vector.Vector3
- func UnpackOctQuad32(b []byte) vector.Vector3
- func Vec2ToByteQuad(v vector.Vector2) byte
- func Vec2ToFourByteQuad(v vector.Vector2) []byte
- func Vec2ToThreeByteQuad(v vector.Vector2) []byte
- func Vec2ToTwoByteQuad(v vector.Vector2) []byte
- type Quadrant2D
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ByteQuadToVec2 ¶
ByteToVec2 calculates a Vector2 based on the encoded quadtree inside the byte.
func Clamp ¶
Clamp clamps the given value between the given minimum float and maximum float values. Returns the given value if it is within the min and max range.
func FourByteQuadToVec2 ¶
FourByteQuadToVec2 calculates a Vector2 based on the encoded quadtree inside the 4 bytes
func MapToOctUV ¶
MapToOctUV converts a 3D sphere's coordinates to a 2D octahedron UV.
func MapToOctUVPrecise ¶
MapToOctUVPrecise brute force finds an optimal UV coordinate that minimizes rounding error.
func PackAlg24 ¶
PackAlg24 converts the x y z components of a normalized vector into a 3 bytes for efficient transport. Uses trig to pack X into 12 bytes, Y into 11 bytes, and 1 to denote sign of Z.
func PackCoarse24 ¶
PackCoarse24 will convert each component of the vector into a single byte, and will return those bytes in an array where x is at index 0, and z is at index 2
func PackOct16 ¶
PackOct16 maps a unit vector to a 2D UV of a octahedron, and then writes the 2D coordinates to 2 bytes, 8bits per coordinate.
func PackOct24 ¶
PackOct24 maps a unit vector to a 2D UV of a octahedron, and then writes the 2D coordinates to 3 bytes, 12bits per coordinate.
func PackOct32 ¶
PackOct32 maps a unit vector to a 2D UV of a octahedron, and then writes the 2D coordinates to 4 bytes, 2 bytes per coordinate.
func PackOctQuad16 ¶
PackOctQuad16 maps a unit vector to a 2D UV of a octahedron, and then encodes the 2D coordinates inside a quad tree.
func PackOctQuad24 ¶
PackOctQuad24 maps a unit vector to a 2D UV of a octahedron, and then encodes the 2D coordinates inside a quad tree.
func PackOctQuad32 ¶
PackOctQuad32 maps a unit vector to a 2D UV of a octahedron, and then encodes the 2D coordinates inside a quad tree.
func ThreeByteQuadToVec2 ¶
ThreeByteQuadToVec2 calculates a Vector2 based on the encoded quadtree inside the 3 bytes
func TwoByteQuadToVec2 ¶
TwoByteQuadToVec2 calculates a Vector2 based on the encoded quadtree inside the 2 bytes
func UnpackAlg24 ¶
UnpackAlg24 will take a previously packed vector and extract it out of 3 bytes
func UnpackCoarse24 ¶
UnpackCoarse24 will take a previously packed vector and extract it out of 3 bytes
func UnpackOct16 ¶
UnpackOct16 reads in two 8bit numbers and converts from 2D octahedron UV to 3D unit sphere coordinates.
func UnpackOct24 ¶
UnpackOct24 reads in two 12bit numbers and converts from 2D octahedron UV to 3D unit sphere coordinates.
func UnpackOct32 ¶
UnpackOct32 reads in two 16bit numbers and converts from 2D octahedron UV to 3D unit sphere coordinates.
func UnpackOctQuad16 ¶
UnpackOctQuad16 builds a 2D coordinate from the encoded quadtree and then converts the 2D octahedron UV to 3D unit sphere coordinates.
func UnpackOctQuad24 ¶
UnpackOctQuad24 builds a 2D coordinate from the encoded quadtree and then converts the 2D octahedron UV to 3D unit sphere coordinates.
func UnpackOctQuad32 ¶
UnpackOctQuad32 builds a 2D coordinate from the encoded quadtree and then converts the 2D octahedron UV to 3D unit sphere coordinates.
func Vec2ToByteQuad ¶
Vec2ToByteQuad creates a quadtree of depth 4 and encodes itself into a single byte
func Vec2ToFourByteQuad ¶
Vec2ToFourByteQuad creates a quadtree of depth 16 and encodes itself in 4 bytes
func Vec2ToThreeByteQuad ¶
Vec2ToThreeByteQuad creates a quadtree of depth 12 and encodes itself in three bytes
func Vec2ToTwoByteQuad ¶
Vec2ToTwoByteQuad creates a quadtree of depth 8 and encodes itself in two bytes
Types ¶
type Quadrant2D ¶
type Quadrant2D int
Quadrant2D represents a quadrant in a 2D space.
const ( TopLeft Quadrant2D = iota TopRight BottomLeft BottomRight )
func QuadRecurse ¶
func QuadRecurse(in, min, max vector.Vector2, levels int) []Quadrant2D
QuadRecurse recursively builds a quad tree based on the given Vector2. The tree's depth is determined by the number of levels passed in.