Skip to content

HalfEdge

Under Construction

This documentation is auto-generated, and is a work in progress. Please see the source code at https://github.com/phetsims/kite/blob/main/js/ops/HalfEdge.ts for the most up-to-date information.

Overview

Represents a single direction/side of an Edge. There are two half-edges for each edge, representing each direction. The half-edge also stores face information for the face that would be to the left of the direction of travel.

@author Jonathan Olson <jonathan.olson@colorado.edu>

Class HalfEdge

import { HalfEdge } from 'scenerystack/kite';

Instance Methods

serialize() : SerializedHalfEdge

Returns an object form that can be turned back into a segment with the corresponding deserialize method.

dispose()

Removes references (so it can allow other objects to be GC'ed or pooled), and frees itself to the pool so it can be reused.

getNext( filter? : ( edge: Edge ) => boolean ) : HalfEdge

Returns the next half-edge, walking around counter-clockwise as possible. Assumes edges have been sorted.

@param [filter] - If it returns false, the edge will be skipped, and not returned by getNext

getEndTangent() : Vector2

Returns the tangent of the edge at the end vertex (in the direction away from the vertex).

getEndCurvature() : number

Returns the curvature of the edge at the end vertex.

getReversed() : HalfEdge

Returns the opposite half-edge for the same edge.

getDirectionalSegment() : Segment

Returns a segment that starts at our startVertex and ends at our endVertex (may be reversed to accomplish that).

freeToPool()

Instance Properties

id : number

(readonly)

edge : Edge

Set in initialize, will be null when disposed (in pool)

face : Face | null

isReversed

signedAreaFragment

startVertex : Vertex | null

endVertex : Vertex | null

sortVector : Vector2

Used for vertex sorting in Vertex.js. X is angle of end tangent (shifted), Y is curvature at end. See Vertex edge sort for more information.

data : IntentionalAny

Available for arbitrary client usage. -- Keep JSONable

Static Properties

pool : Pool

Type SerializedHalfEdge

import type { SerializedHalfEdge } from 'scenerystack/kite';
  • type: "HalfEdge"
  • id: number
  • edge: number
  • face: number | null
  • isReversed: boolean
  • signedAreaFragment: number
  • startVertex: number | null
  • endVertex: number | null
  • sortVector: Vector2StateObject
  • data: IntentionalAny

Source Code

See the source for HalfEdge.ts in the kite repository.