Documentation
¶
Index ¶
- func NormalAt(s Shape, p tuple.Tuple) *tuple.Tuple
- type Computation
- type Intersection
- type Plane
- func (p *Plane) GetMaterial() *material.Material
- func (p *Plane) GetTransform() *matrix.Matrix
- func (p *Plane) LocalIntersect(r ray.Ray) []Intersection
- func (p *Plane) LocalNormalAt(point tuple.Tuple) *tuple.Tuple
- func (p *Plane) SetMaterial(m *material.Material)
- func (p *Plane) SetTransform(m *matrix.Matrix)
- type Shape
- type Sphere
- func (s *Sphere) GetMaterial() *material.Material
- func (s *Sphere) GetTransform() *matrix.Matrix
- func (s *Sphere) LocalIntersect(r ray.Ray) []Intersection
- func (s *Sphere) LocalNormalAt(p tuple.Tuple) *tuple.Tuple
- func (s *Sphere) SetMaterial(m *material.Material)
- func (s *Sphere) SetTransform(m *matrix.Matrix)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Computation ¶
type Computation struct {
Value float64
Object Shape
Point tuple.Tuple
Overpoint tuple.Tuple
Eyev tuple.Tuple
Normal tuple.Tuple
Reflectv tuple.Tuple
Inside bool
}
Computation object that contains data about an intersection
type Intersection ¶
Intersection represents a point where an object is intersected
func Hit ¶
func Hit(intersections []Intersection) *Intersection
Hit returns the lowest nonnegative point of intersection
func Intersect ¶
func Intersect(s Shape, r ray.Ray) []Intersection
Intersect intersects a shape with a ray
func Intersections ¶
func Intersections(intersections ...Intersection) []Intersection
Intersections returns a an array of intersections
func NewIntersection ¶
func NewIntersection(t float64, o Shape) Intersection
NewIntersection returns a new intersection object
func (*Intersection) PrepareComputations ¶
func (i *Intersection) PrepareComputations(r ray.Ray) Computation
PrepareComputations calculates the Computation object for an intersection
type Plane ¶
Plane is a flat surface that extends infinitely in xz
func (*Plane) GetMaterial ¶
GetMaterial returns the material of the plane
func (*Plane) GetTransform ¶
GetTransform returns the transform of the plane
func (*Plane) LocalIntersect ¶
func (p *Plane) LocalIntersect(r ray.Ray) []Intersection
LocalIntersect returns the points at which a ray intersects a plane
func (*Plane) LocalNormalAt ¶
LocalNormalAt returns the normal vector at point P on a plane
func (*Plane) SetMaterial ¶
SetMaterial returns the material of the plane
func (*Plane) SetTransform ¶
SetTransform sets given transform for sphere
type Shape ¶
type Shape interface {
LocalIntersect(ray.Ray) []Intersection
LocalNormalAt(tuple.Tuple) *tuple.Tuple
GetMaterial() *material.Material
SetMaterial(*material.Material)
SetTransform(*matrix.Matrix)
GetTransform() *matrix.Matrix
}
Shape interface
type Sphere ¶
Sphere struct
func (*Sphere) GetMaterial ¶
GetMaterial returns the material of the sphere
func (*Sphere) GetTransform ¶
GetTransform returns the transform of the sphere
func (*Sphere) LocalIntersect ¶
func (s *Sphere) LocalIntersect(r ray.Ray) []Intersection
LocalIntersect returns the points at which a ray intersects a sphere
func (*Sphere) LocalNormalAt ¶
LocalNormalAt returns the normal vector at point P on a sphere
func (*Sphere) SetMaterial ¶
SetMaterial returns the material of the sphere
func (*Sphere) SetTransform ¶
SetTransform sets given transform for sphere