中望cad中求两条直线的中垂线交点的c++代码
时间: 2023-07-24 21:54:56 浏览: 156
以下是中望CAD中求两条直线的中垂线交点的 C++ 代码:
```c++
AcGePoint3d GetPerpendicularBisectorIntersection(const AcGePoint3d& p1, const AcGePoint3d& p2, const AcGePoint3d& p3, const AcGePoint3d& p4)
{
AcGePoint3d ptMid1 = (p1 + p2) / 2.0;
AcGePoint3d ptMid2 = (p3 + p4) / 2.0;
AcGeVector3d vec1 = p2 - p1;
AcGeVector3d vec2 = p4 - p3;
vec1.rotateBy(kPi / 2.0, AcGeVector3d::kZAxis);
vec2.rotateBy(kPi / 2.0, AcGeVector3d::kZAxis);
AcGeLine3d line1(ptMid1, vec1);
AcGeLine3d line2(ptMid2, vec2);
AcGePoint3d ptInt;
line1.intersectWith(line2, AcGe::kOnBothOperands, ptInt);
return ptInt;
}
```
其中,`p1` 和 `p2` 是第一条直线的两个端点,`p3` 和 `p4` 是第二条直线的两个端点。函数返回两条直线的中垂线的交点。
阅读全文