spherand

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2020 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package spherand generates random points uniformly on a sphere.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Geographical

func Geographical() (lat, lng float64)

Geographical returns a random geographical point as latitude in degrees between -90 and 90, and longitude between -180 and 180. This package level function uses the default random source.

func Spherical

func Spherical() (azimuth, polar float64)

Spherical generates a random point on the unit sphere in spherical coordinates. This returns an azimuthal angle in radians between 0 and 2pi and a polar angle between 0 and pi. This package level function uses the default random source.

Types

type Generator

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

Generator can generate spherical points based on a configured source of uniform random values.

func NewGenerator

func NewGenerator(sampler UniformSampler) Generator

NewGenerator builds a Generator backed by the given uniform sampler. Note that the standard library rand.Rand can be used as a UniformSampler.

func (Generator) Geographical

func (g Generator) Geographical() (lat, lng float64)

Geographical returns a random geographical point as latitude in degrees between -90 and 90, and longitude between -180 and 180.

func (Generator) Spherical

func (g Generator) Spherical() (azimuth, polar float64)

Spherical generates a random point on the unit sphere in spherical coordinates. This returns an azimuthal angle in radians between 0 and 2pi and a polar angle between 0 and pi.

type UniformSampler

type UniformSampler interface {
	Float64() float64
}

UniformSampler generates samples from the uniform distribution on [0,1).

type UniformSamplerFunc

type UniformSamplerFunc func() float64

UniformSamplerFunc can satisfy the UniformSampler interface with a plain function.

func (UniformSamplerFunc) Float64

func (f UniformSamplerFunc) Float64() float64

Float64 calls f.

Jump to

Keyboard shortcuts

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