强大,在于简单。这是一个简单的尺规作图引擎,可用于几何分析、课件制作、计算坐标等。
尺规作图中需要四种基本的数据结构类型。
Number
- 数值类型,表示坐标值、距离或索引Point
- 表示一个点,其中x
和y
属性分别表示横坐标和纵坐标Line
- 表示一条直线,给出过该直线的两个点 (x1
,y1
) 和 (x2
,y2
),以及dx
=x2
-x1
和dy
=y2
-y1
Arc
- 表示一个圆的圆弧,给出圆心坐标 (x
,y
)以及半径r
原子命令从传统的尺规作图中提取,主要包括定点、连线、作弧。基本命令见下表
Command | Format | Description |
---|---|---|
define_point | pd x y p1 |
定义一个点 p1,点的坐标为 (x, y) |
define_line | ld p1 p2 l1 |
定义一条直线 l1 过点 p1 和点 p2 |
define_distance | dd p1 p2 d1 |
定义一段距离 d1 表示点 p1 和点 p2 之间的距离 |
define_arc | ad p1 d1 a1 |
定义圆弧 a1 以 p1 为圆心,d1 为半径 |
define_arc_2 | ad2 p1 p2 a1 |
定义圆弧 a1 以 p1 为圆心,以 p1 到 p2 之间的距离为半径 |
define_arc_3 | ad3 p1 p2 p3 a1 |
定义圆弧 a1 以 p1 为圆心,以 p2 到 p3 之间的距离为半径 |
intersect_arc_arc | aai a1 a2 index p1 |
计算圆弧 a1 和 a2 的交点 p1,交点有两个的时候,index 来选择交点(0 或 1) |
intersect_line_arc | lai l1 a1 index p1 |
计算直线 l1 和圆弧 a1 的交点 p1,交点有两个的时候,index 来选择交点(0 或 1) |
intersect_line_line | lli l1 l2 p1 |
计算直线 l1 和圆弧 l2 的交点 p1 |
除此之外,还有内置的拓展命令
Command | Format | Description |
---|---|---|
bisector | bp p1 p2 m1 |
定义点 p1 和点 p2 的中点 m1 |
perpendicular_bisector | pbl p1 p2 l1 |
定义端点为 p1 和 p2 的线段的垂直平分线 |
perpendicular_line | pl l1 p1 l2 |
过点 p1 作直线 l1 的垂线 l2 |