primitive

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: MIT Imports: 2 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Black = Color{}
	White = Color{1.0, 1.0, 1.0}
	Blue  = Color{0.5, 0.7, 1.0}
)
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(lookFrom, lookAt Vector, vFov, aspect, aperture float64) *Camera

func (*Camera) RayAt

func (c *Camera) RayAt(s, t float64, rnd *rand.Rand) Ray

type Color

type Color struct {
	R, G, B float64
}

func Gradient

func Gradient(a, b Color, f float64) Color

func (Color) Add

func (c Color) Add(o Color) Color

func (Color) AddScalar

func (c Color) AddScalar(f float64) Color

func (Color) DivideScalar

func (c Color) DivideScalar(f float64) Color

func (Color) Multiply

func (c Color) Multiply(o Color) Color

func (Color) MultiplyScalar

func (c Color) MultiplyScalar(f float64) Color

func (Color) RGBA

func (c Color) RGBA() (r, g, b, a uint32)

For compatibility with image.Color

type Dielectric

type Dielectric struct {
	Index float64
}

func (Dielectric) Bounce

func (d Dielectric) Bounce(input Ray, hit Hit, rnd *rand.Rand) (bool, Ray)

func (Dielectric) Color

func (d Dielectric) Color() Color

type Hit

type Hit struct {
	T             float64
	Point, Normal Vector
	Material
}

type Hitable

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

type Lambertian

type Lambertian struct {
	Attenuation Color
}

func (Lambertian) Bounce

func (l Lambertian) Bounce(input Ray, hit Hit, rnd *rand.Rand) (bool, Ray)

func (Lambertian) Color

func (l Lambertian) Color() Color

type Material

type Material interface {
	Bounce(input Ray, hit Hit, rnd *rand.Rand) (bool, Ray)
	Color() Color
}

type Metal

type Metal struct {
	Attenuation Color
	Fuzz        float64
}

func (Metal) Bounce

func (m Metal) Bounce(input Ray, hit Hit, rnd *rand.Rand) (bool, Ray)

func (Metal) Color

func (m Metal) Color() Color

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 NewSphere

func NewSphere(x, y, z, radius float64, m Material) *Sphere

func (*Sphere) Hit

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

type Vector

type Vector struct {
	X, Y, Z float64
}

func VectorInUnitSphere

func VectorInUnitSphere(rnd *rand.Rand) Vector

func (Vector) Add

func (v Vector) Add(ov Vector) Vector

func (Vector) AddScalar

func (v Vector) AddScalar(t float64) Vector

func (Vector) Cross

func (v Vector) Cross(ov Vector) Vector

func (Vector) Divide

func (v Vector) Divide(ov Vector) Vector

func (Vector) DivideScalar

func (v Vector) DivideScalar(t float64) Vector

func (Vector) Dot

func (v Vector) Dot(ov Vector) float64

func (Vector) Length

func (v Vector) Length() float64

func (Vector) Multiply

func (v Vector) Multiply(ov Vector) Vector

func (Vector) MultiplyScalar

func (v Vector) MultiplyScalar(t float64) Vector

func (Vector) Normalize

func (v Vector) Normalize() Vector

func (Vector) Reflect

func (v Vector) Reflect(ov Vector) Vector

func (Vector) Refract

func (v Vector) Refract(ov Vector, n float64) (bool, Vector)

func (Vector) SquaredLength

func (v Vector) SquaredLength() float64

func (Vector) Subtract

func (v Vector) Subtract(ov Vector) Vector

func (Vector) SubtractScalar

func (v Vector) SubtractScalar(t float64) Vector

type World

type World []Hitable

func (*World) Add

func (w *World) Add(h Hitable)

func (*World) AddAll

func (w *World) AddAll(hitables ...Hitable)

func (*World) Count

func (w *World) Count() int

func (*World) Hit

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

Jump to

Keyboard shortcuts

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