hitable

package
v0.0.0-...-9165eb6 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: CC0-1.0 Imports: 12 Imported by: 0

Documentation

Overview

Package hitable implements the methods used to compute intersections between a ray and geometry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BVHNode

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

BVHNode represents a bounding volume hierarchy node.

func NewBVH

func NewBVH(hitables []Hitable, time0 float64, time1 float64) *BVHNode

func (*BVHNode) BoundingBox

func (bn *BVHNode) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*BVHNode) Hit

func (bn *BVHNode) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*BVHNode) PDFValue

func (bn *BVHNode) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*BVHNode) Random

func (bn *BVHNode) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type Box

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

Box represents a box.

func NewBox

func NewBox(p0 *vec3.Vec3Impl, p1 *vec3.Vec3Impl, mat material.Material) *Box

func (*Box) BoundingBox

func (b *Box) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*Box) Hit

func (b *Box) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*Box) PDFValue

func (b *Box) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*Box) Random

func (b *Box) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type ConstantMedium

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

ConstantMedium represents a medium with constant density.

func NewConstantMedium

func NewConstantMedium(hitable Hitable, density float64, a texture.Texture) *ConstantMedium

NewConstantMedium returns a new instance of the constant medium hitable.

func (*ConstantMedium) BoundingBox

func (cm *ConstantMedium) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*ConstantMedium) Hit

func (*ConstantMedium) PDFValue

func (cm *ConstantMedium) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*ConstantMedium) Random

func (cm *ConstantMedium) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type FlipNormals

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

FlipNormals represents a hitable with the inverted normal.

func NewFlipNormals

func NewFlipNormals(hitable Hitable) *FlipNormals

NewFlipNormals returns a hitable with inverted normals.

func (*FlipNormals) BoundingBox

func (fn *FlipNormals) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*FlipNormals) Hit

func (fn *FlipNormals) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*FlipNormals) PDFValue

func (fn *FlipNormals) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*FlipNormals) Random

func (fn *FlipNormals) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type Hitable

type Hitable interface {
	Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)
	BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)
	PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64
	Random(o *vec3.Vec3Impl) *vec3.Vec3Impl
}

Hitable defines the methods to compute ray/geometry operations.

type HitableSlice

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

HitableSlice represents a list of hitable entities.

func NewSlice

func NewSlice(hitables []Hitable) *HitableSlice

NewSlice returns an instance of HitableSlice.

func (*HitableSlice) BoundingBox

func (hs *HitableSlice) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*HitableSlice) Hit

Hit computes whether a ray intersects with any of the elements in the slice.

func (*HitableSlice) PDFValue

func (hs *HitableSlice) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*HitableSlice) Random

func (hs *HitableSlice) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type RotateY

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

RotateY represents a rotation along the Y axis.

func NewRotateY

func NewRotateY(hitable Hitable, angle float64) *RotateY

NewRotateY returns a new hitable rotated along the Y axis.

func (*RotateY) BoundingBox

func (ry *RotateY) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*RotateY) Hit

func (ry *RotateY) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*RotateY) PDFValue

func (ry *RotateY) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*RotateY) Random

func (ry *RotateY) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type Sphere

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

Sphere represents a sphere in the 3d world.

func NewSphere

func NewSphere(center0 *vec3.Vec3Impl, center1 *vec3.Vec3Impl, time0 float64, time1 float64, radius float64, material material.Material) *Sphere

NewSphere returns a new instance of Sphere.

func (*Sphere) BoundingBox

func (s *Sphere) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*Sphere) Hit

func (s *Sphere) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

Hit computes whether a ray intersects with the defined sphere.

func (*Sphere) PDFValue

func (s *Sphere) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*Sphere) Random

func (s *Sphere) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type Translate

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

Translate represents a hitable with its associated translation.

func NewTranslate

func NewTranslate(hitable Hitable, offset *vec3.Vec3Impl) *Translate

NewTranslate returns an instance of a translated hitable.

func (*Translate) BoundingBox

func (tr *Translate) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*Translate) Hit

func (tr *Translate) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*Translate) PDFValue

func (tr *Translate) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*Translate) Random

func (tr *Translate) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type XYRect

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

XYRect represents an axis aligned rectangle.

func NewXYRect

func NewXYRect(x0 float64, x1 float64, y0 float64, y1 float64, k float64, mat material.Material) *XYRect

NewXYRect returns an instance of an axis aligned rectangle.

func (*XYRect) BoundingBox

func (xyr *XYRect) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*XYRect) Hit

func (xyr *XYRect) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*XYRect) PDFValue

func (xyr *XYRect) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*XYRect) Random

func (xyr *XYRect) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type XZRect

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

XZRect represents an axis aligned rectangle.

func NewXZRect

func NewXZRect(x0 float64, x1 float64, z0 float64, z1 float64, k float64, mat material.Material) *XZRect

NewXZRect returns an instance of an axis aligned rectangle.

func (*XZRect) BoundingBox

func (xzr *XZRect) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*XZRect) Hit

func (xzr *XZRect) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*XZRect) PDFValue

func (xzr *XZRect) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*XZRect) Random

func (xzr *XZRect) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

type YZRect

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

YZRect represents an axis aligned rectangle.

func NewYZRect

func NewYZRect(y0 float64, y1 float64, z0 float64, z1 float64, k float64, mat material.Material) *YZRect

NewYZRect returns an instance of an axis aligned rectangle.

func (*YZRect) BoundingBox

func (yzr *YZRect) BoundingBox(time0 float64, time1 float64) (*aabb.AABB, bool)

func (*YZRect) Hit

func (yzr *YZRect) Hit(r ray.Ray, tMin float64, tMax float64) (*hitrecord.HitRecord, material.Material, bool)

func (*YZRect) PDFValue

func (yzr *YZRect) PDFValue(o *vec3.Vec3Impl, v *vec3.Vec3Impl) float64

func (*YZRect) Random

func (yzr *YZRect) Random(o *vec3.Vec3Impl) *vec3.Vec3Impl

Jump to

Keyboard shortcuts

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