engine

package
v0.0.0-...-c7f7500 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Color

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

func NewColor

func NewColor(r, g, b float64) Color

func (Color) Add

func (color Color) Add(other Color) Color

func (Color) B

func (color Color) B() float64

func (Color) Equal

func (color Color) Equal(other Color) bool

func (Color) G

func (color Color) G() float64

func (Color) MulColor

func (color Color) MulColor(other Color) Color

func (Color) MulScalar

func (color Color) MulScalar(k float64) Color

func (Color) R

func (color Color) R() float64

func (Color) Sub

func (color Color) Sub(other Color) Color

type Intersection

type Intersection struct {
	T     float64
	Shape Shape
}

type IntersectionList

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

func NewIntersectionList

func NewIntersectionList(intersections ...Intersection) IntersectionList

NewIntersectionList creates a sorted list of intersections

func (IntersectionList) Hit

func (intersections IntersectionList) Hit() *Intersection

Hit returns the nearest intersection (or nil, in case there is no intersection)

type Material

type Material struct {
	Color                                 Color
	Ambient, Diffuse, Specular, Shininess float64
}

func (Material) Lighting

func (material Material) Lighting(light PointLight, point, eye, normal Tuple) Color

type PointLight

type PointLight struct {
	Position  Tuple
	Intensity Color
}

type Ray

type Ray struct {
	Origin, Direction Tuple
}

func (Ray) ApplyTransform

func (ray Ray) ApplyTransform(transform Transform) Ray

func (Ray) At

func (ray Ray) At(t float64) Tuple

type Shape

type Shape interface {
	GetTransform() Transform
	GetMaterial() Material
	Intersect(Ray) IntersectionList
	NormalAt(Tuple) Tuple
}

type Sphere

type Sphere struct {
	Material  Material
	Transform Transform
}

func (*Sphere) GetMaterial

func (sphere *Sphere) GetMaterial() Material

func (*Sphere) GetTransform

func (sphere *Sphere) GetTransform() Transform

func (*Sphere) Intersect

func (sphere *Sphere) Intersect(ray Ray) IntersectionList

func (*Sphere) NormalAt

func (sphere *Sphere) NormalAt(worldPoint Tuple) Tuple

type Transform

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

func NewTransform

func NewTransform() Transform

func (Transform) Chain

func (transform Transform) Chain(other Transform) Transform

func (Transform) Inverse

func (transform Transform) Inverse() Transform

func (Transform) RotateX

func (transform Transform) RotateX(r float64) Transform

func (Transform) RotateY

func (transform Transform) RotateY(r float64) Transform

func (Transform) RotateZ

func (transform Transform) RotateZ(r float64) Transform

func (Transform) Scale

func (transform Transform) Scale(x, y, z float64) Transform

func (Transform) Shear

func (transform Transform) Shear(x_y, x_z, y_x, y_z, z_x, z_y float64) Transform

func (Transform) Translate

func (transform Transform) Translate(x, y, z float64) Transform

func (Transform) Transpose

func (transform Transform) Transpose() Transform

type Tuple

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

func NewPoint

func NewPoint(x, y, z float64) Tuple

func NewTuple

func NewTuple(x, y, z, w float64) Tuple

func NewVector

func NewVector(x, y, z float64) Tuple

func (Tuple) Add

func (tuple Tuple) Add(other Tuple) Tuple

func (Tuple) ApplyTransform

func (tuple Tuple) ApplyTransform(transform Transform) Tuple

func (Tuple) Cross

func (tuple Tuple) Cross(other Tuple) Tuple

func (Tuple) Div

func (tuple Tuple) Div(k float64) Tuple

func (Tuple) Dot

func (tuple Tuple) Dot(other Tuple) float64

func (Tuple) Equal

func (tuple Tuple) Equal(other Tuple) bool

func (Tuple) IsPoint

func (tuple Tuple) IsPoint() bool

func (Tuple) IsVector

func (tuple Tuple) IsVector() bool

func (Tuple) Magnitude

func (tuple Tuple) Magnitude() float64

func (Tuple) Mul

func (tuple Tuple) Mul(k float64) Tuple

func (Tuple) Neg

func (tuple Tuple) Neg() Tuple

func (Tuple) Normalize

func (tuple Tuple) Normalize() Tuple

func (Tuple) Reflect

func (tuple Tuple) Reflect(normal Tuple) Tuple

func (Tuple) String

func (tuple Tuple) String() string

func (Tuple) Sub

func (tuple Tuple) Sub(other Tuple) Tuple

func (Tuple) W

func (tuple Tuple) W() float64

func (Tuple) X

func (tuple Tuple) X() float64

func (Tuple) Y

func (tuple Tuple) Y() float64

func (Tuple) Z

func (tuple Tuple) Z() float64

type World

type World struct {
	Shapes []Shape
}

func (World) Intersect

func (world World) Intersect(ray Ray) IntersectionList

Jump to

Keyboard shortcuts

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