Documentation
¶
Overview ¶
Package functiongrapher provides a way to convert an arbitrary function expression into a list of quadratic bezier curve.
Index ¶
- func BoundingBox(curves []BezierCurve) repere.RepereBounds
- func NewSequenceGraph(fn expression.FunctionDefinition) []repere.Coord
- func OrdinateAt(curves []BezierCurve, x float64) (float64, error)
- func PointsFromExpression(fn expression.FunctionExpr, grid []int) (bounds repere.RepereBounds, fxs []int, dfxs []float64)
- type BezierCurve
- type FunctionDecoration
- type FunctionGraph
- type SequenceGraph
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 ¶
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 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