functiongrapher

package
v0.0.0-...-a5229ac Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package functiongrapher provides a way to convert an arbitrary function expression into a list of quadratic bezier curve.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoundingBox

func BoundingBox(curves []BezierCurve) repere.RepereBounds

BoundingBox compute the bounds enclosing the given segments, always adding the origin and some padding.

func NewSequenceGraph

func NewSequenceGraph(fn expression.FunctionDefinition) []repere.Coord

func OrdinateAt

func OrdinateAt(curves []BezierCurve, x float64) (float64, error)

OrdinateAt computes the Y position for the point [x] belong to the given [curves] It returns an error if [x] does not belong to [curves]

func PointsFromExpression

func PointsFromExpression(fn expression.FunctionExpr, grid []int) (bounds repere.RepereBounds, fxs []int, dfxs []float64)

PointsFromExpression returns the f(x) and f'(x) values for x in the grid

Types

type BezierCurve

type BezierCurve struct {
	P0, P1, P2 repere.Coord
}

BezierCurve is a quadratic Bezier curve with the additional invariant that P0.X <= P2.X

func HorizontalAxis

func HorizontalAxis(from, to, y float64) []BezierCurve

HorizontalAxis is a convinience function returning the curve defined by an horizontal axis at `y`, between x = `from` and x = `to`

func NewAreaBetween

func NewAreaBetween(top, bottom []BezierCurve, left, right float64) []BezierCurve

NewAreaBetween returns a closed path delimiting an area between two curves `top` and `bottom` restricted in [`left`, `right`], which must be included in the two curves.

func NewFunctionGraph

func NewFunctionGraph(fn expression.FunctionDefinition) []BezierCurve

func NewFunctionGraphFromVariations

func NewFunctionGraphFromVariations(xs []float64, ys []float64) []BezierCurve

NewFunctionGraphFromVariations builds one possible representation for the given variations

type FunctionDecoration

type FunctionDecoration struct {
	Label string
	Color string
}

type FunctionGraph

type FunctionGraph struct {
	Decoration FunctionDecoration
	Segments   []BezierCurve
}

type SequenceGraph

type SequenceGraph struct {
	Decoration FunctionDecoration
	Points     []repere.Coord
}

SequenceGraph is a discrete version of FunctionGraph

Jump to

Keyboard shortcuts

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