# 【VTK】坐标系入门

### vtkCoordinate and Coordinate Systems

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 viewport
• VIEW — x-y-z(-1,1) values in camera coordinates (z is depth)
• WORLD — x-y-z global coordinatevalue
• USERDEFINED - 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

还能输入1000个字符
私密原因:
请选择设置私密原因
• 广告
• 抄袭
• 版权
• 政治
• 色情
• 无意义
• 其他
其他原因:
120
系统繁忙，请稍后再试