pdf

package
v1.0.0 Latest Latest
Warning

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

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

Documentation

Overview

Package pdf provides probability density functions

Index

Constants

View Source
const (
	SpherePdfValue float64 = 1 / (4 * math.Pi)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CosinePdf

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

CosinePdf is a probability density functions with a cosine distribution

func (CosinePdf) Generate

func (p CosinePdf) Generate() geo.Vec3

Generate random direction for the CosinePdf shape

func (CosinePdf) Value

func (p CosinePdf) Value(direction geo.Vec3) float64

Value returns the pdf value for a given vector for the CosinePdf

type MixturePdf

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

MixturePdf is for generating a mixture of two different probability density functions

func (MixturePdf) Generate

func (p MixturePdf) Generate() geo.Vec3

Generate random direction for the MixturePdf shape. Which is randomly chosen between the two base pdfs.

func (MixturePdf) Value

func (p MixturePdf) Value(direction geo.Vec3) float64

Value returns the pdf value for a given vector for the MixturePdf. Which is the average of the two base pdfs

type Pdf

type Pdf interface {
	Value(direction geo.Vec3) float64
	Generate() geo.Vec3
}

Pdf is the common interface for the probability density functions

func NewCosinePdf

func NewCosinePdf(w geo.Vec3) Pdf

NewCosinePdf creates a new instance of a CosinePdf

func NewMixturePdf

func NewMixturePdf(p0, p1 Pdf) Pdf

NewMixturePdf creates a new instance of a MixturePdf

func NewSpherePdf

func NewSpherePdf() Pdf

NewSpherePdf creates a new instance of a SpherePdf

type SpherePdf

type SpherePdf struct{}

SpherePdf is a probability density functions with a sphere distribution

func (SpherePdf) Generate

func (p SpherePdf) Generate() geo.Vec3

Generate random direction for the SpherePdf shape

func (SpherePdf) Value

func (p SpherePdf) Value(direction geo.Vec3) float64

Value returns the pdf value for a given vector for the SpherePdf

Jump to

Keyboard shortcuts

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