xtorcga
Version:
Xtor Compute Geometry Algorithm Libary 计算几何算法库
44 lines (43 loc) • 1.31 kB
TypeScript
import { Vec3 } from "src/math/HVec3";
import Decimal from "decimal.js";
declare enum Side {
COPLANAR = 0,
FRONT = 1,
BACK = 2,
SPANNING = 3
}
export declare class Polygon {
w: Decimal;
normal: Vec3;
vertices: Vec3[];
constructor(vertices?: Vec3[]);
calcPlane(): this;
flip(): this;
/**
* @description : 判断点与当前多边形所在的平面的位置关系
* @param {Vec3} vertex
* @return {*}
* @example :
*/
classifyVertex(vertex: Vec3): Side.COPLANAR | Side.FRONT | Side.BACK;
/**
* @description : 判断另一个多边形与当前多边形的位置关系
* @param {Polygon} polygon
* @return {*}
* @example :
*/
classifySide(polygon: Polygon): Side;
/**
* @description : 切割多边形
* @param {Polygon} polygon
* @param {Polygon} coplanar_front
* @param {Polygon} coplanar_back
* @param {Polygon} front
* @param {Polygon} back
* @return {*}
* @example :
*/
splitPolygon(polygon: Polygon, coplanar_front?: Polygon[], coplanar_back?: Polygon[], front?: Polygon[], back?: Polygon[]): void;
clone(): Polygon;
}
export {};