shape

package
v0.0.0-...-cec5250 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2017 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsMap

func AsMap(shapes []Shape) []map[string]interface{}

AsMap turns the input slice of shapes to a slice of maps that can be serialized.

Types

type Shape

type Shape interface {
	Intersect(lr *math3d.LightRay) float64
	NormalAt(point *math3d.Vector3) *math3d.Vector3
	AsMap() map[string]interface{}
}

Shape defines the methods shared by all 3D shapes

func FromMap

func FromMap(themap []map[string]interface{}) []Shape

FromMap returns a slice of shapes made from the slice of map

type Sphere

type Sphere struct {
	Position math3d.Vector3 `json:"position"`
	Radius   float64        `json:"radius"`
}

Sphere defines a spheric shape in 3D space.

func SphereFromMap

func SphereFromMap(themap map[string]interface{}) *Sphere

SphereFromMap returns a sphere with the values in the map

func (*Sphere) AsMap

func (s *Sphere) AsMap() map[string]interface{}

AsMap returns a map representation of this shape

func (*Sphere) Intersect

func (s *Sphere) Intersect(lr *math3d.LightRay) float64

Intersect returns the distance at which the lightray intersects the sphere

func (*Sphere) NormalAt

func (s *Sphere) NormalAt(point *math3d.Vector3) *math3d.Vector3

NormalAt returns the normal vector of a point of the sphere. point must be a point in the surface of the sphere.

Jump to

Keyboard shortcuts

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