VTK中世界坐标系到显示坐标系下的流程分析


水平有限,欢迎各位大神指正!

///

关于坐标相互转换的理论部分可以参阅 http://blog.csdn.net/popy007/article/details/1797121


解析vtk下世界坐标系world到显示坐标系下的转换:

首先呢在vtkInteractorObserver中存在函数ComputeWorldToDisplay()函数供其子类调用,源代码如下:


//----------------------------------------------------------------------------

// Description:

// Transform from world to display coordinates.

// displayPt has to be allocated as 3 vector

void vtkInteractorObserver::ComputeWorldToDisplay(double x, double y, double z,  double displayPt[3])

{

  if ( !this->CurrentRenderer ) 

    {

    return;

    }

   this->ComputeWorldToDisplay(this->CurrentRenderer, x, y, z, displayPt);

}


// Description:

// Transform from world to display coordinates.

// displayPt has to be allocated as 3 vector

void vtkInteractorObserver::ComputeWorldToDisplay(vtkRenderer *ren, double x, double y, double z,  double displayPt[3])

{

  ren->SetWorldPoint(x, y, z, 1.0);

  ren->WorldToDisplay();

  ren->GetDisplayPoint(displayPt);

}

///

借助于上边两个函数最终还是靠vtkRenderer来完成世界坐标系向显示坐标系下的转换,在函数中,首先在世界坐标系下定义了一个点(x,y,z,1),然后调用vtkViewport(vtkRenderer的父类)的WorldToDisplay()函数,下边我们解剖这个函数内部功能。

  // Description:

  // Convert world point coordinates to display (or screen) coordinates.

  void WorldToDisplay() {this->WorldToView(); this->ViewToDisplay();};

这个函数先将world坐标系转换为view坐标系,然后再将view坐标系转换为显示坐标系

(1)下边解剖WorldToView()函数

// Convert world point coordinates to view coordinates.

void vtkRenderer::WorldToView()

{

  double result[3];

  result[0] = this->WorldPoint[0];

  result[1] = this->WorldPoint[1];

  result[2] = this->WorldPoint[2];

  • 0
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值