raytracer

package module
v0.0.0-...-fc46e8d Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2014 License: Artistic-2.0 Imports: 6 Imported by: 0

README

A simple Ray Tracer written in go

(Doesn't actually trace rays yet)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Camera

type Camera struct {
	Width  int
	Height int
	Image  *image.RGBA
}

Camera represents the scene camera.

func NewCamera

func NewCamera(width int, height int) *Camera

func (*Camera) Snap

func (c *Camera) Snap()

type Color

type Color struct {
	Red   uint8
	Green uint8
	Blue  uint8
}

Color represents a color in RGB

type Image

type Image [][]Color

Image is a 2d slice representing the pixels

type Light

type Light struct {
}

Light represents a light source

type Object

type Object struct {
	ObjectInterface
	Ambient  float64
	Diffuse  float64
	Specular float64
}

Object represents an object in the scene

type ObjectInterface

type ObjectInterface interface {
	// contains filtered or unexported methods
}

ObjectInterface is the interface for objects in the scene

type Ray

type Ray struct {
	Position  Vector
	Direction Vector
}

type Renderer

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

Renderer renders the scene

func NewRenderer

func NewRenderer(camera *Camera, scene *Scene) *Renderer

NewRenderer creates a renderer struct

func (*Renderer) Render

func (r *Renderer) Render()

Render renders the scene

type Scene

type Scene struct {
	Objects []ObjectInterface
	Lights  []Light
}

Scene represents the world being rendered

type Sphere

type Sphere struct {
	Object
	Centre Vector
	Radius float64
}

Sphere represents a spherical object

type Vector

type Vector struct {
	X, Y, Z float64
}

Vector is a struct representing a floating point vector.

func (*Vector) Add

func (v *Vector) Add(v2 *Vector) *Vector

Add computes the sum of two vectors

func (*Vector) DotProduct

func (v *Vector) DotProduct(v2 *Vector) float64

DotProduct computes the vector dot product of the two vectors

func (*Vector) Length

func (v *Vector) Length() float64

func (*Vector) Scale

func (v *Vector) Scale(s float64) *Vector

Scale scales the vector by the specified amount

func (*Vector) Subtract

func (v *Vector) Subtract(v2 *Vector) *Vector

Subtract takes the passed vector away from the current one and returns a pointer

func (*Vector) UnitVector

func (v *Vector) UnitVector() *Vector

type View

type View struct {
	Width  uint64
	Height uint64
}

View represents the viewport that the camera is seeing

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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