Documentation ¶
Index ¶
- Constants
- Variables
- func Degrees(radians float64) float64
- func Median(items []float64) float64
- func ParseFloats(items []string) []float64
- func Radians(degrees float64) float64
- func SaveBinarySTL(path string, mesh *Mesh) error
- type Axis
- type BooleanShape
- type Box
- type ClipFilter
- type Cone
- type Cube
- type Cylinder
- type Direction
- type EmptyShape
- type Filter
- type Function
- type Hit
- type Matrix
- func Frustum(l, r, b, t, n, f float64) Matrix
- func Identity() Matrix
- func LookAt(eye, center, up Vector) Matrix
- func Orthographic(l, r, b, t, n, f float64) Matrix
- func Perspective(fovy, aspect, near, far float64) Matrix
- func Rotate(v Vector, a float64) Matrix
- func Scale(v Vector) Matrix
- func Translate(v Vector) Matrix
- func (a Matrix) Determinant() float64
- func (m Matrix) Frustum(l, r, b, t, n, f float64) Matrix
- func (a Matrix) Inverse() Matrix
- func (a Matrix) Mul(b Matrix) Matrix
- func (a Matrix) MulBox(box Box) Box
- func (a Matrix) MulDirection(b Vector) Vector
- func (a Matrix) MulPosition(b Vector) Vector
- func (a Matrix) MulPositionW(b Vector) Vector
- func (a Matrix) MulRay(b Ray) Ray
- func (m Matrix) Orthographic(l, r, b, t, n, f float64) Matrix
- func (m Matrix) Perspective(fovy, aspect, near, far float64) Matrix
- func (m Matrix) Rotate(v Vector, a float64) Matrix
- func (m Matrix) Scale(v Vector) Matrix
- func (m Matrix) Translate(v Vector) Matrix
- func (a Matrix) Transpose() Matrix
- type Mesh
- func (m *Mesh) BoundingBox() Box
- func (m *Mesh) Compile()
- func (m *Mesh) Contains(v Vector, f float64) bool
- func (m *Mesh) FitInside(box Box, anchor Vector)
- func (m *Mesh) Intersect(r Ray) Hit
- func (m *Mesh) MoveTo(position, anchor Vector)
- func (m *Mesh) Paths() Paths
- func (m *Mesh) SaveBinarySTL(path string) error
- func (m *Mesh) Transform(matrix Matrix)
- func (m *Mesh) UnitCube()
- func (m *Mesh) UpdateBoundingBox()
- func (m *Mesh) Voxelize(size float64) []*Cube
- type Node
- type Op
- type OutlineCone
- type OutlineCylinder
- type OutlineSphere
- type Path
- func (p Path) BoundingBox() Box
- func (p Path) Chop(step float64) Path
- func (p Path) Filter(f Filter) Paths
- func (p Path) Print()
- func (p *Path) Reverse()
- func (p Path) Simplify(threshold float64) Path
- func (p Path) String() string
- func (p Path) ToSVG() string
- func (p Path) Transform(matrix Matrix) Path
- type Paths
- func (p Paths) BoundingBox() Box
- func (p Paths) Chop(step float64) Paths
- func (p Paths) Filter(f Filter) Paths
- func (p *Paths) Optimize()
- func (p Paths) Print()
- func (p Paths) Simplify(threshold float64) Paths
- func (p Paths) String() string
- func (p Paths) ToSVG(width, height float64) string
- func (p Paths) Transform(matrix Matrix) Paths
- func (p Paths) WriteToPNG(path string, width, height float64)
- func (p Paths) WriteToSVG(path string, width, height float64) error
- func (p Paths) WriteToTXT(path string) error
- type Plane
- type Ray
- type STLHeader
- type STLTriangle
- type Scene
- func (s *Scene) Add(shape Shape)
- func (s *Scene) Compile()
- func (s *Scene) Intersect(r Ray) Hit
- func (s *Scene) Paths() Paths
- func (s *Scene) Render(eye, center, up Vector, width, height, fovy, near, far, step float64) Paths
- func (s *Scene) RenderWithMatrix(matrix Matrix, eye Vector, width, height, step float64) Paths
- func (s *Scene) Visible(eye, point Vector) bool
- type Shape
- func NewBooleanShape(op Op, shapes ...Shape) Shape
- func NewDifference(shapes ...Shape) Shape
- func NewFunction(function func(x, y float64) float64, box Box, direction Direction) Shape
- func NewIntersection(shapes ...Shape) Shape
- func NewTransformedOutlineCone(eye, up, v0, v1 Vector, radius float64) Shape
- func NewTransformedOutlineCylinder(eye, up, v0, v1 Vector, radius float64) Shape
- func NewTransformedShape(s Shape, m Matrix) Shape
- type Sphere
- type TransformedShape
- type Tree
- type Triangle
- type Vector
- func (a Vector) Add(b Vector) Vector
- func (a Vector) AddScalar(b float64) Vector
- func (a Vector) Cross(b Vector) Vector
- func (a Vector) Distance(b Vector) float64
- func (a Vector) DistanceSquared(b Vector) float64
- func (a Vector) Div(b Vector) Vector
- func (a Vector) DivScalar(b float64) Vector
- func (a Vector) Dot(b Vector) float64
- func (a Vector) Length() float64
- func (a Vector) LengthSquared() float64
- func (a Vector) Max(b Vector) Vector
- func (a Vector) Min(b Vector) Vector
- func (a Vector) MinAxis() Vector
- func (a Vector) MinComponent() float64
- func (a Vector) Mul(b Vector) Vector
- func (a Vector) MulScalar(b float64) Vector
- func (a Vector) Normalize() Vector
- func (p Vector) SegmentDistance(v Vector, w Vector) float64
- func (a Vector) Sub(b Vector) Vector
- func (a Vector) SubScalar(b float64) Vector
Constants ¶
View Source
const EPS = 1e-9
View Source
const INF = 1e9
Variables ¶
View Source
var ClipBox = Box{Vector{-1, -1, -1}, Vector{1, 1, 1}}
View Source
var NoHit = Hit{nil, INF}
Functions ¶
func ParseFloats ¶
func SaveBinarySTL ¶
Types ¶
type BooleanShape ¶
func (*BooleanShape) BoundingBox ¶
func (s *BooleanShape) BoundingBox() Box
func (*BooleanShape) Compile ¶
func (s *BooleanShape) Compile()
func (*BooleanShape) Intersect ¶
func (s *BooleanShape) Intersect(r Ray) Hit
func (*BooleanShape) Paths ¶
func (s *BooleanShape) Paths() Paths
type Box ¶
type Box struct {
Min, Max Vector
}
func BoxForShapes ¶
func BoxForTriangles ¶
func BoxForVectors ¶
type ClipFilter ¶
type Cone ¶
func (*Cone) BoundingBox ¶
type Cube ¶
func (*Cube) BoundingBox ¶
type EmptyShape ¶
type EmptyShape struct { }
func (*EmptyShape) BoundingBox ¶
func (s *EmptyShape) BoundingBox() Box
func (*EmptyShape) Compile ¶
func (s *EmptyShape) Compile()
func (*EmptyShape) Intersect ¶
func (s *EmptyShape) Intersect(r Ray) Hit
func (*EmptyShape) Paths ¶
func (s *EmptyShape) Paths() Paths
type Function ¶
func (*Function) BoundingBox ¶
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
func Orthographic ¶
func Perspective ¶
func (Matrix) Determinant ¶
func (Matrix) MulDirection ¶
func (Matrix) MulPosition ¶
func (Matrix) MulPositionW ¶
func (Matrix) Orthographic ¶
func (Matrix) Perspective ¶
type Mesh ¶
func LoadBinarySTL ¶
func (*Mesh) BoundingBox ¶
func (*Mesh) SaveBinarySTL ¶
func (*Mesh) UpdateBoundingBox ¶
func (m *Mesh) UpdateBoundingBox()
type OutlineCone ¶
func NewOutlineCone ¶
func NewOutlineCone(eye, up Vector, radius, height float64) *OutlineCone
func (*OutlineCone) Paths ¶
func (c *OutlineCone) Paths() Paths
type OutlineCylinder ¶
func NewOutlineCylinder ¶
func NewOutlineCylinder(eye, up Vector, radius, z0, z1 float64) *OutlineCylinder
func (*OutlineCylinder) Paths ¶
func (c *OutlineCylinder) Paths() Paths
type OutlineSphere ¶
func NewOutlineSphere ¶
func NewOutlineSphere(eye, up, center Vector, radius float64) *OutlineSphere
func (*OutlineSphere) Paths ¶
func (s *OutlineSphere) Paths() Paths
type Paths ¶
type Paths []Path
func (Paths) BoundingBox ¶
func (*Paths) Optimize ¶
func (p *Paths) Optimize()
Optimize will reorder the Vectors and Paths to produce continuous lines where possible. Useful for laser applications. Future iterations may use nearest neighbor but currently only exact matches are considered.
func (Paths) WriteToPNG ¶
func (Paths) WriteToTXT ¶
type Plane ¶
func (*Plane) IntersectMesh ¶
type STLTriangle ¶
type STLTriangle struct {
V1, V2, V3 [3]float32
// contains filtered or unexported fields
}
type Shape ¶
type Shape interface { Compile() BoundingBox() Box Contains(Vector, float64) bool Intersect(Ray) Hit Paths() Paths }
func NewBooleanShape ¶
func NewDifference ¶
func NewFunction ¶
func NewIntersection ¶
func NewTransformedShape ¶
type Sphere ¶
func (*Sphere) BoundingBox ¶
type TransformedShape ¶
func (*TransformedShape) BoundingBox ¶
func (s *TransformedShape) BoundingBox() Box
func (*TransformedShape) Intersect ¶
func (s *TransformedShape) Intersect(r Ray) Hit
func (*TransformedShape) Paths ¶
func (s *TransformedShape) Paths() Paths
type Triangle ¶
func NewTriangle ¶
func (*Triangle) BoundingBox ¶
func (*Triangle) UpdateBoundingBox ¶
func (t *Triangle) UpdateBoundingBox()
type Vector ¶
type Vector struct {
X, Y, Z float64
}
func LatLngToXYZ ¶
func RandomUnitVector ¶
func RandomUnitVector() Vector
func (Vector) DistanceSquared ¶
func (Vector) LengthSquared ¶
func (Vector) MinComponent ¶
Click to show internal directories.
Click to hide internal directories.