wire

package module
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: 16 Imported by: 8

README

Package wire

import "gitlab.com/fospathi/wire"

Go package wire is a collection of wireframe geometric figures.

Development status

Package wire is unstable; expect breaking changes with every commit.

Examples

These examples show how you may, in combination with package wiregl, make images of wireframe figures.

License

CC0{height=75}

SPDX-License-Identifier: CC0-1.0 OR MIT-0

  • wire by Christian Stewart is marked with CC0 1.0 Universal

  • MIT No Attribution

    Copyright 2023 Christian Stewart

    Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.

    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

View Source
const (
	// TrigQual is the default quality of a sin figure and some other
	// trigonometric figures.
	TrigQual = 12

	// LineQual is the default quality of a line figure and some other linear
	// figures.
	LineQual = 10
)

Variables

This section is empty.

Functions

func DepictBezCircTangency

func DepictBezCircTangency(
	fr maf.Frame,
	spec BezCircTangencyFiguration,
	p BezCircTangencyPortion,
) mech.Depiction

DepictBezCircTangency depicts the given portions/(parameter intervals) on a Bezier circle tangency.

func DepictCatenary

func DepictCatenary(
	fr maf.Frame,
	a float64,
	vp []mech.Portion,
) mech.Depiction

DepictCatenary depicts the given portions/(parameter intervals) on a catenary curve.

func DepictCircle

func DepictCircle(
	fr maf.Frame,
	r float64,
	vp []mech.Portion,
) mech.Depiction

DepictCircle depicts the given portions/(parameter intervals) on a circle.

func DepictCone

func DepictCone(
	fr maf.Frame,
	spec ConeFiguration,
	p ConePortion,
) mech.Depiction

DepictCone depicts the given cone portions/(parameter intervals) on a cone.

func DepictCos

func DepictCos(
	fr maf.Frame,
	vp ...mech.Portion,
) mech.Depiction

DepictCos depicts the given portions/(parameter intervals) on a cos curve.

func DepictCube

func DepictCube(
	fr maf.Frame,
	l float64,
	p CubePortion,
) mech.Depiction

DepictCube depicts the given cube portions/(parameter intervals) on a cube.

func DepictCycloid

func DepictCycloid(
	fr maf.Frame,
	r float64,
	vp []mech.Portion,
) mech.Depiction

DepictCycloid depicts the given portions/(parameter intervals) on a cycloid.

func DepictDelaunayTriangulation

func DepictDelaunayTriangulation(
	fr maf.Frame,
	segs []maf.LineSeg2,
	vp []mech.Portion,
) mech.Depiction

DepictDelaunayTriangulation depicts the given portions/(parameter intervals) on a Delaunay triangulation.

func DepictEllipse

func DepictEllipse(
	fr maf.Frame,
	a float64,
	b float64,
	vp []mech.Portion,
) mech.Depiction

DepictEllipse depicts the given portions/(parameter intervals) on an ellipse.

func DepictGrid

func DepictGrid(
	fr maf.Frame,
	spec GridFiguration,
	p GridPortion,
) mech.Depiction

DepictGrid depicts the given grid portions/(parameter intervals) on a grid.

func DepictGridDisk

func DepictGridDisk(
	fr maf.Frame,
	spec GridDiskFiguration,
	p GridPortion,
) mech.Depiction

DepictGridDisk depicts the given grid portions/(parameter intervals) on a grid disk.

func DepictHelix

func DepictHelix(
	fr maf.Frame,
	spec kirv.Helix,
	vp []mech.Portion,
) mech.Depiction

DepictHelix depicts the given portions/(parameter intervals) on a helix.

func DepictLatitudes

func DepictLatitudes(
	fr maf.Frame,

	n int,

	r float64,

	equid bool,
	vp []mech.Portion,
) mech.Depiction

DepictLatitudes draws latitudinal circles parallel to the frame's XY plane.

Let the Z-axis of the frame be the main north to south axis of a sphere centered on the frame's origin.

func DepictLineSeg

func DepictLineSeg(
	fr maf.Frame,
	seg maf.LineSeg,
	vp []mech.Portion,
) mech.Depiction

DepictLineSeg depicts the given line segment portions/(parameter intervals) on a line segment.

func DepictMultiPartPolyLine

func DepictMultiPartPolyLine(
	fr maf.Frame,
	parts [][]maf.Vec,
	vp []mech.Portion,
) mech.Depiction

DepictMultiPartPolyLine depicts the given portions/(parameter intervals) on a multipart polyline such that there is a gap between the parts.

func DepictPlanarParametric

func DepictPlanarParametric(
	fr maf.Frame,
	posTan func(t float64) (maf.Vec, maf.Vec),
	vp []mech.Portion,
) mech.Depiction

