Documentation ¶
Index ¶
- Constants
- func EdgeTwin(i int) int
- type DCEL
- func (dc *DCEL) Bounds() geom.Span
- func (dc *DCEL) ConnectVerts(a, b *Vertex, f *Face)
- func (dc *DCEL) Copy() *DCEL
- func (dc *DCEL) CorrectDirectionality(f *Face)
- func (dc *DCEL) CorrectDirectionalityAll()
- func (dc *DCEL) CorrectTwins()
- func (dc *DCEL) FullEdge(i int) (geom.FullEdge, error)
- func (dc *DCEL) FullEdges() ([]geom.FullEdge, [][2]*Face, error)
- func (dc *DCEL) Max(i int) (x float64)
- func (dc *DCEL) MaxX() float64
- func (dc *DCEL) MaxY() float64
- func (dc *DCEL) MaxZ() float64
- func (dc *DCEL) Min(i int) (x float64)
- func (dc *DCEL) MinX() float64
- func (dc *DCEL) MinY() float64
- func (dc *DCEL) MinZ() float64
- func (dc *DCEL) ScanFaces(f *Face) int
- func (dc *DCEL) String() string
- func (dc *DCEL) VerticesSorted(ds ...int) []int
- type Edge
- func (e *Edge) AllEdges() []*Edge
- func (e *Edge) At(i int) geom.Dimensional
- func (e *Edge) Bounds() geom.Span
- func (e *Edge) Compare(i interface{}) search.CompareResult
- func (e *Edge) Copy() *Edge
- func (e *Edge) D() int
- func (e *Edge) EdgeChain() []*Edge
- func (e *Edge) Eq(e2 geom.Spanning) bool
- func (e *Edge) FindSharedPoint(e2 *Edge, d int) (float64, error)
- func (e *Edge) Flip()
- func (e *Edge) FullEdge() (geom.FullEdge, error)
- func (e *Edge) High(d int) geom.Dimensional
- func (e *Edge) IsClockwise() (bool, error)
- func (e *Edge) Len() int
- func (e *Edge) Low(d int) geom.Dimensional
- func (e *Edge) Mid2D() (geom.Point, error)
- func (e *Edge) PointAlong(d int, pcnt float64) geom.D3
- func (e *Edge) PointAt(d int, v float64) (geom.Point, error)
- func (e *Edge) Set(i int, d geom.Dimensional) geom.Spanning
- func (e *Edge) SetNext(e2 *Edge)
- func (e *Edge) SetPrev(e2 *Edge)
- func (e *Edge) SetTwin(e2 *Edge)
- func (e *Edge) String() string
- func (e *Edge) Val(d int) float64
- func (e *Edge) X() float64
- func (e *Edge) Y() float64
- func (e *Edge) Z() float64
- type Face
- type Vertex
Constants ¶
const ( // OUTER_FACE is used to represent the infinite space // around the outer edge(s) of a DCEL. OUTER_FACE = 0 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DCEL ¶
type DCEL struct { Vertices []*Vertex HalfEdges []*Edge // The first value in a face is the outside component // of the face, the second value is the inside component Faces []*Face }
A DCEL is a structure representin arbitrary plane divisions and 3d polytopes. Its values are relatively self-explanatory but constructing it is significantly harder.
func New ¶
func New() *DCEL
New returns an empty DCEL with its inner fields initialized to empty slices, and a zeroth outside face.
func Random2DDCEL ¶
func Rect ¶
Rect is a wrapper around FourPoint to make a rectangle with top left position and dimensions.
func (*DCEL) ConnectVerts ¶
ConnectVerts takes two vertices and adds edges to the dcel containing them to connect the two vertices by a full edge. the added edges will be at dc.HalfEdges[len-1] and len-2. no face is added, and connectVerts assumes the provided face is the face in which the diagonal will land.
The job of creating new faces is delayed because if a series of ConnectVerts is called on the same face, calling code won't be able to easily tell which face the sequential diagonals land in.
This function doesn't cover enough cases to work.
func (*DCEL) CorrectDirectionality ¶
CorrectDirectionality (rather innefficently) ensures that a face has the right clockwise/ counter-clockwise orientation based on whether its chain is the inner or outer portion of a face.
func (*DCEL) CorrectDirectionalityAll ¶
func (dc *DCEL) CorrectDirectionalityAll()
This is probably how we actually want to do flipping, always.
func (*DCEL) CorrectTwins ¶
func (dc *DCEL) CorrectTwins()
CorrectTwins modifies the ordering on twins inside the DCEL such that dc.HalfEdges[i] is the twin of dc.HalfEdges[i+1] for all even i values.
func (*DCEL) Max ¶
Max functions iterate through vertices to find the maximum value along a given axis in the DCEL
func (*DCEL) Min ¶
Min functions iterate through vertices to find the maximum value along a given axis in the DCEL
func (*DCEL) VerticesSorted ¶
VerticesSorted returns a list indicating the sorted order of this dcel's vertices in dimensions ds. Example: to get points sorted by x, use with (0)
to get points sorted by y, breaking ties on lesser x, use with (1,0).
type Edge ¶
type Edge struct { // Origin is the vertex this edge starts at Origin *Vertex // Face is the index within Faces that this // edge wraps around Face *Face // Next and Prev are the edges following and // preceding this edge that also wrap around // Face Next *Edge Prev *Edge // Twin is the half edge who points to this // half-edge's origin, and respectively whose // origin this half-edge points to. Twin *Edge }
An Edge represents an edge within a DCEL, specifically a half edge, which maintains references to it's origin vertex, the face it bounds, the half edge sharing its space bounding its adjacent face, and the previous and following edges which bound its face.
func (*Edge) AllEdges ¶
AllEdges on an edge is equivalent to e.Origin.AllEdges, which actually calls this instead of the other way around because that involves less code duplciation.
func (*Edge) At ¶
func (e *Edge) At(i int) geom.Dimensional
At returns either e.Origin or e.Twin.Origin for 0 or 1
func (*Edge) Compare ¶
func (e *Edge) Compare(i interface{}) search.CompareResult
Compare allows Edge to satisfy search interfaces for placement in BSTs.
func (*Edge) FindSharedPoint ¶
FindSharedPoint returns some value, if one exists, in dimension d, that has a defined point on both e and e2. This function is deterministic. It does not return a -random- value, if multiple values are valid.
func (*Edge) Flip ¶
func (e *Edge) Flip()
Flip converts edge and all that share a face with edge from counterclockwise to clockwise or vice versa
func (*Edge) High ¶
func (e *Edge) High(d int) geom.Dimensional
High returns whichever point on e is higher in dimension d
func (*Edge) IsClockwise ¶
IsClockwise returns whether a given set of edges is clockwise or not. Method credit: lhf on stackOverflow https://math.stackexchange.com/questions/340830
func (*Edge) Low ¶
func (e *Edge) Low(d int) geom.Dimensional
Low returns whichever point on e is lower in dimension d
func (*Edge) PointAlong ¶
PointAlong returns the point some percent along e, increasing on dimension d. If percent <= 0, returns e.Low(d). if percent >= 1, returns e.High(d).
func (*Edge) PointAt ¶
PointAt returns the point at a given position on some d dimension along this edge. I.E. for d = 0, v = 5, if this edge was represented as y = mx + b, this would return y = m*5 + b.
type Face ¶
type Face struct {
Inner, Outer *Edge
}
A Face points to the edges on its inner and outer portions. Any given face may have either of these values be nil, but never both.
func (*Face) Bounds ¶
Bounds returns a Span calculated from every point on the Inner of this face because at time of writing we don't populate Outer
func (*Face) Contains ¶
Contains returns whether a point lies inside f. We cannot assume that f is convex, or anything besides some polygon. That leaves us with a rather complex form of PIP--
func (*Face) Encloses ¶
Encloses returns whether f completey enwraps f2 Doing this check legitimately would be costly and complex. We assume, right now, that we already -know- that either f encloses f2 or f2 encloses f. If this is true, if one of them has a point higher than the other, that one is the encloser.
func (*Face) VerticesSorted ¶
VerticesSorted returns this face's vertices sorted in dimensions ds. Example: to get points sorted by x, use with (0)
to get points sorted by y, breaking ties on lesser x, use with (1,0).
--This has different behavior than DCEL.VerticesSorted! it does not return indices but direct vertex pointers.
type Vertex ¶
A Vertex is a Point which knows its outEdge.
func PointToVertex ¶
PointToVertex converts a point into a vertex
func (*Vertex) AllEdges ¶
AllEdges iterates through the edges surrounding a vertex and returns them all.
func (*Vertex) EdgeToward ¶
EdgeToward returns the edge around this vertex which is pointing toward v2.
Directories ¶
Path | Synopsis |
---|---|
package off describes methods for interacting with OFF files and structures formatted as OFF files.
|
package off describes methods for interacting with OFF files and structures formatted as OFF files. |