ln: github.com/fogleman/ln/ln Index | Files

package ln

import "github.com/fogleman/ln/ln"

Index

Package Files

axis.go box.go common.go cone.go csg.go cube.go cylinder.go filter.go function.go hit.go matrix.go mesh.go obj.go path.go plane.go ray.go scene.go shape.go sphere.go stl.go tree.go triangle.go util.go vector.go

Constants

const EPS = 1e-9
const INF = 1e9

Variables

var ClipBox = Box{Vector{-1, -1, -1}, Vector{1, 1, 1}}
var NoHit = Hit{nil, INF}

func Degrees Uses

func Degrees(radians float64) float64

func Median Uses

func Median(items []float64) float64

func ParseFloats Uses

func ParseFloats(items []string) []float64

func Radians Uses

func Radians(degrees float64) float64

func SaveBinarySTL Uses

func SaveBinarySTL(path string, mesh *Mesh) error

type Axis Uses

type Axis uint8
const (
    AxisNone Axis = iota
    AxisX
    AxisY
    AxisZ
)

type BooleanShape Uses

type BooleanShape struct {
    Op   Op
    A, B Shape
}

func (*BooleanShape) BoundingBox Uses

func (s *BooleanShape) BoundingBox() Box

func (*BooleanShape) Compile Uses

func (s *BooleanShape) Compile()

func (*BooleanShape) Contains Uses

func (s *BooleanShape) Contains(v Vector, f float64) bool

func (*BooleanShape) Filter Uses

func (s *BooleanShape) Filter(v Vector) (Vector, bool)

func (*BooleanShape) Intersect Uses

func (s *BooleanShape) Intersect(r Ray) Hit

func (*BooleanShape) Paths Uses

func (s *BooleanShape) Paths() Paths

type Box Uses

type Box struct {
    Min, Max Vector
}

func BoxForShapes Uses

func BoxForShapes(shapes []Shape) Box

func BoxForTriangles Uses

func BoxForTriangles(shapes []*Triangle) Box

func BoxForVectors Uses

func BoxForVectors(vectors []Vector) Box

func (Box) Anchor Uses

func (a Box) Anchor(anchor Vector) Vector

func (Box) Center Uses

func (a Box) Center() Vector

func (Box) Contains Uses

func (a Box) Contains(b Vector) bool

func (Box) Extend Uses

func (a Box) Extend(b Box) Box

func (*Box) Intersect Uses

func (b *Box) Intersect(r Ray) (float64, float64)

func (*Box) Partition Uses

func (b *Box) Partition(axis Axis, point float64) (left, right bool)

func (Box) Size Uses

func (a Box) Size() Vector

type ClipFilter Uses

type ClipFilter struct {
    Matrix Matrix
    Eye    Vector
    Scene  *Scene
}

func (*ClipFilter) Filter Uses

func (f *ClipFilter) Filter(v Vector) (Vector, bool)

type Cone Uses

type Cone struct {
    Radius float64
    Height float64
}

func NewCone Uses

func NewCone(radius, height float64) *Cone

func (*Cone) BoundingBox Uses

func (c *Cone) BoundingBox() Box

func (*Cone) Compile Uses

func (c *Cone) Compile()

func (*Cone) Contains Uses

func (c *Cone) Contains(v Vector, f float64) bool

func (*Cone) Intersect Uses

func (shape *Cone) Intersect(ray Ray) Hit

func (*Cone) Paths Uses

func (c *Cone) Paths() Paths

type Cube Uses

type Cube struct {
    Min Vector
    Max Vector
    Box Box
}

func NewCube Uses

func NewCube(min, max Vector) *Cube

func (*Cube) BoundingBox Uses

func (c *Cube) BoundingBox() Box

func (*Cube) Compile Uses

func (c *Cube) Compile()

func (*Cube) Contains Uses

func (c *Cube) Contains(v Vector, f float64) bool

func (*Cube) Intersect Uses

func (c *Cube) Intersect(r Ray) Hit

func (*Cube) Paths Uses

func (c *Cube) Paths() Paths

type Cylinder Uses

type Cylinder struct {
    Radius float64
    Z0, Z1 float64
}