DepictPlanarParametric depicts the given portions on the parametric curve defined by the given position tangent function.

func DepictPlot

func DepictPlot(
	fr maf.Frame,
	f func(t float64) maf.Vec,
	vp []mech.Portion,
) mech.Depiction

DepictPlot depicts the given portions/(parameter intervals) on a function.

func DepictPolyLine

func DepictPolyLine(
	fr maf.Frame,
	points []maf.Vec,
	vp []mech.Portion,
) mech.Depiction

DepictPolyLine depicts the given portions/(parameter intervals) on a polyline.

func DepictQuadraticBezier

func DepictQuadraticBezier(
	fr maf.Frame,
	bez maf.Bez,
	vp []mech.Portion,
) mech.Depiction

DepictQuadraticBezier depicts the given portions/(parameter intervals) on a quadratic Bezier curve.

func DepictSin

func DepictSin(
	fr maf.Frame,
	vp []mech.Portion,
) mech.Depiction

DepictSin depicts the given portions/(parameter intervals) on a sin curve.

func DepictSinusoid

func DepictSinusoid(
	fr maf.Frame,
	spec SinusoidFiguration,
	vp []mech.Portion,
) mech.Depiction

DepictSinusoid depicts the given portions/(parameter intervals) on a sinusoid.

func DepictSphere

func DepictSphere(
	fr maf.Frame,
	spec SphereFiguration,
	p SpherePortion,
) mech.Depiction

DepictSphere depicts the given sphere portions/(parameter intervals) on a sphere.

func DepictStandingWave

func DepictStandingWave(
	fr maf.Frame,
	spec StandingWaveFiguration,
	p StandingWavePortion,
) mech.Depiction

DepictStandingWave depicts the given portions/(parameter intervals) on a sinusoidal standing wave.

func DepictTimeDepArchimedean

func DepictTimeDepArchimedean(
	fr maf.Frame,
	spec kinem.Archimedean,
	vp []mech.Portion,
) mech.Depiction

DepictTimeDepArchimedean depicts the given portions/(parameter intervals) on an Archimedean spiral.

func DepictTimeDepProjectile

func DepictTimeDepProjectile(
	fr maf.Frame,
	spec kinem.Projectile,
	vp []mech.Portion,
) mech.Depiction

DepictTimeDepProjectile depicts the given portions/(parameter intervals) on a projectile.

Types

type BezCircTangency

type BezCircTangency struct {
	depictioner.Figure

	BezCircTangencyFiguration
}

BezCircTangency is a wireframe tangency curve figure for the tangency to a circle by a quadratic Bezier curve.

func NewBezCircTangency

func NewBezCircTangency(spec BezCircTangencyFiguration) *BezCircTangency

NewBezCircTangency constructs a new BezCircTangency which is initially oriented with a standard frame.

func (*BezCircTangency) Depict

func (fig *BezCircTangency) Depict(p BezCircTangencyPortion)

Depict the given portions/(parameter intervals) on the Bezier circle tangency, overwriting the previous depiction(s) if any.

type BezCircTangencyFiguration

type BezCircTangencyFiguration struct {
	// Bez has its non-middle control points A and C fixed.
	//
	// The middle control point B shall be non-collinear with the other two and
	// serves only to define the curve's intrinsic plane.
	//
	// The line AC shall be outside the sphere.
	Bez maf.Bez

	// Sphere shall intersect the plane of the Bezier curve thus generating the
	// circle that the Bezier curve touches tangentially.
	Sphere maf.Sphere

	// CloserBranchT and FartherBranchT give the proportion of the angle, in the
	// range 0..1, through their respective angle interval for their respective
	// branch.
	CloserBranchT, FartherBranchT float64

	// The radius of the circle displayed around the tangent point of the
	// respective branch.
	CloserBranchTangentCircleR, FartherBranchTangentCircleR float64
	// The radius of the circle displayed around the middle control point of the
	// respective branch.
	CloserBranchControlCircleR, FartherBranchControlCircleR float64

	// Put some distance between the branch depictions and the main circle with
	// a non-zero offset.
	CloserBranchZOffset, FartherBranchZOffset float64
}

BezCircTangencyFiguration specifies the input geometry required for visualizing the tangency to a circle by a quadratic Bezier curve.

There are in general two solutions referred to here as the closer branch solution and the farther branch solution. Each solution is comprised of two distinct point sets, one point set being a circular arc of tangentially touched points on the circle and the other being the associated tangency locus for the middle control point of the quadratic Bezier.

