Arx: AcdbPolyline的二维三维转换矩阵
2013-09-25 09:07
411 查看
1. AcdbPolyline的GetPointAt有两个:一个是获取二维点坐标(In OCS),一个是获取三维点坐标(In WCS)
Acad::ErrorStatusgetPointAt(
unsigned int index,
AcGePoint2d& pt) const;
This function sets pt to the 2D location of the vertexindex in thepolyline's own ojbect coordinate system (OCS).
Acad::ErrorStatus
getPointAt(
unsigned int unnamed,
AcGePoint3d& pt) const;
This function sets pt to the 3D location of the vertexindexin World Coordinates.
如果AcdbPolyLine不在x/y平面上的话,我们可以看出来,他们是不完全对应的:
例如下面的这个
Point: x-670.8292, y-18.2542
Point: x-670.8292, y-12.0000, z-18.2542
二维、三维之间如何转换呢?借助matrix可以完成转换:我们借助两个函数
AcDbEntity::getEcs Functionvirtual void
getEcs(
AcGeMatrix3d& retVal) const;
retVal | Output filled in with transformation matrix to go from OCS to WCS |
AcDbPolyline::elevationFunction
double
elevation() const;
This returns the distance from the WCS origin to the plane of the polyline.
第一种方法:[b] 通过getEcs获取其转换矩阵,通过elevation获取PLine线所在面 距 WCS原点的距离[/b]
(我们通过GetPointAt获取二维点时,其实他们本身是缺省带有z坐标elevation的---也就是PLine线所在面 距 WCS原点的距离)
AcGeMatrix3d matixToWCS; pPlineTop->getEcs(matixTransToWCS); double dElevetion = pPlineTop->elevation();
转换的时候:调用transformby,完成转换
注:dElevetion作为了z坐标
AcGePoint3d pt3dPoint = AcGePoint3d(pt2dTemp.x, pt2dTemp.y, dElevetion).transformBy(matixToWCS);
[b]第二种方法: 把dElevetion也放到转换矩阵中来,直接转换[/b]
AcGeMatrix3d matixToWCS; pPlineTop->getEcs(matixTransToWCS); // 矩阵附加elevation的转换
matixTransToWCS *= AcGeMatrix3d::translation(AcGeVector3d::kZAxis * pPlineTop->elevation());AcGePoint3d pt3dPoint = AcGePoint3d(pt2dTemp.x, pt2dTemp.y, dElevToWCS).transformBy(matixToWCS);
相关文章推荐
- 关于if语句的条件
- windows7系统字体被改了之后怎么还原之前的默认字体
- 64位系统和32位系统的区别
- C语言 打印圣诞树
- 启动服务时,提示“错误1053:服务没有及时相应启动或控制请求”。
- Maven(一)如何创建一个web程序
- C++中的三种继承public,protected,private详细解析
- REVERSE关键字之REVERSE函数
- Windows Server 2012 R2 RTM版安装
- 多核下的并发计数器的高性能实现
- ubuntu 12.04 安装ubuntu-Tweak
- jquery mobile 中的长按操作
- C# 4.0 新機能
- libevent分解之数据结构 小根堆
- 读书
- Windows Server 8.1RTM版本安装
- uva 10280 - Old Wine Into New Bottles(完全背包)
- asp.net Cookie的使用
- 算法学习及面试技巧网
- 机房收费系统之组合查询