import { Edge } from "./edge"; import { Vector } from "./vector"; import { Vertex } from "./vertex"; /** * A polygon in two dimensional space. */ export declare class Polygon { private _vertices; private _edges; private _clockwise; /** * A copy of the collection of vertices that constitute the boundary of the polygon. */ get vertices(): Vertex[]; /** * A copy of the collection of edges that constitute the boundary of the polygon. */ get edges(): Edge[]; /** * True if the polygon edges are oriented in a clockwise direction, false otherwise. */ get clockwise(): boolean; /** * The anchoring point of the polygon; the point from which all transformative operations will be completed in * reference to. The anchor point will be the centroid of the polygon by default. */ anchor: Vertex; /** * Constructs the polygon edges and orientation from an array of vertices expressed as polygons. * @param vertices */ constructor(vertices: Vertex[]); private static calculateEdges; private static calculateAngularSum; /** * Constructs a new Polygon object with the same properties of this one. * @returns A new Polygon object. */ copy(): Polygon; /** * Creates a user-friendly formatted string for the polygon. Vertices are contained in parenthesis, separated by * commas and formatted as user-friendly vertices. * @returns A formatted string representing the polygon. */ toString(): string; /** * Calculates all distinct intersecting points between the edges of this polygon and another edge. * @param edge The edge to intersect with the edges of this polygon. * @returns All distinct intersecting points in an array. */ intersectEdge(edge: Edge): Vertex[]; /** * Translates the polygon by some amount along both axes. * @param x The translation along the x-axis, 0 by default. * @param y The translation along the y-axis, 0 by default. * @returns The polygon after translation. */ translate(x?: number, y?: number): Polygon; /** * Translates a polygon by some amount along both axes. * @param polygon The polygon to translate. * @param x The translation along the x-axis, 0 by default. * @param y The translation along the y-axis, 0 by default. * @returns The new translated polygon. */ static translate(polygon: Polygon, x?: number, y?: number): Polygon; /** * Scales the distance between the vertices of the polygon and some reference point. * @param factor The scaling factor. * @param reference The point from which to scale the polygon vertices, the polygon anchor point by default. * @returns The polygon after scaling. */ scale(factor: number, reference?: Vertex): Polygon; /** * Scales the distance between the vertices of a polygon and some control point. * @param polygon The polygon to scale. * @param factor The scaling factor. * @param reference The point from which to scale the polygon vertices, the polygon anchor point by default. * @returns A new scaled polygon. */ static scale(polygon: Polygon, factor: number, reference?: Vertex): Polygon; /** * Rotates the polygon around some reference point. * @param angle The amount to rotate the polygon by in radians. * @param reference The point from which to rotate the polygon, the polygon anchor point by default. * @returns The polygon after rotation. */ rotate(angle: number, reference?: Vertex): Polygon; /** * Rotates a polygon around some reference point. * @param polygon The polygon to rotate * @param angle The amount to rotate the polygon by in radians. * @param reference The point from which to rotate the polygon, the polygon anchor point by default. * @returns A new rotated polygon. */ static rotate(polygon: Polygon, angle: number, reference?: Vertex): Polygon; /** * Reflects the polygon along an axis projected from some reference point. * @param axis The axis along which to reflect the polygon. * @param reference The point from which to project the axis for reflection, the polygon anchor point by default. * @returns The polygon after reflection. */ reflect(axis: Vector, reference?: Vertex): Polygon; /** * Reflects a polygon along an axis projected from some reference point. * @param polygon The polygon to reflect. * @param axis The axis along which to reflect the polygon. * @param reference The point from which to project the axis for reflection, the polygon anchor point by default. * @returns A new reflected polygon. */ static reflect(polygon: Polygon, axis: Vector, reference?: Vertex): Polygon; private transform; /** * Splits the existing polygon into one or more sub-polygons based on it's self-intersecting edges. * @returns An array of polygons derived from this one. */ overlapSplit(): Polygon[]; /** * Offsets the edges of the polygon orthogonally by some quantity. Depending on the structure of the polygon and the offset * amount it is entirely for the polygon to be separated into two or more distinct polygons. * @param quantity The amount to offset the polygon edges. A positive value will shift the polygon edges away from the * centre, while a negative value will shift the polygon edges toward the centre. * @returns An array of offset polygon segments. */ offset(quantity: number): Polygon[]; } export declare function poly(vertices: Vertex[]): Polygon;