Documentation ¶
Index ¶
- func CheckAxis(origin, direction, minimum, maximum float64) (float64, float64)
- func CheckCap(r primitives.Ray, t float64) bool
- func IntersectEquals(xs Intersections, dists []float64) bool
- func MinMax(values []float64) (float64, float64)
- type Bounds
- type Cone
- type Cube
- type Cylinder
- type Group
- type Intersection
- type Intersections
- type Plane
- type Shape
- type ShapeBase
- func (s *ShapeBase) Inverse() primitives.Matrix
- func (s *ShapeBase) Material() patterns.Material
- func (s *ShapeBase) ObjectToWorldPV(pv primitives.PV) primitives.PV
- func (s *ShapeBase) Parent() Shape
- func (s *ShapeBase) SetMaterial(mat patterns.Material)
- func (s *ShapeBase) SetParent(parent Shape)
- func (s *ShapeBase) SetTransform(m primitives.Matrix)
- func (s *ShapeBase) Transform() primitives.Matrix
- func (s *ShapeBase) WorldToObjectPV(pv primitives.PV) primitives.PV
- type Sphere
- type Triangle
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCap ¶
func CheckCap(r primitives.Ray, t float64) bool
CheckCap Checks if an intersection happens at the cap
func IntersectEquals ¶
func IntersectEquals(xs Intersections, dists []float64) bool
IntersectEquals Check if two slices are equal
Types ¶
type Bounds ¶
type Bounds struct {
Min, Max primitives.PV
}
Bounds Bounding box structure with a minimum and maximum point representing an axis-aligned cube
func CombineBounds ¶
CombineBounds Combine a slice of bounds into one
type Cone ¶
type Cone struct { ShapeBase // contains filtered or unexported fields }
Cone Represents a cone
func (*Cone) Intersect ¶
func (cone *Cone) Intersect(r primitives.Ray) Intersections
Intersect Check if a ray intersects
func (*Cone) Normal ¶
func (cone *Cone) Normal(worldPoint primitives.PV, u, v float64) primitives.PV
Normal Calculate the normal at a given point on the Cone
func (*Cone) UVMapping ¶
func (cone *Cone) UVMapping(point primitives.PV) primitives.PV
UVMapping Return the 2D coordinates of an intersection point
type Cube ¶
type Cube struct {
ShapeBase
}
Cube Basic cube representation
func MakeCube ¶
func MakeCube() *Cube
MakeCube Make a regular cube with an identity matrix for transform
func (*Cube) Intersect ¶
func (c *Cube) Intersect(r primitives.Ray) Intersections
Intersect Check for intersection along one of the six sides of the cube
func (*Cube) Normal ¶
func (c *Cube) Normal(worldPoint primitives.PV, u, v float64) primitives.PV
Normal Calculate the normal at a given point on the cube
func (*Cube) UVMapping ¶
func (c *Cube) UVMapping(point primitives.PV) primitives.PV
UVMapping Return the 2D coordinates of an intersection point
type Cylinder ¶
type Cylinder struct { ShapeBase // contains filtered or unexported fields }
Cylinder Represents a cylinder
func MakeCylinder ¶
MakeCylinder Make a regular cylinder with an identity matrix for transform
func (*Cylinder) Intersect ¶
func (cyl *Cylinder) Intersect(r primitives.Ray) Intersections
Intersect Check if a ray intersects
func (*Cylinder) Normal ¶
func (cyl *Cylinder) Normal(worldPoint primitives.PV, u, v float64) primitives.PV
Normal Calculate the normal at a given point on the Cylinder
func (*Cylinder) UVMapping ¶
func (cyl *Cylinder) UVMapping(point primitives.PV) primitives.PV
UVMapping Return the 2D coordinates of an intersection point
type Group ¶
type Group struct { ShapeBase // contains filtered or unexported fields }
Group Represents a group of other shapes
func (*Group) Intersect ¶
func (g *Group) Intersect(r primitives.Ray) Intersections
Intersect Check if a ray intersects
func (*Group) Normal ¶
func (g *Group) Normal(worldPoint primitives.PV, u, v float64) primitives.PV
Normal Calculate the normal at a given point on the sphere
func (*Group) UVMapping ¶
func (g *Group) UVMapping(point primitives.PV) primitives.PV
UVMapping Return the 2D coordinates of an intersection point
type Intersection ¶
Intersection Structure to hold intersection information
type Intersections ¶
type Intersections []Intersection
Intersections Sortable list of intersection structs
func (Intersections) Hit ¶
func (i Intersections) Hit() (Intersection, bool)
Hit Get the closest hit from intersections, assumes i is sorted
func (Intersections) Len ¶
func (i Intersections) Len() int
Necessary functions to make Intersections sortable
func (Intersections) Less ¶
func (i Intersections) Less(j, k int) bool
func (Intersections) Swap ¶
func (i Intersections) Swap(j, k int)
type Plane ¶
type Plane struct {
ShapeBase
}
Plane Plane along the XZ axis
func (*Plane) Intersect ¶
func (p *Plane) Intersect(r primitives.Ray) Intersections
Intersect Check if a ray intersects
func (*Plane) Normal ¶
func (p *Plane) Normal(worldPoint primitives.PV, u, v float64) primitives.PV
Normal Calculate the normal at a given point on the sphere
func (*Plane) UVMapping ¶
func (p *Plane) UVMapping(point primitives.PV) primitives.PV
UVMapping Return the 2D coordinates of an intersected point
type Shape ¶
type Shape interface { Intersect(primitives.Ray) Intersections Normal(primitives.PV, float64, float64) primitives.PV SetTransform(primitives.Matrix) Transform() primitives.Matrix SetMaterial(patterns.Material) Material() patterns.Material SetParent(Shape) Parent() Shape GetBounds() *Bounds UVMapping(primitives.PV) primitives.PV WorldToObjectPV(primitives.PV) primitives.PV ObjectToWorldPV(primitives.PV) primitives.PV }
Shape Interface for different 3D and 2D shape modules
type ShapeBase ¶
type ShapeBase struct {
// contains filtered or unexported fields
}
ShapeBase Base struct to be embedded in shape objects
func MakeShapeBase ¶
func MakeShapeBase() ShapeBase
MakeShapeBase Make a regular sphere with an identity matrix for transform
func (*ShapeBase) Inverse ¶
func (s *ShapeBase) Inverse() primitives.Matrix
Inverse Get the Inverse of the transform matrix
func (*ShapeBase) ObjectToWorldPV ¶
func (s *ShapeBase) ObjectToWorldPV(pv primitives.PV) primitives.PV
ObjectToWorldPV Convert a Point/Vector from object to world-space
func (*ShapeBase) SetMaterial ¶
SetMaterial Set the material for the shape
func (*ShapeBase) SetTransform ¶
func (s *ShapeBase) SetTransform(m primitives.Matrix)
SetTransform Set the transform matrix
func (*ShapeBase) Transform ¶
func (s *ShapeBase) Transform() primitives.Matrix
Transform Get the transform matrix
func (*ShapeBase) WorldToObjectPV ¶
func (s *ShapeBase) WorldToObjectPV(pv primitives.PV) primitives.PV
WorldToObjectPV Convert a Point/Vector from world to object-space
type Sphere ¶
type Sphere struct {
ShapeBase
}
Sphere Represents a sphere of radius 1
func MakeSphere ¶
func MakeSphere() *Sphere
MakeSphere Make a regular sphere with an identity matrix for transform
func (*Sphere) Intersect ¶
func (s *Sphere) Intersect(r primitives.Ray) Intersections
Intersect Check if a ray intersects
func (*Sphere) Normal ¶
func (s *Sphere) Normal(worldPoint primitives.PV, u, v float64) primitives.PV
Normal Calculate the normal at a given point on the sphere
func (*Sphere) UVMapping ¶
func (s *Sphere) UVMapping(point primitives.PV) primitives.PV
UVMapping Return the 2D coordinates of an intersection point
type Triangle ¶ added in v0.15.5
type Triangle struct { ShapeBase Point1, Point2, Point3, Edge1, Edge2, Normal1, Normal2, Normal3 primitives.PV // contains filtered or unexported fields }
Triangle Represents a triangle
func MakeSmoothTriangle ¶ added in v0.15.5
func MakeSmoothTriangle(point1, point2, point3, normal1, normal2, normal3 primitives.PV) *Triangle
MakeSmoothTriangle Create a smooth triangle from three points and three normals
func MakeTriangle ¶ added in v0.15.5
func MakeTriangle(point1, point2, point3 primitives.PV) *Triangle
MakeTriangle Create a triangle from three points
func (*Triangle) GetBounds ¶ added in v0.15.5
GetBounds Return an axis aligned bounding box for the triangle
func (*Triangle) Intersect ¶ added in v0.15.5
func (t *Triangle) Intersect(ray primitives.Ray) Intersections
Intersect Check if a ray intersects
func (*Triangle) Normal ¶ added in v0.15.5
func (t *Triangle) Normal(worldPoint primitives.PV, u, v float64) primitives.PV
Normal Calculate the normal at a given point on the sphere
func (*Triangle) UVMapping ¶ added in v0.15.5
func (t *Triangle) UVMapping(point primitives.PV) primitives.PV
UVMapping Return the 2D coordinates of an intersection point