【VTK】坐标系入门

网友投稿 542 2022-09-01

【VTK】坐标系入门

vtkCoordinate and Coordinate Systems

以下英文介绍内容出自《VTKUsersGuide.pdf》

The Visualization Toolkit supports several different coordinate systems, and the class vtkCoordinate manages transformations between them. The supported coordinate systems are as follows.

DISPLAY — x-y pixel values in the (rendering) window. (Note that vtkRenderWindow is a subclass of vtkWindow). The origin is the lower-left corner (which is true for all 2D coordinate systems described below).NORMALIZED DISPLAY — x-y (0,1) normalized values in the window.VIEWPORT — x-y pixel values in the viewport (or renderer—a sub class of vtkViewport)NORMALIZED VIEWPORT — x-y(0,1) normalized values in viewportVIEW — x-y-z(-1,1) values in camera coordinates (z is depth)WORLD — x-y-z global coordinatevalueUSERDEFINED - x-y-z in user-defined space. The user must provide a transformation method for user defined coordinate systems. See vtkCoordinate for more information. The class vtkCoordinate can be used to transform between coordinate systems and can be linked together to form “relative” or “offset” coordinate values. Refer to the next section for an example of using vtkCoordinate in an application.要点:DISPLAY:二维像素坐标系,原点在renderWindow左下角NORMALIZED DISPLAY:和DISPLAY类似,但X,Y的取值范围是[0, 1]VIEWPORT:二维像素坐标系,原点在renderWindow左下角,但是受到render的viewport影响。NORMALIZED VIEWPORT:和VIEWPORT类似,X、Y的取值范围为[0,1]。VIEW:X、Y、Z坐标值取值范围为[-1,1],Z表示深度,即物体离相机的距离。WORLD:世界坐标系统的x,y,z。

坐标转换

在vtkViewport中,几乎提供了所有的坐标系相互转换的方法,比如

void DisplayToWorld()void WorldToDisplay()void WorldToView()void ViewToDisplay()...

world坐标转Display坐标 例子

vtkRenderer *render = m_MainWindow->GetVtkRenderer();render->SetWorldPoint( origin.point );render->WorldToDisplay();render->GetDisplayPoint( displayOriginPos );

一个实验:

renderer->SetWorldPoint( 10, 10, 10, 0 ); renderer->WorldToDisplay(); double *disPos = renderer->GetDisplayPoint(); printf( "disPos: (%lf, %lf, %lf)\n", disPos[0], disPos[1], disPos[2] ); //disPos: (-673.684208, -673.684208, 2.867116)

这个结果有点以外,因为之前提到过Display是二维坐标系,但是这里的Z值不是0. 如果对view,viewport,display坐标系理解还有疑惑,可以阅读这个例子:​​​【VTK】使用vtkActor2D添加polyline​​

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Print debug message based on MSVC
下一篇:大闸蟹鲜美上市,如何不让营销套路横行?(大闸蟹怎么推广)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~