Documentation
¶
Overview ¶
Package csgpoly holds the rules the outline of a CSG polygon must meet. Package pkg/world3d/csg applies them when it builds a polygon and package pkg/sceneformat when it validates a scene before anything is built; sceneformat cannot import csg (csg imports render3d, which imports sceneformat), so both call this one implementation and cannot drift apart.
Index ¶
Constants ¶
const ( // MaxPoints is the most points an outline may have. MaxPoints = 2048 // AxisTolerance is how far from the Y axis a spin outline's X may be and still count as on it. AxisTolerance = 1e-7 )
Variables ¶
This section is empty.
Functions ¶
func Normalize ¶
Normalize checks that in is a simple polygon: between 3 and MaxPoints finite points, at least 3 of them distinct, with non-zero area and no edge crossing or touching another. It returns the points with consecutive duplicates (and a closing point equal to the first) dropped, in counter-clockwise order.
Types ¶
type Error ¶
type Error struct {
// Index is the input index of the point that breaks the rule, or -1 when the rule is about the outline as a whole.
Index int
// TooComplex is true when the outline has more than MaxPoints points, a complexity limit rather than invalid input.
TooComplex bool
// Reason describes the broken rule, such as "polygon has zero area".
Reason string
}
Error is a rule an outline breaks.