Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FitSpline ¶
FitSpline computes the control points of a cubic bezier curve that fits a polygonal path. The input path points must be ordered from start to end.
func MakeSpline ¶ added in v0.9.0
func MakeSpline(a, b P) ctrlp
MakeSpline computes control points of a cubic bezier from a to b so that it gently curves in the direction of the slope.
Types ¶
type P ¶
type P struct {
X, Y float64
}
P represents a point on the plane
type Polygon ¶
type Polygon struct {
Points []P // counterclockwise list of points
// contains filtered or unexported fields
}
Polygon represents a polygon on the plane
func MergeRects ¶
type Rect ¶
type Rect struct {
TL P // top-left vertex of the rectangle
BR P // bottom-right vertex of the rectangle
}
Rect represents a rectangle
type Tri ¶
Tri represents a triangle
func Triangulate ¶
Triangulate returns a list of triangles resulting from the triangulation of the polygon obtained by merging the rectangles (the rectangles aren't actually merged). Since the polygon's internal angles are all fractions of π, the triangulation is special-cased to run in O(n). Note that the polygon is y-monotone but isn't also strictly y-monotone, therefore the left and right vertex chains can't be considered sorted. For each output triangle, the segment (A,B) is a diagonal of the polygon.