[Go to site: main page, start]

Class PolygonTreeNode

The node of a foundry.data.PolygonTree.

Hierarchy (View Summary)

Index

Constructors

Accessors

  • get area(): number

    The area of this node.

    Returns number

  • get bounds(): Rectangle

    The bounds of the polygon, or the combined bounds of all children in case of the root node.

    The value of this property must not be mutated.

    Returns Rectangle

  • get children(): readonly PolygonTreeNode[]

    The children of this node.

    The value of this property must not be mutated.

    Returns readonly PolygonTreeNode[]

  • get depth(): number

    The depth of this node. The depth of the root node is 0.

    Returns number

  • get isEmpty(): boolean

    Is the (sub)tree empty?

    Returns boolean

  • get isHole(): boolean

    Is this a hole? The root node is a hole.

    Returns boolean

  • get path(): readonly Point[] | null

    The path of the polygon ([{x: x0, y: y0}, {x: x1, y: y1}, ...]). They are null in case of the root node.

    The value of this property must not be mutated.

    Returns readonly Point[] | null

  • get points(): readonly number[] | null

    The points of the polygon ([x0, y0, x1, y1, ...]). They are null in case of the root node.

    The value of this property must not be mutated.

    Returns readonly number[] | null

  • get polygon(): Polygon | null

    The polygon of this node. It is null in case of the root node.

    The value of this property must not be mutated.

    Returns Polygon | null

Methods

  • Iterate over recursively over the children in depth-first order.

    Returns Generator<PolygonTreeNode, any, any>

  • Find a point inside this polygon tree that is closest to the given reference point.

    Parameters

    • point: Point

      The reference point.

    Returns Point

    The closest point to the reference point in the polygon tree.

  • Find the node in this (sub)tree that contains the given point.

    Parameters

    Returns PolygonTreeNode | null

    The (sub)node that contains the point, if any. Cannot return null for PolygonTree; instead the root node (the tree itself) is returned.

  • Test circle containment/intersection with this (sub)tree.

    Parameters

    • center: Point

      The center point of the circle.

    • radius: number

      The radius of the circle.

    Returns -1 | 0 | 1

    • -1: the circle is in the exterior and does not intersect the boundary. - 0: the circle is intersects the boundary. - 1: the circle is in the interior and does not intersect the boundary.
  • Test whether given point is contained within this (sub)tree. If distance is is nonzero, true is returned if and only if the signed distance from the point to the boundary of the (sub)tree is less than or equal to distance. The signed distance is positive for points in the exterior of the (sub)tree and negative for points within the interior of the (sub)tree.

    Parameters

    • point: Point

      The point.

    • Optionaldistance: number = 0

      The tolerance of the containment test.

    Returns boolean

    polygonTree.testPoint({x, y});
    
    polygonTree.testPoint({x, y}, r);
    
    polygonTree.testPoint({x, y}, -r);