The closer branch solution consists of i.) the arc of tangentially touched points on the circle which is closer to the non-middle control points of the Bezier and ii.) the associated tangency locus for the middle control point.

The farther branch solution consists of i.) the arc of tangentially touched points on the circle which is farther from the non-middle control points of the Bezier and ii.) the associated tangency locus for the middle control point.

type BezCircTangencyPortion

type BezCircTangencyPortion struct {
	CloserBranchArc    []mech.Portion
	CloserBranchBezier []mech.Portion
	CloserBranchLocus  []mech.Portion

	FartherBranchArc    []mech.Portion
	FartherBranchBezier []mech.Portion
	FartherBranchLocus  []mech.Portion

	Circle []mech.Portion

	CloserBranchControlCircle []mech.Portion
	CloserBranchTangentCircle []mech.Portion

	FartherBranchControlCircle []mech.Portion
	FartherBranchTangentCircle []mech.Portion

	CloserBranchAB []mech.Portion
	CloserBranchCB []mech.Portion

	FartherBranchAB []mech.Portion
	FartherBranchCB []mech.Portion

	AC []mech.Portion
}

BezCircTangencyPortion specifies which parts of a BezCircTangency's wireframe to show.

The arc, Bezier, and locus portions' parameter intervals are in unitless proportions of their respective branches angular domains and shall be clamped to the range 0..1.

The circle, control circle, and tangent circle portions' parameter intervals are in radians.

type Catenary

type Catenary struct {
	depictioner.Figure

	// A is the Y-intercept value and scales the curve.
	A float64
}

Catenary is a wireframe catenary curve figure.

Relative to its orientation frame the curve is in the Z=0 plane.

func NewCatenary

func NewCatenary(a float64) *Catenary

NewCatenary constructs a new Catenary with the given Y-axis intercept value which is initially oriented with a standard frame.

func (*Catenary) Depict

func (fig *Catenary) Depict(vp ...mech.Portion)

Depict the given portions/(X-axis intervals) on the catenary curve, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are distance.

The portions' quality has units of "quadratic Beziers per unit distance" and when left unset a sensible default is used.

type Circle

type Circle struct {
	depictioner.Figure

	// R is the circle's radius.
	R float64
}

Circle is a wireframe circle figure.

Relative to its orientation frame the circle is in the Z=0 plane and is centered on the origin.

func NewCircle

func NewCircle(r float64) *Circle

NewCircle constructs a new Circle with the given radius which is initially oriented with a standard frame.

func (*Circle) Depict

func (fig *Circle) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the circle, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are radians.

The portions' quality has units of "quadratic Beziers per 2π radians" and when left unset a sensible default is used.

type Cone

type Cone struct {
	depictioner.Figure

	ConeFiguration
}

A Cone is a wireframe right circular cone figure.

Relative to its orientation frame the cone base is in the Z=0 plane and is centered on the origin.

func NewCone

func NewCone(spec ConeFiguration) *Cone

NewCone constructs a new Cone which is initially oriented with a standard frame.

func (*Cone) Depict

func (fig *Cone) Depict(p ConePortion)

Depict the given portions/(parameter intervals) on the cone, overwriting the previous depiction(s) if any.

type ConeFiguration

type ConeFiguration struct {
	// The number of concentric circles on the flat base, including the
	// directrix.
	CC int
	// The number of lateral circles, perpendicular to the axis, on the slanted
	// surface but not including the directrix.
	LC int

	// The number of diameter line segments on the base.
	D int
	// The number of pairs of generatrix.
	G int

	// The perpendicular distance from the apex to the base, that is, the cone's
	// height.
	H float64
	// The radius of the base.
	R float64
}

ConeFiguration specifies the geometry of a wireframe cone figure.

Cone terminology:

  • apex: the pointed tip.
  • axis: straight line passing through the apex, about which the base has a circular symmetry.
  • directrix: the perimeter of the base.
  • generatrix: lateral line segments between the directrix and apex.

type ConePortion

type ConePortion struct {
	Concentric []mech.Portion // Portions of each of the concentric base circles excluding the directrix.
	Directrix  []mech.Portion // Portions of the directrix.
	Generatrix []mech.Portion // Portions of each of the generatrices.
	Lateral    []mech.Portion // Portions of each of the lateral circles excluding the directrix.
}

A ConePortion specifies which parts of a cone's wireframe to show.

type Cos

type Cos struct {
	depictioner.Figure
}

Cos is a wireframe cos curve figure.

Relative to its orientation frame the curve is in the Z=0 plane.

func NewCos

func NewCos() *Cos

NewCos constructs a new Cos which is initially oriented with a standard frame.

func (*Cos) Depict

func (fig *Cos) Depict(vp ...mech.Portion)