func NewCylinder Uses

func NewCylinder(radius, z0, z1 float64) *Cylinder

func (*Cylinder) BoundingBox Uses

func (c *Cylinder) BoundingBox() Box

func (*Cylinder) Compile Uses

func (c *Cylinder) Compile()

func (*Cylinder) Contains Uses

func (c *Cylinder) Contains(v Vector, f float64) bool

func (*Cylinder) Intersect Uses

func (shape *Cylinder) Intersect(ray Ray) Hit

func (*Cylinder) Paths Uses

func (c *Cylinder) Paths() Paths

type Direction Uses

type Direction int
const (
    Above Direction = iota
    Below
)

type EmptyShape Uses

type EmptyShape struct {
}

func (*EmptyShape) BoundingBox Uses

func (s *EmptyShape) BoundingBox() Box

func (*EmptyShape) Compile Uses

func (s *EmptyShape) Compile()

func (*EmptyShape) Contains Uses

func (s *EmptyShape) Contains(v Vector, f float64) bool

func (*EmptyShape) Intersect Uses

func (s *EmptyShape) Intersect(r Ray) Hit

func (*EmptyShape) Paths Uses

func (s *EmptyShape) Paths() Paths

type Filter Uses

type Filter interface {
    Filter(v Vector) (Vector, bool)
}

type Function Uses

type Function struct {
    Function  func(x, y float64) float64
    Box       Box
    Direction Direction
}

func (*Function) BoundingBox Uses

func (f *Function) BoundingBox() Box

func (*Function) Compile Uses

func (f *Function) Compile()

func (*Function) Contains Uses

func (f *Function) Contains(v Vector, eps float64) bool

func (*Function) Intersect Uses

func (f *Function) Intersect(ray Ray) Hit

func (*Function) Paths Uses

func (f *Function) Paths() Paths

func (*Function) Paths1 Uses

func (f *Function) Paths1() Paths

func (*Function) Paths3 Uses

func (f *Function) Paths3() Paths

type Hit Uses

type Hit struct {
    Shape Shape
    T     float64
}

func (Hit) Max Uses

func (a Hit) Max(b Hit) Hit

func (Hit) Min Uses

func (a Hit) Min(b Hit) Hit

func (Hit) Ok Uses

func (hit Hit) Ok() bool

type Matrix Uses

type Matrix struct {
    // contains filtered or unexported fields
}

func Frustum Uses

func Frustum(l, r, b, t, n, f float64) Matrix

func Identity Uses

func Identity() Matrix

func LookAt Uses

func LookAt(eye, center, up Vector) Matrix

func Orthographic Uses

func Orthographic(l, r, b, t, n, f float64) Matrix

func Perspective Uses

func Perspective(fovy, aspect, near, far float64) Matrix

func Rotate Uses

func Rotate(v Vector, a float64) Matrix

func Scale Uses

func Scale(v Vector) Matrix

func Translate Uses

func Translate(v Vector) Matrix

func (Matrix) Determinant Uses

func (a Matrix) Determinant() float64

func (Matrix) Frustum Uses

func (m Matrix) Frustum(l, r, b, t, n, f float64) Matrix

func (Matrix) Inverse Uses

func (a Matrix) Inverse() Matrix

func (Matrix) Mul Uses

func (a Matrix) Mul(b Matrix) Matrix

func (Matrix) MulBox Uses

func (a Matrix) MulBox(box Box) Box

func (Matrix) MulDirection Uses

func (a Matrix) MulDirection(b Vector) Vector

func (Matrix) MulPosition Uses

func (a Matrix) MulPosition(b Vector) Vector

func (Matrix) MulPositionW Uses

func (a Matrix) MulPositionW(b Vector) Vector

func (Matrix) MulRay Uses

func (a Matrix) MulRay(b Ray) Ray

func (Matrix) Orthographic Uses

func (m Matrix) Orthographic(l, r, b, t, n, f float64) Matrix

func (Matrix) Perspective Uses

func (m Matrix) Perspective(fovy, aspect, near, far float64) Matrix

func (Matrix) Rotate Uses

func (m Matrix) Rotate(v Vector, a float64) Matrix

