Documentation
¶
Index ¶
Constants ¶
const ( Coplanar = PlaneComparison(iota) Before Behind Splits )
const SideEpsilon = 1e-5
SideEpsilon is the absolute world-space distance within which a point is considered to lie on a partition plane. Plane normals are unit length, so Normal.Dot(p)-d is a true distance and an absolute tolerance keeps the classification independent of a model's distance from the origin (a relative epsilon's dead zone grows with coordinate magnitude). Measured on mocap scenes, genuine interpenetrations are >= 1e-3 world units deep while numerical jitter stays below 1e-6, so 1e-5 separates the two cleanly.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Plane ¶
type Plane struct {
// Id of the face of the node this plane is associated with.
Id int
// Points contains the Face points in WorldSpace coordinates.
Points point.Points
// Barycenter contains the Barycenter of the Points (in WorldSpace
// coordinates).
Barycenter point.Point
// Normal is the normal vector that is perpendicular to the plane going
// through Points (in WorldSpace coordinates).
Normal point.Point
// Piece marks a plane produced by Split: a fragment of the face
// identified by Id rather than the whole face. The renderer projects a
// piece's own Points instead of the cached whole-face coordinates.
Piece bool
// NoSplit marks a plane whose polygon must never be cut (e.g. a text
// face, which paints its whole string from its points — each piece
// would repeat the text). Process routes a straddling NoSplit plane
// wholesale to its barycenter's side instead of splitting it.
NoSplit bool
}
Plane is the plane going through the Points of a face in the WorldSpace coordinate system.
func (Plane) CoplanarWith ¶
CoplanarWith returns true when this plane is in the same plane as the given plane.
func (Plane) ParallelWith ¶
ParallelWith returns true when this plane is parallel to the given plane. This means the planes have the same normal, but are in parallel planes.
func (Plane) Split ¶ added in v0.0.4
Split cuts target's polygon by the receiver's plane and returns the two pieces: front on the receiver's negative-normal side (the side the Front subtree holds, see Process) and back on the positive-normal side. Both pieces keep target's Id and Normal — they lie in the same plane and shade from the same face — and are marked as Piece so the renderer projects their own points instead of the cached whole-face coordinates.
ok is false when target does not actually straddle the plane within SideEpsilon or a piece would degenerate to fewer than three vertices; callers should then keep the whole target on a single side.
The cut walks the polygon ring once, so a concave polygon that crosses the plane more than twice comes back as two self-touching rings rather than several disjoint pieces. Faces in practice (pipe quads, sphere triangles) are convex, where a single cut yields exactly two pieces.
type PlaneComparison ¶
type PlaneComparison int
func Compare ¶
func Compare(l, r Plane) PlaneComparison
Compare classifies plane r against plane l: Coplanar when r lies in l's plane, Before when r is entirely on l's negative-normal side, Behind when entirely on the positive-normal side, and Splits when r has vertices on both sides (l's plane cuts r's polygon).