Depict the given portions/(X-axis intervals) on the cos curve, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are radians.

The portions' quality has units of "quadratic Beziers per 2π radians" and when left unset a sensible default is used.

type Cube

type Cube struct {
	depictioner.Figure

	// L is the length of any side of the cube.
	L float64
}

A Cube is a wireframe cube figure.

Relative to its orientation frame the cube is centered on the origin.

func NewCube

func NewCube(l float64) *Cube

NewCube constructs a new Cube with the given side length which is initially oriented with a standard frame.

func (*Cube) Depict

func (fig *Cube) Depict(p CubePortion)

Depict the given portions/(parameter intervals) on the cube, overwriting the previous depiction(s) if any.

type CubePortion

type CubePortion struct {
	Bottom   []mech.Portion // Portions of each of the four bottom lines.
	Top      []mech.Portion // Portions of each of the four top lines.
	Vertical []mech.Portion // Portions of each of the four vertical lines.
}

A CubePortion specifies which parts of a cube's wireframe to show.

type Cycloid

type Cycloid struct {
	depictioner.Figure

	// R is the radius of the rolling circle which generates the cycloid.
	R float64
}

Cycloid is a wireframe cycloid figure.

Relative to its orientation frame the cycloid is in the Z=0 plane and it begins at the origin and ends on the positive X-axis.

func NewCycloid

func NewCycloid(r float64) *Cycloid

NewCycloid constructs a new Cycloid, generated by a point on a circle with the given radius rolling along the positive X-axis, which is initially oriented with a standard frame.

func (*Cycloid) Depict

func (fig *Cycloid) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the cycloid, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are radians.

The portions' quality has units of "quadratic Beziers per 2π radians", which is effectively the whole cycloid since the valid parameter range is from 0 to 2π, and when left unset a sensible default is used.

type DelaunayFiguration

type DelaunayFiguration struct {
	// The vertices of the triangles.
	P []maf.Vec2
}

DelaunayFiguration specifies the geometry of a wireframe Delaunay triangulation figure.

type DelaunayTriangulation

type DelaunayTriangulation struct {
	depictioner.Figure

	DelaunayFiguration

	Segs []maf.LineSeg2
}

A DelaunayTriangulation is a wireframe Delaunay triangulation figure.

func NewDelaunayTriangulation

func NewDelaunayTriangulation(
	spec DelaunayFiguration,
) *DelaunayTriangulation

NewDelaunayTriangulation constructs a new Delaunay triangulation which is initially oriented with a standard frame.

func (*DelaunayTriangulation) Depict

func (fig *DelaunayTriangulation) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the triangulation, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and they are in units of distance from the triangulation frame origin.

The portions' quality is the literal number of quadratic Beziers to use for each line segment.

type Ellipse

type Ellipse struct {
	depictioner.Figure

	// A is the ellipse's semi-major axis.
	A float64
	// B is the ellipse's semi-minor axis.
	B float64
}

Ellipse is a wireframe ellipse figure.

Relative to its orientation frame the ellipse is in the Z=0 plane and is centered on the origin.

func NewEllipse

func NewEllipse(spec kirv.Ellipse) *Ellipse

NewEllipse constructs a new Ellipse with the given properties which is initially oriented with a standard frame.

func (*Ellipse) Depict

func (fig *Ellipse) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the ellipse, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are radians.

The portions' quality has units of "quadratic Beziers per 2π radians" and when left unset a sensible default is used.

type GoldenDragon

type GoldenDragon struct {
	*PolyLine
}

A GoldenDragon is a wireframe figure that depicts a Heighway golden dragon curve.

func NewGoldenDragon

func NewGoldenDragon(spec heighway.TerdragonPlotSpec) GoldenDragon

NewGoldenDragon constructs a new GoldenDragon curve which is initially oriented with a standard frame.

type Grid

type Grid struct {
	depictioner.Figure

	GridFiguration
}

A Grid is a wireframe grid figure.

Relative to its orientation frame the grid area is in the Z=0 plane and is centered on the origin.

func NewGrid

func NewGrid(spec GridFiguration) *Grid

NewGrid constructs a new Grid which is initially oriented with a standard frame.

func (*Grid) Depict

func (fig *Grid) Depict(p GridPortion)

Depict the given portions/(parameter intervals) on the grid, overwriting the previous depiction(s) if any.

type GridDisk

type GridDisk struct {
	depictioner.Figure

	GridDiskFiguration
}

A GridDisk is a circular section of a wireframe grid figure.

Relative to its orientation frame the disk is in the Z=0 plane and is centered on the origin.

func NewGridDisk

func NewGridDisk(spec GridDiskFiguration) *GridDisk

