constructor(x?: number, y?: number, r?: number)
View sourceCreates a circular bound with a center and radius.
Class
Represents a circular 2D bounds value for circle-shaped regions.
Use BoundingCircle as a standalone geometry value when an API
needs a circle-shaped region.
Use intersectCircle or intersectAABB2DvsCircle to test
overlap with another geometry value.
BoundingCircle#translate changes the current center in
place. The static translation helper can write a center into a supplied
output value, while BoundingCircle.copy copies the center and
radius. Serialization stores only the persisted geometry; the runtime type
discriminator is supplied by construction and is not serialized.
import { BoundingCircle, intersectCircle } from '@wimaengine/geometry'
const region = new BoundingCircle(10, 20, 5)
region.translate(2, -1)
const copy = BoundingCircle.copy(region)
console.log(intersectCircle(region, copy)) // trueconstructor(x?: number, y?: number, r?: number)Creates a circular bound with a center and radius.
Bound discriminator for circular geometry.
Default: BoundType.Circle
Circle radius.
Default: 0
Circle center.
translate(x: number, y: number): voidTranslates this circle’s center in place.
The radius and type discriminator are unchanged. This instance method
returns no value; use BoundingCircle.translate when a returned
output value is preferred.
copy(bound: BoundingCircle): voidCopies another circle’s center and radius into this instance.
The type discriminator is left unchanged. This instance method returns no
value; use BoundingCircle.copy when a returned output value is
preferred.
translate(bound: BoundingCircle, x: number, y: number, out?: BoundingCircle): BoundingCircleWrites a translated center into an output circle.
Only the output position is changed; the source radius and type are not
copied. Pass an existing output to update it in place, or omit out to
receive a new BoundingCircle with the translated center.
copy(bound: BoundingCircle, out?: BoundingCircle): BoundingCircleCopies a circle’s center and radius to an output circle.
The destination’s type discriminator is preserved. When out is omitted,
a new circular bound is created and returned.
serialize(value: BoundingCircle): BoundingCircleSerialConverts a circle to its serializable radius and position.
The returned object contains r and the serialized pos; it does not
contain the type discriminator.
deserialize(value: BoundingCircleSerial, out?: BoundingCircle): BoundingCircleRestores a circle from serialized radius and position data.
When out is supplied, its radius and position are updated in place and
its type discriminator is preserved. Otherwise a new circle is returned.
validateSerial(value: unknown): value is BoundingCircleSerialChecks whether a value has the serialized circle shape.
Validation requires a non-null object with numeric r and valid vector
data in pos. It does not require or validate the type discriminator,
and it does not enforce a radius range or finiteness.