bspline

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: Unlicense Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeKinematics

func ComputeKinematics(spline []Knot, scale uint) (v, a, j uint)

ComputeKinematics compute the absolute kinematic maximums of the clamped B-spline.

func InterpolatePoints

func InterpolatePoints(pts []bezier.Point) (knots []bezier.Point, err error)

InterpolatePoints takes a clamped cubic uniform b-spline and returns a similar spline that minimizes maximum speed, acceleration and jerk. The returned spline has a control point in each control point interval of the input spline. As a special case, a zero-length input B-spline is returned as is.

For example, the clamped uniform B-spline with n+4 control points,

P0P0P0 - P1 - P2 - P3 - … - P{n-1}P{n-1}P{n-1}

is turned into another clamped uniform B-spline n+5 control points

Q0Q0Q0 - Q1 - Q2 - Q3 - Q4 - … - Q{n}Q{n}Q{n}

where

Q0 = P0,
Q{n} = P{n-1}, and
Q{i} for i∈[1,n-1] is on the line segment P{i-1} - P{i}.

Types

type Attributes

type Attributes struct {
	Bounds   Bounds
	Duration uint
}

func Measure

func Measure(spline Curve) Attributes

type Bounds

type Bounds struct {
	Min, Max bezier.Point
}

Bounds is like image.Rectangle with its upper bound inclusive.

func (Bounds) Dx

func (b Bounds) Dx() int

func (Bounds) Dy

func (b Bounds) Dy() int

func (Bounds) Empty

func (b Bounds) Empty() bool

func (Bounds) In

func (b Bounds) In(b2 Bounds) bool

func (Bounds) Union

func (b Bounds) Union(b2 Bounds) Bounds

type Curve

type Curve = iter.Seq[Knot]

Curve is an iterator over the knots of a b-spline.

type Kinematics

type Kinematics struct {
	Velocity     bezier.Point
	Acceleration bezier.Point
	Jerk         bezier.Point
	// contains filtered or unexported fields
}

Kinematics track the derivative values of a B-Spline.

func (*Kinematics) Knot

func (k *Kinematics) Knot(t uint, ctrl bezier.Point, scale uint)

Knot shifts the spline one knot and updates the kinematics.

func (*Kinematics) Max

func (k *Kinematics) Max() (v, a, j uint)

type Knot

type Knot struct {
	Ctrl    bezier.Point
	T       uint
	Engrave bool
}

type Segment

type Segment struct {

	// Knots is a sliding window of knots.
	Knots [3]Knot
	// contains filtered or unexported fields
}

func (*Segment) Knot

func (s *Segment) Knot(k Knot) (bezier.Cubic, uint, bool)

Jump to

Keyboard shortcuts

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