NewGridDisk constructs a new GridDisk which is initially oriented with a standard frame.

func (*GridDisk) Depict

func (fig *GridDisk) Depict(p GridPortion)

Depict the grid disk, overwriting the previous depiction(s) if any.

type GridDiskFiguration

type GridDiskFiguration struct {
	GridFiguration
	// The radius of the disk.
	R float64
}

GridDiskFiguration specifies the geometry of a circular section of a rectangular grid.

type GridFiguration

type GridFiguration struct {
	// The horizontal and vertical cell dimensions respectively.
	CX, CY float64
	// The horizontal and vertical grid dimensions respectively.
	GX, GY float64

	// The offset of the grid pattern from its default position.
	//
	// The default grid pattern places an intersection point of a horizontal and
	// vertical grid line at the centre of the grid. This intersection point is
	// displaced by the given values modulo their respective cell dimensions.
	//
	// Even though the grid's pattern is displaced for non-zero values, the grid
	// area itself is not displaced and it occupies the same rectangular area.
	OX, OY float64

	// The displacements added to the grid lines' Z-values for the lines
	// parallel to the X and Y-axes respectively.
	//
	// Using non-zero values for these can create gaps that prevent issues with
	// the otherwise overlapping lines.
	ZX, ZY float64
}

GridFiguration specifies the geometry of a rectangular grid.

type GridPortion

type GridPortion struct {
	X []mech.Portion // Portions of each of the horizontal lines.
	Y []mech.Portion // Portions of each of the vertical lines.
}

A GridPortion specifies which parts of a grid's wireframe to show.

type HeighwayDragon

type HeighwayDragon struct {
	*PolyLine
}

A HeighwayDragon is a wireframe figure that depicts a Heighway dragon curve.

func NewHeighwayDragon

func NewHeighwayDragon(spec heighway.PlotSpec) HeighwayDragon

NewHeighwayDragon constructs a new HeighwayDragon curve which is initially oriented with a standard frame.

type HeighwayFudgeflake

type HeighwayFudgeflake struct {
	*PolyLine
}

A HeighwayFudgeflake is a wireframe figure that depicts a Heighway fudgeflake curve.

func NewHeighwayFudgeflake

func NewHeighwayFudgeflake(
	spec heighway.FudgeflakePlotSpec,
) HeighwayFudgeflake

NewHeighwayFudgeflake constructs a new HeighwayFudgeflake curve which is initially oriented with a standard frame.

type HeighwayTwinDragon

type HeighwayTwinDragon struct {
	*MultipartPolyLine
}

HeighwayTwinDragon is a wireframe figure that depicts a Heighway twin dragon curve.

func NewHeighwayTwinDragon

func NewHeighwayTwinDragon(spec heighway.PlotSpec) *HeighwayTwinDragon

NewHeighwayTwinDragon constructs a new HeighwayTwinDragon curve which is initially oriented with a standard frame.

type Helix

type Helix struct {
	depictioner.Figure

	kirv.Helix
}

Helix is a wireframe helix figure.

Relative to its orientation frame the base of the helix is in the Z=0 plane and is centered on the origin.

func NewHelix

func NewHelix(spec kirv.Helix) *Helix

NewHelix constructs a new Helix which is initially oriented with a standard frame.

func (*Helix) Depict

func (fig *Helix) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the helix, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are radians.

The portions' quality has units of "quadratic Beziers per 2π radians" and when left unset a sensible default is used.

type HexTerdragon

type HexTerdragon struct {
	*MultipartPolyLine
}

A HexTerdragon is a wireframe figure that depicts six copies of a Heighway terdragon curve which surround a point.

func NewHexTerdragon

func NewHexTerdragon(spec heighway.TerdragonPlotSpec) HexTerdragon

NewHexTerdragon constructs a new HexTerdragon curve which is initially oriented with a standard frame.

type Hilbert

type Hilbert struct {
	*PolyLine
}

A Hilbert is a wireframe figure that depicts a pseudo Hilbert curve occupying a 2D square region.

Relative to its orientation frame the curve is in a plane parallel to the XY-plane.

func NewHilbert

func NewHilbert(spec hilbert.PlotSpec) Hilbert

NewHilbert constructs a new Hilbert curve which is initially oriented with a standard frame.

func NewHilbert3D

func NewHilbert3D(spec hilbert3d.PlotSpec) Hilbert

NewHilbert3D constructs a new 3D Hilbert curve which is initially oriented with a standard frame.

type Hilbert3D

type Hilbert3D struct {
	*PolyLine
}

A Hilbert3D is a wireframe figure that depicts a pseudo Hilbert curve occupying a 3D cube region.

