overview
本文回答:vjcad 的几何工具按"基础类型 → 计算 → 实体级算法"分层:①
Point2D / BoundingBox / ObservablePoint2D;②distance / getAngleBetweenPoints / getMidPoint / polarToCartesian / GeometryCalculator.{LineToLine, ArcToArc, ...};③ 实体级offset / trim / extend / break / transform;以及SpatialIndex、中心线、云线、智能块等智能工具。
一、按子主题挑
| 想做的 | 子主题 |
|---|---|
Point2D / BoundingBox / ObservablePoint2D |
point-bounds |
| 距离 / 角度 / 中点 / 极坐标 | distance-angle |
| 求交点(直线 / 圆 / 弧 / 多段线 / 填充) | intersection |
| Offset / Trim / Extend | offset-trim-extend |
| 打断 / 几何变换(不带实体的纯算法) / 边界框合并 | break-transform |
| 空间索引(Quadtree) | spatial-index |
| 中心线 / 云线 / 智能块 | smart-tools |
二、心智模型
┌──────────────────────────────┐
│ 基础类型 │
│ Point2D / BoundingBox / │
│ ObservablePoint2D │
└──────────────────────────────┘
│
▼
┌──────────────────────────────┐
│ 纯计算函数 │
│ distance / getAngleBetweenPoints│
│ getMidPoint / polarToCartesian │
│ GeometryCalculator (100+ 求交点) │
│ calculatePolygonArea / ... │
└──────────────────────────────┘
│
▼
┌──────────────────────────────┐
│ 作用于实体的算法 │
│ offset/trim/extend/break/ │
│ transform │
└──────────────────────────────┘
│
▼
┌──────────────────────────────┐
│ 智能工具 / 空间索引 │
│ SpatialIndex / centerline / │
│ revcloud / smartblock │
└──────────────────────────────┘
MCP 参考:vjcad/doc/geometry/index.md、vjcad/doc/geometry/calculations.md、vjcad/doc/geometry/point2d.md、vjcad/doc/geometry/bounding-box.md。
三、最常用一行 API
import { Point2D, distance, getAngleBetweenPoints, getMidPoint } from 'vjcad';
distance(new Point2D(0, 0), new Point2D(100, 100)); // 141.42...
getAngleBetweenPoints(new Point2D(0, 0), new Point2D(100, 100)); // 0.785... (弧度)
getMidPoint(new Point2D(0, 0), new Point2D(100, 100)); // Point2D(50, 50)
参考(官方文档 MCP)
- 文档:
vjcad/doc/geometry/index.md、calculations.md、point2d.md、bounding-box.md、intersection、area.md、centerline.md、revcloud.md、spline.md、boundary.md - 示例:
vjcad/example/geometry/01distance.js~20smartblock.js