chapter3

package
v0.0.0-...-979f466 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package chapter3 provides utilities for mandelbrot and surface plots.

Index

Constants

View Source
const (
	// MBXMin is lower bound of x value for MB (Mandelbrot Set)
	MBXMin = -2
	// MBXMax is upper bound of x value for MB (Mandelbrot Set)
	MBXMax = 2
	// MBYMin is lower bound of y value for MB (Mandelbrot Set)
	MBYMin = -2
	// MBYMax is upper bound of y value for MB (Mandelbrot Set)
	MBYMax = 2
	// MBWidth pixels wide (along x-axis)
	MBWidth = 1024
	// MBHeight pixels high (along y-axis)
	MBHeight = 1024
	// MBContrast contrast desired
	MBContrast = 100
	// MBSubPixels number of pixels to take average for super aliasing
	MBSubPixels = 4
	// MaxGoRoutines for concurrency
	MaxGoRoutines = 32
)

Mandelbrot Set Graph constants

View Source
const (
	// SurfaceWidth width of #D surface plot
	SurfaceWidth = 1200
	// SurfaceHeight Height of #D surface plot
	SurfaceHeight = 800
	// SurfaceGridCells number of cells in a grid
	SurfaceGridCells = 50
	// SurfaceXYRange of x-axis from -SurfaceXYRange .. +SurfaceXYRange
	SurfaceXYRange = 30.0
	// SurfaceXYScale scaling x data to plot on graph
	SurfaceXYScale = SurfaceWidth / 2 / SurfaceXYRange
	// SurfaceZScale scaling x data to plot on graph
	SurfaceZScale = SurfaceHeight * 0.4
	// SurfaceAngle30 at which x and y are angled
	SurfaceAngle30 = math.Pi / 6
	// SVGPrefixFormat element prefix
	SVGPrefixFormat = `<svg xmlns="http://www.w3.org/2000/svg" style="stroke: grey; fill: white; stroke-width:0.7" width="100%%" height="100%%" viewBox="0 0 %d %d">` + "\n"
	// SVGSuffixTag closes <svg> ... </svg>
	SVGSuffixTag = "</svg>"
)

Surface plot 3D (x,y,z) constants to plot on a 2-D graph

View Source
const (
	EggDenominator     = 10
	SquaresDenominator = 5
)

Variables

This section is empty.

Functions

func Egg

func Egg(x, y float64) float64

Egg sampling function returns squares

func EggHandlerSVG

func EggHandlerSVG(w io.Writer)

EggHandlerSVG draws an egg on a writer

func MBGraphBWHandler

func MBGraphBWHandler(w http.ResponseWriter, _ *http.Request)

MBGraphBWHandler in black

func MBGraphHandler

func MBGraphHandler(w http.ResponseWriter, _ *http.Request)

MBGraphHandler returns a color image.

func PlotOn3DSurface

func PlotOn3DSurface(w io.Writer, plot func(float64, float64) float64)

PlotOn3DSurface plats z = f(x,y) as a wire on a 3-D mesh surface using SVG (Scalable Vector Graphics)

See SVG on https://www.w3schools.com/graphics/svg_intro.asp
Example, makes a hexagon
<svg width="100" height="100">
  <polygon points="25,0 50,0 75,25 50,50 25,50 0,25" stroke="green" stroke-width="4" fill="yellow" />
</svg>

func Sinc

func Sinc(x, y float64) float64

Sinc sampling function returns 1 or sin r / r

https://mathworld.wolfram.com/SincFunction.html

func SincSVG

func SincSVG(w io.Writer)

SincSVG writes raw SVG content

func Squares

func Squares(x, y float64) float64

Squares of sorts

func SquaresHandlerSVG

func SquaresHandlerSVG(w io.Writer)

SquaresHandlerSVG draws a sinc on a writer

func Valley

func Valley(x, y float64) float64

Valley of sorts

func ValleyHandlerSVG

func ValleyHandlerSVG(w io.Writer)

ValleyHandlerSVG draws a Valley on a writer

Types

type MandelbrotImage

type MandelbrotImage int
const (
	// MBBlackAndWhite draws MB in Black and White
	MBBlackAndWhite MandelbrotImage = iota
	MBColor
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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