Relative to its orientation frame the curve is in a cube whose faces are parallel to each of the respective planes of the frame's coordinate system.

type Koch

type Koch struct {
	*PolyLine
}

A Koch is a wireframe figure that depicts a Koch curve.

func NewKoch

func NewKoch(spec koch.PlotSpec) Koch

NewKoch constructs a new Koch curve which is initially oriented with a standard frame.

type KochSnowflake

type KochSnowflake struct {
	*PolyLine
}

A KochSnowflake is a wireframe figure that depicts a Koch snowflake curve.

func NewKochSnowflake

func NewKochSnowflake(spec koch.SnowflakePlotSpec) KochSnowflake

NewKochSnowflake constructs a new KochSnowflake curve which is initially oriented with a standard frame.

type LineSeg

type LineSeg struct {
	depictioner.Figure

	maf.LineSeg
}

A LineSeg is a wireframe line segment figure.

func NewLineSeg

func NewLineSeg(seg maf.LineSeg) *LineSeg

NewLineSeg constructs a new line segment which is initially oriented with a standard frame.

func (*LineSeg) Depict

func (fig *LineSeg) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the line segment, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and they are unitless proportions of the line segment's length in the range 0..1.

The portions' quality is the literal number of quadratic Beziers to use.

type MultipartPolyLine

type MultipartPolyLine struct {
	depictioner.Figure

	// Parts are the polylines' vertices.
	Parts [][]maf.Vec
}

A MultipartPolyLine is a wireframe figure made from distinct polyline parts such that there is a gap between the parts.

func NewMultiPartPolyLine

func NewMultiPartPolyLine(parts [][]maf.Vec) *MultipartPolyLine

NewMultiPartPolyLine constructs a new MultiPartPolyLine which is initially oriented with a standard frame.

func (*MultipartPolyLine) Depict

func (fig *MultipartPolyLine) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the multipart polyline, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and they are unitless proportions of the multipart polyline's total length in the range 0..1.

The portions' quality is the literal number of quadratic Beziers to use for each line segment.

type Peano

type Peano struct {
	*PolyLine
}

A Peano is a wireframe figure that depicts a Peano curve occupying a 2D square region.

Relative to its orientation frame the curve is in a plane parallel to the XY-plane.

func NewPeano

func NewPeano(spec peano.PlotSpec) Peano

NewPeano constructs a new Peano curve which is initially oriented with a standard frame.

type Pentadentrite

type Pentadentrite struct {
	*PolyLine
}

A Pentadentrite is a wireframe figure that depicts a McWorter pentadentrite curve.

func NewPentadentrite

func NewPentadentrite(spec mcworter.PentadentritePlotSpec) Pentadentrite

NewPentadentrite constructs a new Pentadentrite curve which is initially oriented with a standard frame.

type Plot

type Plot struct {
	depictioner.Figure

	// The function which is plotted. The function need not be continuous.
	F func(t float64) maf.Vec
}

Plot is a wireframe figure of a function's trace.

It consists of groups of connected line segments such that the end points of the line segments are generated by the function.

func NewPlot

func NewPlot(f func(t float64) maf.Vec) *Plot

NewPlot constructs a new Plot which is initially oriented with a standard frame.

func (*Plot) Depict

func (fig *Plot) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the function, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their unit of measurement is whatever unit the plotted function's input parameter is.

The portions' quality is the number of line segments to use, or equivalently, one more than the number of points on the function to evaluate.

type PolyLine

type PolyLine struct {
	depictioner.Figure

	// Points are the vertices of the polyline. Each vertex is connected by a
	// line segment to the next vertex in the slice.
	Points []maf.Vec
}

A PolyLine is a wireframe figure made from a connected sequence of line segments.

func NewClosedPolyLine

func NewClosedPolyLine(points []maf.Vec) *PolyLine

NewClosedPolyLine constructs a new closed polyline which is initially oriented with a standard frame.

func NewPolyLine

func NewPolyLine(points []maf.Vec) *PolyLine

NewPolyLine constructs a new polyline which is initially oriented with a standard frame.

func (*PolyLine) Depict

func (fig *PolyLine) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the polyline, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and they are unitless proportions of the polyline's total length in the range 0..1.

The portions' quality is the literal number of quadratic Beziers to use for each line segment.

type QuadraticBezier

type QuadraticBezier struct {
	depictioner.Figure

	Quadratic maf.Bez
}

A QuadraticBezier curve figure defined by three control points.

func NewQuadraticBezier

func NewQuadraticBezier(bez maf.Bez) *QuadraticBezier

NewQuadraticBezier constructs a new QuadraticBezier which is initially oriented with a standard frame.

