UNPKG

@dominicstop/utils

Version:

Yet another event emitter written in typescript.

77 lines 2.73 kB
import { Angle } from "./Angle"; import { BoxedShape } from "./interfaces/BoxedShape"; import { Point } from "./Point"; import { Rect } from "./Rect"; import { UniformScaleConfig } from "./Scalelable"; export type BoxedCircleValue = { center: Point; radius: number; }; export type BoxedCircleInit = { mode: 'relativeToOrigin'; origin: Point; radius: number; } | (BoxedCircleValue & { mode: 'relativeToCenter'; }); export declare class BoxedCircle implements BoxedShape<BoxedCircleValue> { origin: Point; radius: number; epsilon: number; constructor(args: BoxedCircleInit); get asValue(): BoxedCircleValue; get diameter(): number; get center(): Point; set center(newCenter: Point); get boundingBox(): Rect; clone(): BoxedCircle; pointAlongPath(angle: Angle): Point; isPointInside(point: Point): boolean; computeDistanceToOther(other: BoxedCircle): number; isEdgeToEdgeWithOther(other: this): boolean; isCollidingWithOther(other: this): boolean; applyUniformScaleByFactor(args: UniformScaleConfig): void; scaledUniformallyByFactor(args: UniformScaleConfig): this; static initFromValue(args: BoxedCircleValue): BoxedCircle; static rotateCirclesRelativeToPoint(args: { circles: Array<BoxedCircle>; centerPoint: Point; rotationAmount: Angle; }): void; static recenterCirclesRelativeToPoint(args: { circles: Array<BoxedCircle>; centerPoint: Point; }): void; /** * the distance between the circle's centers minus * the sum of their radii: `d < (r1 + r2)` */ static computeDistanceBetweenTwoCricles(circleA: BoxedCircle, circleB: BoxedCircle): number; /** * Collision detection for two circles: * returns true if two circles are colliding * * * Two circles are overlapping if the distance between their centers is less than * the sum of their radii: `d < (r1 + r2)` */ static checkCollisionBetweenTwoCircles(circleA: BoxedCircle, circleB: BoxedCircle, epsilon?: number): boolean; /** * Two circles are "edge-to-edge" (touching) if: `d=r1+r2` */ static checkIfTwoCirclesAreEdgeToEdge(circleA: BoxedCircle, circleB: BoxedCircle, epsilon?: number): boolean; /** * * Collision Detection (Circle-Box) * * * A circle (x, y, r) is inside a box defined by minimum (xmin, ymin) * and maximum (xmax, ymax) coordinates if: * ``` * x - r >= xmin * x + r <= xmax * y - r >= ymin * y + r <= ymax * ``` */ static checkIfCircleIsInsideRect(circle: BoxedCircle, rect: Rect, epsilon?: number): boolean; } //# sourceMappingURL=BoxedCircle.d.ts.map