math

package
v0.0.0-...-899be5f Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abs

func Abs(value float64) float64

func Clamp

func Clamp(value, a, b float64) float64

func DegreesToRadians

func DegreesToRadians(degrees float64) float64

func Distance

func Distance(a, b *Point3) float64

func Dot

func Dot(a, b *Vec3) float64

func Max

func Max(a, b float64) float64

func Min

func Min(a, b float64) float64

Types

type Aabb

type Aabb struct {
	Min, Max *Point3
}

func SurroundingBox

func SurroundingBox(box0, box1 *Aabb) *Aabb

func (*Aabb) Hit

func (self *Aabb) Hit(ray *Ray, tMin, tMax float64) bool

type AabbBuilder

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

func MakeAabbBuilder

func MakeAabbBuilder() *AabbBuilder

func (*AabbBuilder) AddPoint

func (this *AabbBuilder) AddPoint(p *Point3)

func (*AabbBuilder) GetBox

func (this *AabbBuilder) GetBox() *Aabb

type Onb

type Onb struct {
	U, V, W *Vec3
}

func BuildOnbFromW

func BuildOnbFromW(n *Vec3) *Onb

func MakeOnbFromDirection

func MakeOnbFromDirection(dir, up *Vec3) *Onb

func (*Onb) Local

func (this *Onb) Local(v *Vec3) *Vec3

type Perlin

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

func MakePerlin

func MakePerlin(rng *RandExt) *Perlin

func (*Perlin) Noise

func (this *Perlin) Noise(p *Point3) float64

func (*Perlin) Turb

func (this *Perlin) Turb(p *Point3, depth int) float64

type Point3

type Point3 struct {
	*Vec3
}

func MakePoint3

func MakePoint3(x, y, z float64) *Point3

func (*Point3) Move

func (p *Point3) Move(v *Vec3) *Point3

type RandExt

type RandExt struct {
	*rand.Rand
}

func MakeRandExt

func MakeRandExt(seed int) *RandExt

func (*RandExt) Between

func (this *RandExt) Between(a, b float64) float64

func (*RandExt) RandomCosineDirection

func (this *RandExt) RandomCosineDirection() *Vec3

func (*RandExt) RandomInHemisphere

func (this *RandExt) RandomInHemisphere(normal *Vec3) *Vec3

func (*RandExt) RandomInUnitDisk

func (this *RandExt) RandomInUnitDisk() *Vec3

func (*RandExt) RandomInUnitSphere

func (this *RandExt) RandomInUnitSphere() *Vec3

func (*RandExt) RandomToSphere

func (this *RandExt) RandomToSphere(radius, distance2 float64) *Vec3

func (*RandExt) RandomUnitVector

func (this *RandExt) RandomUnitVector() *Vec3

type Ray

type Ray struct {
	Origin    *Point3
	Direction *Vec3
	Time      float64
}

func MakeRayFromDirection

func MakeRayFromDirection(origin *Point3, dir *Vec3, time float64) *Ray

func MakeRayFromPoints

func MakeRayFromPoints(origin, target *Point3, time float64) *Ray

func (*Ray) At

func (r *Ray) At(t float64) *Point3

type Vec2

type Vec2 struct {
	X, Y float64
}

type Vec3

type Vec3 struct {
	X, Y, Z float64
}

func Cross

func Cross(u, v *Vec3) *Vec3

func GetDirection

func GetDirection(a, b *Point3) *Vec3

func (*Vec3) Add

func (v *Vec3) Add(a *Vec3) *Vec3

func (*Vec3) AsColor

func (v *Vec3) AsColor() color.Color

func (*Vec3) AsPoint3

func (v *Vec3) AsPoint3() *Point3

func (*Vec3) Length

func (v *Vec3) Length() float64

func (*Vec3) Length2

func (v *Vec3) Length2() float64

func (*Vec3) Mul

func (v *Vec3) Mul(t float64) *Vec3

func (*Vec3) MulVec

func (v *Vec3) MulVec(a *Vec3) *Vec3

func (*Vec3) NearZero

func (v *Vec3) NearZero() bool

func (*Vec3) Normalize

func (v *Vec3) Normalize() *Vec3

func (*Vec3) Sub

func (v *Vec3) Sub(a *Vec3) *Vec3

Jump to

Keyboard shortcuts

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