func (Matrix) Scale Uses

func (m Matrix) Scale(v Vector) Matrix

func (Matrix) Translate Uses

func (m Matrix) Translate(v Vector) Matrix

func (Matrix) Transpose Uses

func (a Matrix) Transpose() Matrix

type Mesh Uses

type Mesh struct {
    Box       Box
    Triangles []*Triangle
    Tree      *Tree
}

func LoadBinarySTL Uses

func LoadBinarySTL(path string) (*Mesh, error)

func LoadOBJ Uses

func LoadOBJ(path string) (*Mesh, error)

func LoadSTL Uses

func LoadSTL(path string) (*Mesh, error)

func NewMesh Uses

func NewMesh(triangles []*Triangle) *Mesh

func (*Mesh) BoundingBox Uses

func (m *Mesh) BoundingBox() Box

func (*Mesh) Compile Uses

func (m *Mesh) Compile()

func (*Mesh) Contains Uses

func (m *Mesh) Contains(v Vector, f float64) bool

func (*Mesh) FitInside Uses

func (m *Mesh) FitInside(box Box, anchor Vector)

func (*Mesh) Intersect Uses

func (m *Mesh) Intersect(r Ray) Hit

func (*Mesh) MoveTo Uses

func (m *Mesh) MoveTo(position, anchor Vector)

func (*Mesh) Paths Uses

func (m *Mesh) Paths() Paths

func (*Mesh) SaveBinarySTL Uses

func (m *Mesh) SaveBinarySTL(path string) error

func (*Mesh) Transform Uses

func (m *Mesh) Transform(matrix Matrix)

func (*Mesh) UnitCube Uses

func (m *Mesh) UnitCube()

func (*Mesh) UpdateBoundingBox Uses

func (m *Mesh) UpdateBoundingBox()

func (*Mesh) Voxelize Uses

func (m *Mesh) Voxelize(size float64) []*Cube

type Node Uses

type Node struct {
    Axis   Axis
    Point  float64
    Shapes []Shape
    Left   *Node
    Right  *Node
}

func NewNode Uses

func NewNode(shapes []Shape) *Node

func (*Node) Intersect Uses

func (node *Node) Intersect(r Ray, tmin, tmax float64) Hit

func (*Node) IntersectShapes Uses

func (node *Node) IntersectShapes(r Ray) Hit

func (*Node) Partition Uses

func (node *Node) Partition(size int, axis Axis, point float64) (left, right []Shape)

func (*Node) PartitionScore Uses

func (node *Node) PartitionScore(axis Axis, point float64) int

func (*Node) Split Uses

func (node *Node) Split(depth int)

type Op Uses

type Op int
const (
    Intersection Op  = iota
    Difference
)

type OutlineCone Uses

type OutlineCone struct {
    Cone
    Eye Vector
    Up  Vector
}

func NewOutlineCone Uses

func NewOutlineCone(eye, up Vector, radius, height float64) *OutlineCone

func (*OutlineCone) Paths Uses

func (c *OutlineCone) Paths() Paths

type OutlineCylinder Uses

type OutlineCylinder struct {
    Cylinder
    Eye Vector
    Up  Vector
}

func NewOutlineCylinder Uses

func NewOutlineCylinder(eye, up Vector, radius, z0, z1 float64) *OutlineCylinder

func (*OutlineCylinder) Paths Uses

func (c *OutlineCylinder) Paths() Paths

type OutlineSphere Uses

type OutlineSphere struct {
    Sphere
    Eye Vector
    Up  Vector
}

func NewOutlineSphere Uses

func NewOutlineSphere(eye, up, center Vector, radius float64) *OutlineSphere

func (*OutlineSphere) Paths Uses

func (s *OutlineSphere) Paths() Paths

type Path Uses

type Path []Vector

func (Path) BoundingBox Uses

func (p Path) BoundingBox() Box

func (Path) Chop Uses

func (p Path) Chop(step float64) Path

func (Path) Filter Uses

func (p Path) Filter(f Filter) Paths

func (Path) Print Uses

func (p Path) Print()

func (Path) Simplify Uses

func (p Path) Simplify(threshold float64) Path

