intersection

package
v0.0.0-...-7d0236b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseShape

type BaseShape struct {
	Shape

	Material material.Material
	// contains filtered or unexported fields
}

func NewShape

func NewShape() *BaseShape

func (*BaseShape) GetInvTransform

func (s *BaseShape) GetInvTransform() *matrix.Mat44

func (*BaseShape) GetMaterial

func (s *BaseShape) GetMaterial() *material.Material

func (*BaseShape) GetTransform

func (s *BaseShape) GetTransform() *matrix.Mat44

func (*BaseShape) Intersect

func (s *BaseShape) Intersect(r ray.Ray) Intersections

func (*BaseShape) NormalAt

func (s *BaseShape) NormalAt(p tuple.Tuple) tuple.Tuple

func (*BaseShape) SetTransform

func (s *BaseShape) SetTransform(transform matrix.Mat44)

type Intersection

type Intersection struct {
	T      float64
	Object Shape
}

func NewIntersection

func NewIntersection(T float64, Object Shape) Intersection

func (Intersection) Equal

func (x1 Intersection) Equal(x2 Intersection) bool

func (Intersection) PrepareComputations

func (x Intersection) PrepareComputations(r ray.Ray, xs Intersections) PreparedComps

type Intersections

type Intersections []Intersection

func (Intersections) Hit

func (xs Intersections) Hit() *Intersection

func (Intersections) Sort

func (xs Intersections) Sort()

type Plane

type Plane struct {
	*BaseShape
}

func NewPlane

func NewPlane() *Plane

type PreparedComps

type PreparedComps struct {
	T          float64
	Object     Shape
	Point      tuple.Tuple
	OverPoint  tuple.Tuple
	UnderPoint tuple.Tuple
	EyeV       tuple.Tuple
	NormalV    tuple.Tuple
	ReflectV   tuple.Tuple
	Inside     bool
	N1         float64 // Refractive index of exiting material
	N2         float64 // Refractive index of entering material
}

func (*PreparedComps) Schlick

func (comps *PreparedComps) Schlick() float64

type Shape

type Shape interface {
	Intersect(r ray.Ray) Intersections
	NormalAt(p tuple.Tuple) tuple.Tuple

	GetMaterial() *material.Material
	GetTransform() *matrix.Mat44
	GetInvTransform() *matrix.Mat44
	// contains filtered or unexported methods
}

type Sphere

type Sphere struct {
	*BaseShape
}

func NewSphere

func NewSphere() *Sphere

type World

type World struct {
	Objects []Shape
	Lights  []light.PointLight
}

func NewDefaultWorld

func NewDefaultWorld() World

func NewWorld

func NewWorld() World

func (*World) AddLight

func (w *World) AddLight(l light.PointLight)

func (*World) AddObject

func (w *World) AddObject(obj Shape)

func (*World) ColorAt

func (w *World) ColorAt(r ray.Ray, remaining int) color.Color

func (*World) Intersect

func (w *World) Intersect(r ray.Ray) Intersections

func (*World) IsShadowed

func (w *World) IsShadowed(point tuple.Tuple, l light.PointLight) bool

func (*World) ReflectedColor

func (w *World) ReflectedColor(comps PreparedComps, remaining int) color.Color

func (*World) RefractedColor

func (w *World) RefractedColor(comps PreparedComps, remaining int) color.Color

func (*World) ShadeHit

func (w *World) ShadeHit(comps PreparedComps, remaining int) color.Color

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL