sierpinski

package
v0.0.0-...-7a21720 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: CC0-1.0 Imports: 4 Imported by: 1

Documentation

Overview

Package sierpinski produces the vertices of a space-filling Sierpinski curve.

Index

Constants

View Source
const (
	S = Orientation(iota) // XY -> XY.
	R                     // XY -> YXn.
	P                     // XY -> YnX.
	Z                     // XY -> XnYn.
)

An orientation of the basic motif.

For a detailed explanation of these orientations see (Bader 80).

  • (Bader 80). Bader, Michael. Space-Filling Curves, An Introduction with Applications in Scientific Computing. Springer. 2013.
View Source
const (
	A = Region(iota)
	B
	C
	D
	E
	F
	G
	H
)

= \ C | B / = \ | / = D \ | / A = - - - - -|- - - - - = E / | \ H = / | \ = / F | G \

Variables

This section is empty.

Functions

func Vertices

func Vertices(spec PlotSpec) []maf.Vec

Vertices of a 2D Sierpinski curve.

Types

type CurvePath

type CurvePath [4]struct {
	Region
	Orientation
}

CurvePath through the sub regions.

The curve path progresses through the indices in increasing order: 0, 1, 2, 3.

func Magnify

func Magnify(ori Orientation) CurvePath

Magnify a section of the curve which consists of the basic motif with the given orientation.

type CurveRegion

type CurveRegion struct {
	MidHypot  maf.Vec     // The midpoint of the region's hypotenuse.
	HalfHypot float64     // Half the length of the hypotenuse of the region.
	Ori       Orientation // The orientation of the region's basic motif.
}

CurveRegion of a Sierpinski curve.

Each curve region consists of a right isosceles divided into four right isosceles.

func (CurveRegion) SubRegions

func (q CurveRegion) SubRegions() [4]CurveRegion

SubRegions of the receiver region in order of the direction of the curve through the sub regions.

func (CurveRegion) Vertices

func (reg CurveRegion) Vertices() [4]maf.Vec

Vertices of the curve in the region in the order of the curve's path through the region.

type Orientation

type Orientation uint

Orientation of the basic motif.

type PlotSpec

type PlotSpec struct {
	// Centre of the 2D square region occupied by the Sierpinski curve.
	//
	// The vertices of the curve will be in a plane parallel to the Z=0 plane.
	Centre maf.Vec
	// Iterations of the magnification process applied to the basic motif.
	//
	// The number of iterations does not equal the order of the curve because
	// the algorithm skips every other order of the curve.
	Iterations int
	// Width of the 2D square region occupied by the Sierpinski curve.
	W float64
}

PlotSpec specifies the properties of a Sierpinski curve.

type Region

type Region uint

A Region that can be occupied by a suitably oriented basic motif.

Jump to

Keyboard shortcuts

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