func (*QuadraticBezier) Depict

func (fig *QuadraticBezier) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the quadratic Bezier curve, overwriting the previous depiction(s) if any.

The portions' parameter intervals shall be clamped to the range 0..1.

type Sierpinski

type Sierpinski struct {
	*PolyLine
}

A Sierpinski is a wireframe figure that depicts a Sierpinski curve occupying a 2D square region.

Relative to its orientation frame the curve's region is parallel to the XY-plane and axis-aligned.

func NewSierpinski

func NewSierpinski(spec sierpinski.PlotSpec) Sierpinski

NewSierpinski constructs a new Sierpinski curve which is initially oriented with a standard frame.

type SierpinskiTriangle

type SierpinskiTriangle struct {
	*PolyLine
}

A SierpinskiTriangle is a wireframe figure that depicts a Sierpinski curve occupying a 2D right isosceles region.

Relative to its orientation frame the curve's region is parallel to the XY-plane and the hypotenuse is axis aligned.

func NewSierpinskiTriangle

func NewSierpinskiTriangle(spec sierpinski.PlotSpec) SierpinskiTriangle

NewSierpinskiTriangle constructs a new SierpinskiTriangle curve which is initially oriented with a standard frame.

type Sin

type Sin struct {
	depictioner.Figure
}

Sin is a wireframe sin curve figure.

Relative to its orientation frame the curve is in the Z=0 plane.

func NewSin

func NewSin() *Sin

NewSin constructs a new Sin which is initially oriented with a standard frame.

func (*Sin) Depict

func (fig *Sin) Depict(vp ...mech.Portion)

Depict the given portions/(X-axis intervals) on the sin curve, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are radians.

The portions' quality has units of "quadratic Beziers per 2π radians" and when left unset a sensible default is used.

type Sinusoid

type Sinusoid struct {
	depictioner.Figure

	SinusoidFiguration
}

Sinusoid is a wireframe sine wave figure.

Relative to its orientation frame the curve is in the Z=0 plane.

func NewSinusoid

func NewSinusoid(spec SinusoidFiguration) *Sinusoid

NewSinusoid constructs a new Sinusoid which is initially oriented with a standard frame.

func (*Sinusoid) Depict

func (fig *Sinusoid) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the sinusoid, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are distance.

The portions' quality has units of "quadratic Beziers per wavelength" and when left unset a sensible default is used.

type SinusoidFiguration

type SinusoidFiguration struct {
	Sinusoid kirv.Sinusoid
	ExpDecay kirv.ExpDecay
	// The time value.
	T float64
}

SinusoidFiguration specifies the geometry of a wireframe sine wave figure.

type Sphere

type Sphere struct {
	depictioner.Figure

	SphereFiguration
}

A Sphere is a wireframe sphere figure.

Relative to its orientation frame the sphere is depicted by a number of circles which are perpendicular to and centered on the X, Y, and Z axes.

func NewSphere

func NewSphere(spec SphereFiguration) *Sphere

NewSphere constructs a new Sphere which is initially oriented with a standard frame.

func (*Sphere) Depict

func (fig *Sphere) Depict(p SpherePortion)

Depict the given portions/(parameter intervals) on the sphere, overwriting the previous depiction(s) if any.

type SphereFiguration

type SphereFiguration struct {
	// The signed lengths added to the circles' radiuses for the circles
	// perpendicular to the X, Y, and Z-axes respectively.
	//
	// Using non-zero values for these can create gaps that prevent issues with
	// the otherwise overlapping curves.
	DX, DY, DZ float64

	// The number of circles perpendicular to the X, Y, and Z-axes respectively.
	NX, NY, NZ int

	// The spacing method for the circles perpendicular to the X, Y, and Z-axes
	// respectively.
	//
	// By default the circles of (that is, perpendicular to) a particular axis
	// are spaced such that their planes, when used to cut into arcs a great
	// circle on the sphere which is parallel to the axis, generate arcs that
	// subtend equal angles at the origin.
	//
	// The alternate spacing method, selected by setting the respective flag to
	// true, simply spaces them an equal perpendicular distance apart.
	SX, SY, SZ bool

	// The radius of the sphere.
	R float64
}

SphereFiguration specifies the geometry of a wireframe sphere figure.

type SpherePortion

type SpherePortion struct {
	X []mech.Portion // Portions of each of the circles perpendicular to the X-axis.
	Y []mech.Portion // Portions of each of the circles perpendicular to the Y-axis.
	Z []mech.Portion // Portions of each of the circles perpendicular to the Z-axis.
}

A SpherePortion specifies which parts of a sphere's wireframe to show.

type StandingWave

