UNPKG

x5-geometry

Version:

Geometry and word processing utilities for XNet

35 lines (34 loc) 1.76 kB
import { Point, Triangle } from './types'; /** * Tests if a point is inside a hexagon and returns the subdivision indices. * @param point - The point to test * @param hexVertices - Six vertices of the hex in right-hand rule order * @returns List of indices (e.g., [0, 1, 7, 31]) if inside, false if outside */ export declare function getHexSubdivisionIndices(point: Point, hexVertices: Point[]): number[] | false; export declare function hexIndexToIndexArray(hexIndex: number): number[]; export declare function hexIndexToVertices(hexIndex: number, hexVertices: Point[]): Point[]; export declare function reorderVerticies(hexVertices: Point[]): Point[]; /** * Subdivides a hexagon into 6 triangles by connecting the centroid to each vertex. * @param hexVertices - Six vertices in right-hand rule order. * @returns Object containing vertices and triangles */ export declare function subdivideHexToTriangles(hexVertices: Point[]): Triangle; /** * Subdivides a triangle into 4 smaller triangles. * @param triangleVertices - Three vertices of the triangle. * @returns Object containing vertices and triangles */ export declare function subdivideTriangle(triangleVertices: Point[]): Triangle; /** * Determines if a point is inside a triangle * @param point - The point to test * @param v1 - First vertex of the triangle * @param v2 - Second vertex of the triangle * @param v3 - Third vertex of the triangle * @param includeBoundary - Whether to include points on the boundary * @returns True if the point is inside the triangle, false otherwise */ export declare function isPointInsideTriangle(point: Point, v1: Point, v2: Point, v3: Point, includeBoundary?: boolean): boolean; export declare function sign(p1: Point, p2: Point, p3: Point): number;