@technobuddha/library
Version:
A large library of useful functions
24 lines (23 loc) • 768 B
TypeScript
import { type Polygon } from './@types/geometry.ts';
import { type OriginOptions } from './angle.ts';
/**
* Generates a regular polygon.
* @param sides - The number of sides of the polygon (must be at least 3).
* @param radius - The radius of the polygon (distance from the origin to each vertex).
* @param options - see {@link OriginOptions}
* @returns A regular polygon.
* @throws `TypeError` If the number of sides is less than 3.
* @example
* ```typescript
* regularPolygon(4, 2);
* // [
* // { x: 2, y: 0 },
* // { x: 0, y: 2 },
* // { x: -2, y: 0 },
* // { x: 0, y: -2 }
* // ]
* ```
* @group Geometry
* @category Polygon
*/
export declare function regularPolygon(sides?: number, radius?: number, { origin }?: OriginOptions): Polygon;