Documentation ¶
Index ¶
- Constants
- func Divide(s Shape, threshold int)
- func FaceFromPoint(point geom.Tuple4) int
- func Flatten(g *Group, groups *[]*Group)
- func IntersectRayWithBox(ray geom.Ray, BoundingBox *BoundingBox) bool
- func IntersectionAllowed(op string, lhit, inl, inr bool) bool
- func MakeSubGroup(g *Group, shapes ...Shape)
- func PartitionChildren(g *Group) (*Group, *Group)
- func SphericalMap(p geom.Tuple4) (float64, float64)
- func SplitBounds(b1 *BoundingBox) (*BoundingBox, *BoundingBox)
- type AlignCheck
- type Basic
- type BoundingBox
- func BoundsOf(shape Shape) *BoundingBox
- func NewBoundingBox(pointA geom.Tuple4, pointB geom.Tuple4) *BoundingBox
- func NewBoundingBoxF(x1, y1, z1, x2, y2, z2 float64) *BoundingBox
- func NewEmptyBoundingBox() *BoundingBox
- func ParentSpaceBounds(shape Shape) *BoundingBox
- func TransformBoundingBox(bbox *BoundingBox, m1 geom.Mat4x4) *BoundingBox
- type Cube
- func (c *Cube) GetInverse() geom.Mat4x4
- func (c *Cube) GetInverseTranspose() geom.Mat4x4
- func (c *Cube) GetMaterial() material.Material
- func (c *Cube) GetParent() Shape
- func (c *Cube) GetTransform() geom.Mat4x4
- func (c *Cube) ID() int64
- func (c *Cube) Lbl() string
- func (c *Cube) SetMaterial(material material.Material)
- func (c *Cube) SetParent(shape Shape)
- func (c *Cube) SetTransform(transform geom.Mat4x4)
- type Cylinder
- func (c *Cylinder) GetInverse() geom.Mat4x4
- func (c *Cylinder) GetInverseTranspose() geom.Mat4x4
- func (c *Cylinder) GetMaterial() material.Material
- func (c *Cylinder) GetParent() Shape
- func (c *Cylinder) GetTransform() geom.Mat4x4
- func (c *Cylinder) ID() int64
- func (c *Cylinder) Init()
- func (c *Cylinder) Lbl() string
- func (c *Cylinder) SetMaterial(material material.Material)
- func (c *Cylinder) SetParent(shape Shape)
- func (c *Cylinder) SetTransform(transform geom.Mat4x4)
- type Group
- func (g *Group) AddChild(s Shape)
- func (g *Group) AddChildren(shapes ...Shape)
- func (g *Group) Bounds()
- func (g *Group) BoundsToCube() *Cube
- func (g *Group) CastsShadow() bool
- func (g *Group) GetInverse() geom.Mat4x4
- func (g *Group) GetInverseTranspose() geom.Mat4x4
- func (g *Group) GetLocalRay() geom.Ray
- func (g *Group) GetMaterial() material.Material
- func (g *Group) GetParent() Shape
- func (g *Group) GetTransform() geom.Mat4x4
- func (g *Group) ID() int64
- func (g *Group) Lbl() string
- func (g *Group) Name() string
- func (g *Group) NormalAtLocal(point geom.Tuple4, intersection *Intersection) geom.Tuple4
- func (g *Group) SetMaterial(material material.Material)
- func (g *Group) SetParent(shape Shape)
- func (g *Group) SetTransform(transform geom.Mat4x4)
- type Intersection
- type Intersections
- type Plane
- func (p *Plane) GetInverse() geom.Mat4x4
- func (p *Plane) GetInverseTranspose() geom.Mat4x4
- func (p *Plane) GetMaterial() material.Material
- func (p *Plane) GetParent() Shape
- func (p *Plane) GetTransform() geom.Mat4x4
- func (p *Plane) ID() int64
- func (p *Plane) Lbl() string
- func (p *Plane) SetMaterial(m material.Material)
- func (p *Plane) SetParent(shape Shape)
- func (p *Plane) SetTransform(translation geom.Mat4x4)
- type Shape
- type Sphere
- func (s *Sphere) GetInverse() geom.Mat4x4
- func (s *Sphere) GetInverseTranspose() geom.Mat4x4
- func (s *Sphere) GetMaterial() material.Material
- func (s *Sphere) GetParent() Shape
- func (s *Sphere) GetTransform() geom.Mat4x4
- func (s *Sphere) ID() int64
- func (s *Sphere) Lbl() string
- func (s *Sphere) SetMaterial(m material.Material)
- func (s *Sphere) SetParent(shape Shape)
- func (s *Sphere) SetTransform(translation geom.Mat4x4)
- type Triangle
- func (s *Triangle) Barycentric(p geom.Tuple4, u *float64, v *float64, w *float64)
- func (s *Triangle) GetInverse() geom.Mat4x4
- func (s *Triangle) GetInverseTranspose() geom.Mat4x4
- func (s *Triangle) GetLocalRay() geom.Ray
- func (s *Triangle) GetMaterial() material.Material
- func (s *Triangle) GetParent() Shape
- func (s *Triangle) GetTransform() geom.Mat4x4
- func (s *Triangle) ID() int64
- func (s *Triangle) IntersectLocal(ray geom.Ray) []Intersection
- func (s *Triangle) Lbl() string
- func (s *Triangle) Name() string
- func (s *Triangle) NormalAtLocal(point geom.Tuple4, intersection *Intersection) geom.Tuple4
- func (s *Triangle) SetMaterial(material material.Material)
- func (s *Triangle) SetParent(shape Shape)
- func (s *Triangle) SetTransform(transform geom.Mat4x4)
Constants ¶
const TriThreshold = 0.00000000001
Variables ¶
This section is empty.
Functions ¶
func FaceFromPoint ¶
func Flatten ¶
Flatten is meaningless since each level of the hierarchy seems to build upon its parent's transform.
func IntersectRayWithBox ¶
func IntersectRayWithBox(ray geom.Ray, BoundingBox *BoundingBox) bool
func IntersectionAllowed ¶
func MakeSubGroup ¶
func PartitionChildren ¶
func SplitBounds ¶
func SplitBounds(b1 *BoundingBox) (*BoundingBox, *BoundingBox)
SplitBounds splits the passed bounding box perpendicular of its longest axis. (Impl from bonus chapter)
Types ¶
type AlignCheck ¶
type AlignCheck struct {
// contains filtered or unexported fields
}
type BoundingBox ¶
func BoundsOf ¶
func BoundsOf(shape Shape) *BoundingBox
func NewBoundingBox ¶
func NewBoundingBox(pointA geom.Tuple4, pointB geom.Tuple4) *BoundingBox
func NewBoundingBoxF ¶
func NewBoundingBoxF(x1, y1, z1, x2, y2, z2 float64) *BoundingBox
func NewEmptyBoundingBox ¶
func NewEmptyBoundingBox() *BoundingBox
func ParentSpaceBounds ¶
func ParentSpaceBounds(shape Shape) *BoundingBox
func TransformBoundingBox ¶
func TransformBoundingBox(bbox *BoundingBox, m1 geom.Mat4x4) *BoundingBox
func (*BoundingBox) Add ¶
func (b *BoundingBox) Add(p geom.Tuple4)
func (*BoundingBox) ContainsBox ¶
func (b *BoundingBox) ContainsBox(b2 *BoundingBox) bool
func (*BoundingBox) ContainsPoint ¶
func (b *BoundingBox) ContainsPoint(p geom.Tuple4) bool
func (*BoundingBox) MergeWith ¶
func (b *BoundingBox) MergeWith(b2 *BoundingBox)
type Cube ¶
type Cube struct { Basic // contains filtered or unexported fields }
func (*Cube) GetInverse ¶
func (*Cube) GetInverseTranspose ¶
func (*Cube) GetMaterial ¶
func (*Cube) GetTransform ¶
func (*Cube) SetMaterial ¶
func (*Cube) SetTransform ¶
type Cylinder ¶
func NewCylinder ¶
func NewCylinder() *Cylinder
func NewCylinderMM ¶
func NewCylinderMMC ¶
func (*Cylinder) GetInverse ¶
func (*Cylinder) GetInverseTranspose ¶
func (*Cylinder) GetMaterial ¶
func (*Cylinder) GetTransform ¶
func (*Cylinder) SetMaterial ¶
func (*Cylinder) SetTransform ¶
type Group ¶
type Group struct { Id int64 Transform geom.Mat4x4 Inverse geom.Mat4x4 InverseTranspose geom.Mat4x4 Material material.Material Mtl material.Mtl Label string Children []Shape InnerRays []geom.Ray XsCache Intersections BoundingBox *BoundingBox CastShadow bool // contains filtered or unexported fields }
func (*Group) AddChildren ¶
func (*Group) BoundsToCube ¶
func (*Group) CastsShadow ¶
func (*Group) GetInverse ¶
func (*Group) GetInverseTranspose ¶
func (*Group) GetLocalRay ¶
func (*Group) GetMaterial ¶
func (*Group) GetTransform ¶
func (*Group) NormalAtLocal ¶
func (*Group) SetMaterial ¶
func (*Group) SetTransform ¶
type Intersections ¶
type Intersections []Intersection
func (Intersections) Len ¶
func (xs Intersections) Len() int
func (Intersections) Less ¶
func (xs Intersections) Less(i, j int) bool
func (Intersections) Swap ¶
func (xs Intersections) Swap(i, j int)
type Plane ¶
type Plane struct { Basic // contains filtered or unexported fields }
func (*Plane) GetInverse ¶
func (*Plane) GetInverseTranspose ¶
func (*Plane) GetMaterial ¶
func (*Plane) GetTransform ¶
func (*Plane) SetMaterial ¶
SetMaterial passes a pointer to the Plane on which to set the material
func (*Plane) SetTransform ¶
SetTransform passes a pointer to the Plane on which to apply the translation matrix
type Sphere ¶
type Sphere struct { Basic // contains filtered or unexported fields }
func (*Sphere) GetInverse ¶
func (*Sphere) GetInverseTranspose ¶
func (*Sphere) GetMaterial ¶
func (*Sphere) GetTransform ¶
func (*Sphere) SetMaterial ¶
SetMaterial passes a pointer to the Sphere on which to set the material
func (*Sphere) SetTransform ¶
SetTransform passes a pointer to the Sphere on which to apply the translation matrix
type Triangle ¶
type Triangle struct { P1 geom.Tuple4 P2 geom.Tuple4 P3 geom.Tuple4 E1 geom.Tuple4 E2 geom.Tuple4 N geom.Tuple4 N1 geom.Tuple4 N2 geom.Tuple4 N3 geom.Tuple4 Material material.Material Label string D00 float64 D01 float64 D11 float64 Denom float64 // contains filtered or unexported fields }
func DefaultTriangle ¶
func DefaultTriangle() *Triangle
func NewTriangle ¶
func (*Triangle) Barycentric ¶
Barycentric computes barycentric coordinates (u, v, w) for point p with respect to triangle defined by pre-computed vectors E1 and E2, which was derived into points d00, d01, d11 and denominator in constructor func.
func (*Triangle) GetInverse ¶
func (*Triangle) GetInverseTranspose ¶
func (*Triangle) GetLocalRay ¶
func (*Triangle) GetMaterial ¶
func (*Triangle) GetTransform ¶
func (*Triangle) IntersectLocal ¶
func (s *Triangle) IntersectLocal(ray geom.Ray) []Intersection