smoothsurface

package
v0.0.0-...-40e05f8 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Smooth

func Smooth(surface *geo.Surface, kernel []float64, goroutines ...int)

Smooth applies a kernel vertically and horizontally in place on the surface. For most purposes the SmoothSurface object may be more efficient since it only smooths values that are accessed. TODO: There is probably a better, cleaner way to do this.

Types

type LazySmoothSurface

type LazySmoothSurface struct {
	*geo.Surface
	// contains filtered or unexported fields
}

LazySmoothSurface provides ValueAt and GradientAt function based on a surface vertically and horizontally smoothed using the given kernel. The values are smoothed on request and cached. Note that is takes 3x the memory, but using arrays vs maps with locking was 2x faster. Cache hit rate for a 100 iteration sample was 50% for the grid value and 99+% for the Intermediate vertical smoothing values.

func New

func New(surface *geo.Surface, kernel []float64) *LazySmoothSurface

New creates a new smooth service using the kernel.

func (*LazySmoothSurface) GradientAt

func (s *LazySmoothSurface) GradientAt(point *geo.Point) *geo.Point

GradientAt is the same as for a normal surface but with the smoothing kernel applied.

func (*LazySmoothSurface) SetKernel

func (s *LazySmoothSurface) SetKernel(kernel []float64)

SetKernel allows the updating of the kernel used. The cache is cleared.

func (*LazySmoothSurface) SmoothedGrid

func (s *LazySmoothSurface) SmoothedGrid(x, y int) float64

SmoothedGrid provides the same stuff as surface.Grid[x][y] but smoothed vertically and horizontally by the given kernel. Computed values are cached.

func (*LazySmoothSurface) ValueAt

func (s *LazySmoothSurface) ValueAt(point *geo.Point) float64

ValueAt is the same as for a normal surface but with the smoothing kernel applied.

Jump to

Keyboard shortcuts

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