type StandingWave struct {
	depictioner.Figure

	StandingWaveFiguration
}

StandingWave is a wireframe sinusoidal standing wave figure.

Relative to its orientation frame the curve is in the Z=0 plane.

func NewStandingWave

func NewStandingWave(spec StandingWaveFiguration) *StandingWave

NewStandingWave constructs a new StandingWave which is initially oriented with a standard frame.

func (*StandingWave) Depict

func (fig *StandingWave) Depict(p StandingWavePortion)

Depict the given portions/(parameter intervals) on the standing wave, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are distance.

The portions' quality has units of "quadratic Beziers per wavelength" and when left unset a sensible default is used.

type StandingWaveFiguration

type StandingWaveFiguration struct {
	Standing kirv.Standing
	ExpDecay kirv.ExpDecay
	// The time value.
	T float64

	// Put some distance between the two constituent right/left moving wave
	// depictions and the main standing wave with a non-zero offset.
	RightwardsZOffset, LeftwardsZOffset float64
}

StandingWaveFiguration specifies the geometry of a wireframe sinusoidal standing wave figure.

type StandingWavePortion

type StandingWavePortion struct {
	Standing   []mech.Portion
	Rightwards []mech.Portion
	Leftwards  []mech.Portion
}

StandingWavePortion specifies which parts of a standing wave's wireframe to show along with the two sinusoids that combine to form the standing wave.

type Terdragon

type Terdragon struct {
	*PolyLine
}

A Terdragon is a wireframe figure that depicts a Heighway terdragon curve.

func NewTerdragon

func NewTerdragon(spec heighway.TerdragonPlotSpec) Terdragon

NewTerdragon constructs a new Terdragon curve which is initially oriented with a standard frame.

type TimeDepArchimedean

type TimeDepArchimedean struct {
	depictioner.Figure

	kinem.Archimedean
}

TimeDepArchimedean is a wireframe Archimedean spiral figure.

Relative to its orientation frame the spiral is in the Z=0 plane and is centered on the origin.

func NewTimeDepArchimedean

func NewTimeDepArchimedean(spec kinem.Archimedean) *TimeDepArchimedean

NewTimeDepArchimedean constructs a new TimeDepArchimedean which is initially oriented with a standard frame.

func (*TimeDepArchimedean) Depict

func (fig *TimeDepArchimedean) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the Archimedean spiral, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are time.

The portions' quality has units of "quadratic Beziers per revolution" and when left unset a sensible default is used.

type TimeDepProjectile

type TimeDepProjectile struct {
	depictioner.Figure

	kinem.Projectile
}

TimeDepProjectile is a wireframe parabola figure.

Relative to its orientation frame the projectile is in the Z=0 plane and intersects the origin at which point it has the given velocity.

func NewTimeDepProjectile

func NewTimeDepProjectile(spec kinem.Projectile) *TimeDepProjectile

NewTimeDepProjectile constructs a new Projectile which is initially oriented with a standard frame.

func (*TimeDepProjectile) Depict

func (fig *TimeDepProjectile) Depict(vp ...mech.Portion)

Depict the given portions/(parameter intervals) on the projectile, overwriting the previous depiction(s) if any.

The given portions' intervals shall not overlap with each other and their units are time.

The portions' quality has units of "quadratic Beziers per unit time" and when left unset a sensible default is used.

Directories

Path Synopsis
Package colour contains some colour types.
Package colour contains some colour types.
lch
Package lch contains the 148 CSS4 colour names as LCh type colours.
Package lch contains the 148 CSS4 colour names as LCh type colours.
lch/internal
Package main generates the 148 CSS4 named colour LCh type variable declarations in the lch package.
Package main generates the 148 CSS4 named colour LCh type variable declarations in the lch package.
rgb
Package rgb contains the 148 CSS4 colour names as RGB type colours as well as some other colours commonly used by Mechane.
Package rgb contains the 148 CSS4 colour names as RGB type colours as well as some other colours commonly used by Mechane.
compgeom
hilbert
Package hilbert facilitates sorting 2D points along a single space-filling Hilbert curve.
Package hilbert facilitates sorting 2D points along a single space-filling Hilbert curve.
hilbert/hilbert3d
Package hilbert facilitates sorting 3D points along a single space-filling Hilbert curve.
Package hilbert facilitates sorting 3D points along a single space-filling Hilbert curve.
peano
Package peano produces the vertices of a space-filling Peano curve.
Package peano produces the vertices of a space-filling Peano curve.
sierpinski
Package sierpinski produces the vertices of a space-filling Sierpinski curve.
Package sierpinski produces the vertices of a space-filling Sierpinski curve.

Jump to

Keyboard shortcuts

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