【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 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

    發表評論
    所有評論
    還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
    相關文章