primitives

package
v0.0.0-...-5eff40d Latest Latest
Warning

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

Go to latest
Published: May 1, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnitVector = Vector{1, 1, 1}

Functions

This section is empty.

Types

type Camera

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

func NewCamera

func NewCamera() *Camera

func (*Camera) Direction

func (c *Camera) Direction(position Vector) Vector

func (*Camera) Position

func (c *Camera) Position(u, v float64) Vector

func (*Camera) RayAt

func (c *Camera) RayAt(u, v float64) Ray

type Dielectric

type Dielectric struct {
	C               Vector
	RefractiveIndex float64
}

func (Dielectric) Bounce

func (d Dielectric) Bounce(input Ray, record HitRecord, rand *rand.Rand) (bool, Ray)

func (Dielectric) Color

func (d Dielectric) Color() Vector

type HitRecord

type HitRecord struct {
	Time          float64
	Point, Normal Vector
	Material
}

type Hitable

type Hitable interface {
	Hit(r Ray, tMin, tMax float64) (bool, HitRecord)
}

type Lambertian

type Lambertian struct {
	C Vector
}

func (Lambertian) Bounce

func (l Lambertian) Bounce(input Ray, record HitRecord, rand *rand.Rand) (bool, Ray)

func (Lambertian) Color

func (l Lambertian) Color() Vector

type Material

type Material interface {
	Bounce(ray Ray, hit HitRecord, rand *rand.Rand) (bool, Ray)
	Color() Vector
}

type Metal

type Metal struct {
	C    Vector
	Fuzz float64
}

func (Metal) Bounce

func (m Metal) Bounce(input Ray, record HitRecord, rand *rand.Rand) (bool, Ray)

func (Metal) Color

func (m Metal) Color() Vector

type Ray

type Ray struct {
	Origin, Direction Vector
}

func (Ray) Point

func (r Ray) Point(t float64) Vector

type Sphere

type Sphere struct {
	Center Vector
	Radius float64
	Material
}

func (*Sphere) Hit

func (s *Sphere) Hit(r Ray, tMin, tMax float64) (bool, HitRecord)

type Vector

type Vector struct {
	X, Y, Z float64
}

func VectorInUnitSphere

func VectorInUnitSphere(rand *rand.Rand) Vector

func (Vector) Add

func (u Vector) Add(v Vector) Vector

func (Vector) AddScalar

func (u Vector) AddScalar(a float64) Vector

func (Vector) DivideScalar

func (u Vector) DivideScalar(a float64) Vector

func (Vector) DotProduct

func (u Vector) DotProduct(v Vector) float64

func (Vector) Length

func (u Vector) Length() float64

func (Vector) Multiply

func (u Vector) Multiply(v Vector) Vector

func (Vector) MultiplyScalar

func (u Vector) MultiplyScalar(a float64) Vector

func (Vector) Normalise

func (u Vector) Normalise() Vector

func (Vector) RGBA

func (u Vector) RGBA() (r, g, b, a uint32)

func (Vector) Reflect

func (u Vector) Reflect(n Vector) Vector

func (Vector) Refract

func (u Vector) Refract(normal Vector, ni_over_nt float64) (bool, Vector)

func (Vector) Subtract

func (u Vector) Subtract(v Vector) Vector

type World

type World struct {
	Elements []Hitable
}

func (*World) Add

func (w *World) Add(hitable Hitable)

func (*World) Hit

func (w *World) Hit(r Ray, tMin, tMax float64) (bool, HitRecord)

Jump to

Keyboard shortcuts

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