func (Path) String Uses

func (p Path) String() string

func (Path) ToSVG Uses

func (p Path) ToSVG() string

func (Path) Transform Uses

func (p Path) Transform(matrix Matrix) Path

type Paths Uses

type Paths []Path

func (Paths) BoundingBox Uses

func (p Paths) BoundingBox() Box

func (Paths) Chop Uses

func (p Paths) Chop(step float64) Paths

func (Paths) Filter Uses

func (p Paths) Filter(f Filter) Paths

func (Paths) Print Uses

func (p Paths) Print()

func (Paths) Simplify Uses

func (p Paths) Simplify(threshold float64) Paths

func (Paths) String Uses

func (p Paths) String() string

func (Paths) ToSVG Uses

func (p Paths) ToSVG(width, height float64) string

func (Paths) Transform Uses

func (p Paths) Transform(matrix Matrix) Paths

func (Paths) WriteToPNG Uses

func (p Paths) WriteToPNG(path string, width, height float64)

func (Paths) WriteToSVG Uses

func (p Paths) WriteToSVG(path string, width, height float64) error

func (Paths) WriteToTXT Uses

func (p Paths) WriteToTXT(path string) error

type Plane Uses

type Plane struct {
    Point  Vector
    Normal Vector
}

func (*Plane) IntersectMesh Uses

func (p *Plane) IntersectMesh(m *Mesh) Paths

func (*Plane) IntersectSegment Uses

func (p *Plane) IntersectSegment(v0, v1 Vector) (Vector, bool)

func (*Plane) IntersectTriangle Uses

func (p *Plane) IntersectTriangle(t *Triangle) (Vector, Vector, bool)

type Ray Uses

type Ray struct {
    Origin, Direction Vector
}

func (Ray) Position Uses

func (r Ray) Position(t float64) Vector

type STLHeader Uses

type STLHeader struct {
    Count uint32
    // contains filtered or unexported fields
}

type STLTriangle Uses

type STLTriangle struct {
    V1, V2, V3 [3]float32
    // contains filtered or unexported fields
}

type Scene Uses

type Scene struct {
    Shapes []Shape
    Tree   *Tree
}

func (*Scene) Add Uses

func (s *Scene) Add(shape Shape)

func (*Scene) Compile Uses

func (s *Scene) Compile()

func (*Scene) Intersect Uses

func (s *Scene) Intersect(r Ray) Hit

func (*Scene) Paths Uses

func (s *Scene) Paths() Paths

func (*Scene) Render Uses

func (s *Scene) Render(eye, center, up Vector, width, height, fovy, near, far, step float64) Paths

func (*Scene) RenderWithMatrix Uses

func (s *Scene) RenderWithMatrix(matrix Matrix, eye Vector, width, height, step float64) Paths

func (*Scene) Visible Uses

func (s *Scene) Visible(eye, point Vector) bool

type Shape Uses

type Shape interface {
    Compile()
    BoundingBox() Box
    Contains(Vector, float64) bool
    Intersect(Ray) Hit
    Paths() Paths
}

func NewBooleanShape Uses

func NewBooleanShape(op Op, shapes ...Shape) Shape

func NewDifference Uses

func NewDifference(shapes ...Shape) Shape

func NewFunction Uses

func NewFunction(function func(x, y float64) float64, box Box, direction Direction) Shape

func NewIntersection Uses

func NewIntersection(shapes ...Shape) Shape

func NewTransformedOutlineCone Uses

func NewTransformedOutlineCone(eye, up, v0, v1 Vector, radius float64) Shape

func NewTransformedOutlineCylinder Uses

func NewTransformedOutlineCylinder(eye, up, v0, v1 Vector, radius float64) Shape

func NewTransformedShape Uses

func NewTransformedShape(s Shape, m Matrix) Shape

type Sphere Uses

type Sphere struct {
    Center Vector
    Radius float64
    Box    Box
}

func NewSphere Uses

func NewSphere(center Vector, radius float64) *Sphere

func (*Sphere) BoundingBox Uses

func (s *Sphere) BoundingBox() Box

func (*Sphere) Compile Uses

func (s *Sphere) Compile()

