shape

package
v0.0.0-...-e407d5c Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const EPSILON = 0.000000001

Variables

This section is empty.

Functions

This section is empty.

Types

type Quadrilateral

type Quadrilateral struct {
	Shape
	Vertices [4]geometry.Vector
	// contains filtered or unexported fields
}

func NewQuadrilateral

func NewQuadrilateral(vertices [4]geometry.Vector) Quadrilateral

func (Quadrilateral) CheckForCollision

func (quad Quadrilateral) CheckForCollision(ray geometry.Ray) (Shape, float64)

func (Quadrilateral) RandomLocationOn

func (quad Quadrilateral) RandomLocationOn() geometry.Vector

func (Quadrilateral) String

func (quad Quadrilateral) String() string

type Shape

type Shape interface {
	// CheckForCollision determines if a Ray collides with this shape
	CheckForCollision(ray geometry.Ray) (Shape, float64)

	// NormalAtLocation calculates the normal vector at a given location on this shape
	NormalAtLocation(loc geometry.Vector) geometry.Vector

	// RandomLocationOn return a random location on the surface of the shape
	RandomLocationOn() geometry.Vector
}

Shape represents a shape in 3D space

type Sphere

type Sphere struct {
	Shape
	Center geometry.Vector
	Radius float64
}

func (Sphere) CheckForCollision

func (sphere Sphere) CheckForCollision(ray geometry.Ray) (Shape, float64)

func (Sphere) NormalAtLocation

func (s Sphere) NormalAtLocation(loc geometry.Vector) geometry.Vector

func (Sphere) RandomLocationOn

func (s Sphere) RandomLocationOn() geometry.Vector

func (Sphere) String

func (sphere Sphere) String() string

type Triangle

type Triangle struct {
	Shape
	Vertices [3]geometry.Vector
	// contains filtered or unexported fields
}

func (Triangle) Area

func (triangle Triangle) Area() float64

Area calculates the area of the triangle

func (Triangle) CheckForCollision

func (triangle Triangle) CheckForCollision(ray geometry.Ray) (Shape, float64)

func (Triangle) NormalAtLocation

func (triangle Triangle) NormalAtLocation(loc geometry.Vector) geometry.Vector

func (Triangle) RandomLocationOn

func (triangle Triangle) RandomLocationOn() geometry.Vector

func (Triangle) String

func (triangle Triangle) String() string

Jump to

Keyboard shortcuts

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