sampleutil

package
v0.0.0-...-ec9fd1c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2012 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package sampleutil provides useful sampling functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMod1

func AddMod1(a, b float64) (s float64)

AddMod1 performs an floating-point addition modulo 1. Both values must be in the range [0,1].

func Cone

func Cone(d, u, v vec64.Vector, maxCosAngle, s1, s2 float64) vec64.Vector

Cone uniformly samples a cone.

func CosHemisphere

func CosHemisphere(n, ru, rv vec64.Vector, s1, s2 float64) (v vec64.Vector)

CosHemisphere samples a cosine-weighted hemisphere given the coordinate system built by n, ru, and rv.

func Sphere

func Sphere(s1, s2 float64) (dir vec64.Vector)

Sphere uniformly samples a sphere.

Types

type Pdf1D

type Pdf1D struct {
	F, Cdf   []float64
	Integral float64
}

Pdf1D stores a 1-dimensonal probability distribution function.

func NewPdf1D

func NewPdf1D(f []float64) (p Pdf1D)

NewPdf1D creates a new probably distribution function and calculates its cumulative distribution function.

func (Pdf1D) DiscreteSample

func (p Pdf1D) DiscreteSample(u float64) (index int, pdf float64)

func (Pdf1D) Len

func (p Pdf1D) Len() int

func (Pdf1D) Sample

func (p Pdf1D) Sample(u float64) (offset, pdf float64)

Jump to

Keyboard shortcuts

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