func (*Sphere) Contains Uses

func (s *Sphere) Contains(v Vector, f float64) bool

func (*Sphere) Intersect Uses

func (s *Sphere) Intersect(r Ray) Hit

func (*Sphere) Paths Uses

func (s *Sphere) Paths() Paths

func (*Sphere) Paths2 Uses

func (s *Sphere) Paths2() Paths

func (*Sphere) Paths3 Uses

func (s *Sphere) Paths3() Paths

func (*Sphere) Paths4 Uses

func (s *Sphere) Paths4() Paths

type TransformedShape Uses

type TransformedShape struct {
    Shape
    Matrix  Matrix
    Inverse Matrix
}

func (*TransformedShape) BoundingBox Uses

func (s *TransformedShape) BoundingBox() Box

func (*TransformedShape) Contains Uses

func (s *TransformedShape) Contains(v Vector, f float64) bool

func (*TransformedShape) Intersect Uses

func (s *TransformedShape) Intersect(r Ray) Hit

func (*TransformedShape) Paths Uses

func (s *TransformedShape) Paths() Paths

type Tree Uses

type Tree struct {
    Box  Box
    Root *Node
}

func NewTree Uses

func NewTree(shapes []Shape) *Tree

func (*Tree) Intersect Uses

func (tree *Tree) Intersect(r Ray) Hit

type Triangle Uses

type Triangle struct {
    V1, V2, V3 Vector
    Box        Box
}

func NewTriangle Uses

func NewTriangle(v1, v2, v3 Vector) *Triangle

func (*Triangle) BoundingBox Uses

func (t *Triangle) BoundingBox() Box

func (*Triangle) Compile Uses

func (t *Triangle) Compile()

func (*Triangle) Contains Uses

func (t *Triangle) Contains(v Vector, f float64) bool

func (*Triangle) Intersect Uses

func (t *Triangle) Intersect(r Ray) Hit

func (*Triangle) Paths Uses

func (t *Triangle) Paths() Paths

func (*Triangle) UpdateBoundingBox Uses

func (t *Triangle) UpdateBoundingBox()

type Vector Uses

type Vector struct {
    X, Y, Z float64
}

func LatLngToXYZ Uses

func LatLngToXYZ(lat, lng, radius float64) Vector

func RandomUnitVector Uses

func RandomUnitVector() Vector

func (Vector) Add Uses

func (a Vector) Add(b Vector) Vector

func (Vector) AddScalar Uses

func (a Vector) AddScalar(b float64) Vector

func (Vector) Cross Uses

func (a Vector) Cross(b Vector) Vector

func (Vector) Distance Uses

func (a Vector) Distance(b Vector) float64

func (Vector) DistanceSquared Uses

func (a Vector) DistanceSquared(b Vector) float64

func (Vector) Div Uses

func (a Vector) Div(b Vector) Vector

func (Vector) DivScalar Uses

func (a Vector) DivScalar(b float64) Vector

func (Vector) Dot Uses

func (a Vector) Dot(b Vector) float64

func (Vector) Length Uses

func (a Vector) Length() float64

func (Vector) LengthSquared Uses

func (a Vector) LengthSquared() float64

func (Vector) Max Uses

func (a Vector) Max(b Vector) Vector

func (Vector) Min Uses

func (a Vector) Min(b Vector) Vector

func (Vector) MinAxis Uses

func (a Vector) MinAxis() Vector

func (Vector) MinComponent Uses

func (a Vector) MinComponent() float64

func (Vector) Mul Uses

func (a Vector) Mul(b Vector) Vector

func (Vector) MulScalar Uses

func (a Vector) MulScalar(b float64) Vector

func (Vector) Normalize Uses

func (a Vector) Normalize() Vector

func (Vector) SegmentDistance Uses

func (p Vector) SegmentDistance(v Vector, w Vector) float64

func (Vector) Sub Uses

func (a Vector) Sub(b Vector) Vector

func (Vector) SubScalar Uses

func (a Vector) SubScalar(b float64) Vector

Package ln imports 11 packages (graph) and is imported by 3 packages. Updated 2018-11-28. Refresh now. Tools for package owners.