Circle
geometry/circle.ts:27 Implements Shape
Defines a circle as a pure shape: it is described entirely by its radius
and has no position of its own. Where a circle "is" in the world is the
responsibility of whatever owns it (e.g. a transform / WorldObject
position).
Consequently, geometric queries operate in the circle's local space, where
the circle is centered on the origin 0,0. Callers map world coordinates
into that space (and supply the relative offset between two shapes) before
calling.
A negative radius is clamped to zero for containment and intersection
queries, so a degenerate circle reports no overlaps beyond its own center
point rather than producing inverted-radius nonsense.
Circle implements Shape: alongside the circle-idiomatic
Circle.diameter, Circle.circumference, and
Circle.area getters it exposes the uniform Shape.getArea,
Shape.getPerimeter, and Shape.intersects surface that lets
collision code treat any shape the same way.
Constructors
Properties
Accessors
area: number The area enclosed by the circle (πr²). A negative radius is clamped to
zero — see Circle.diameter.
circumference: number The distance around the circle (2πr). A negative radius is clamped to
zero — see Circle.diameter.
diameter: number The distance across the circle through its center (radius * 2). A
negative radius is clamped to zero, matching the containment and
intersection queries, so a degenerate circle never reports a negative
measurement (including through the polymorphic Shape.getPerimeter).
Methods
containsPoint(point: PointPrimitive): boolean Determines whether a point lies inside this circle. The point is expressed in the circle's local space (relative to its center). A point exactly on the edge is treated as contained.
Parameters
-
pointPointPrimitive
Returns
boolean getArea(): number The Shape contract's area accessor — equivalent to the Circle.area getter, in method form so a circle reads the same as any other shape.
Returns
number getPerimeter(): number The Shape contract's perimeter accessor — equivalent to the Circle.circumference getter.
Returns
number intersects(other: Shape, offset: PointPrimitive): boolean Determines whether this circle overlaps any other Shape — another circle, a Rectangle, or a Polygon. Shapes that touch count as intersecting. For the circle-vs-circle case prefer the typed Circle.intersectsCircle; this method is the polymorphic entry point used when the other shape's type isn't known statically.
Parameters
-
otherShape -
offsetPointPrimitive
Returns
boolean intersectsCircle(other: Circle, offset: PointPrimitive): boolean Determines whether this circle overlaps another circle. Circles that touch at exactly one point are considered intersecting.
Parameters
-
otherCircle -
offsetPointPrimitive
Returns
boolean toString(): string Returns a string representation of this circle.
Returns
string