utils

package
v0.0.0-...-ef7d6af Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const ERROR = 0.00001

Variables

This section is empty.

Functions

func Vector2Color

func Vector2Color(a Vector) color.RGBA

Types

type Box

type Box struct {
	MinX float64
	MaxX float64
	MinY float64
	MaxY float64
	MinZ float64
	MaxZ float64
}

func (Box) Collide

func (a Box) Collide(b Box) bool

func (Box) Intersect

func (box Box) Intersect(ray Ray) bool

type Camera

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

func NewCamera

func NewCamera(up Vector, origin Vector, fov float64) (camera Camera)

func (Camera) GetDistanceFromScreen

func (camera Camera) GetDistanceFromScreen(aspect float64) float64

func (Camera) GetLookAt

func (camera Camera) GetLookAt(target Vector) Transformation

type Material

type Material struct {
	Color         color.RGBA
	Emitance      Vector
	PScatter      float64
	Nt            float64
	ProbReflected float64
}

type Object3D

type Object3D interface {
	Intersect(ray Ray) (Ray, float64, bool)
	Transform(transformMatrix Transformation)
}

type Octree

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

func (*Octree) Intersect

func (octree *Octree) Intersect(ray *Ray, objects []VisibleObject) (int, Ray, float64, bool)

type Ray

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

func NewRay

func NewRay(origin, direction Vector) Ray

func (Ray) DiffuseReflection

func (ray Ray) DiffuseReflection(normal Ray) (result Ray)

func (Ray) GetDirection

func (r Ray) GetDirection() Vector

func (Ray) GetOrigin

func (r Ray) GetOrigin() Vector

func (Ray) GetRayPoint

func (ray Ray) GetRayPoint(distance float64) Vector

func (Ray) SpecularReflection

func (ray Ray) SpecularReflection(normal Ray) (result Ray)

type Sphere

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

func NewSphere

func NewSphere(origin Vector, radius float64) (sphere Sphere)

func (*Sphere) Intersect

func (sphere *Sphere) Intersect(ray Ray) (result Ray, distance float64, isHitted bool)

func (*Sphere) Transform

func (sphere *Sphere) Transform(transformMatrix Transformation)

type Transformation

type Transformation [4][4]float64

func (Transformation) Combine

func (a Transformation) Combine(b Transformation) (result Transformation)

type Vector

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

func Color2Vector

func Color2Vector(c color.RGBA) (result Vector)

func NewNormal

func NewNormal(x, y, z float64) (result Vector)

func NewVector

func NewVector(x, y, z float64) (result Vector)

func (Vector) Add

func (a Vector) Add(b Vector) (result Vector)

func (Vector) Cross

func (a Vector) Cross(b Vector) (result Vector)

func (Vector) Dot

func (a Vector) Dot(b Vector) float64

func (Vector) Extend

func (a Vector) Extend(k float64) (result Vector)

func (Vector) Multiply

func (a Vector) Multiply(b Vector) (result Vector)

func (Vector) Norma

func (a Vector) Norma() (nrma float64)

func (Vector) Normalize

func (a Vector) Normalize() (result Vector)

func (Vector) Scale

func (a Vector) Scale(k float64) (result Vector)

func (Vector) Sub

func (a Vector) Sub(b Vector) (result Vector)

func (Vector) Transform

func (a Vector) Transform(transformMatrix Transformation) (result Vector)

type VisibleObject

type VisibleObject struct {
	Geometry Object3D
	Material Material
}

Jump to

Keyboard shortcuts

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