世界坐标系 > 屏幕坐标系
double worldCoord[3] = {100, 100, 20};vtkSmartPointer<vtkCoordinate> pCoorPress = vtkSmartPointer<vtkCoordinate>::New();pCoorPress->SetCoordinateSystemToWorld();pCoorPress->SetValue(worldCoord);int *dispCoord = pCoorPress->GetComputedDisplayValue(m_Render1);qDebug() << dispCoord[0] << dispCoord[1];
屏幕坐标系 > 世界坐标系
double dispCoord[2] = {100, 100};vtkSmartPointer<vtkCoordinate> pCoorPress = vtkSmartPointer<vtkCoordinate>::New();pCoorPress->SetCoordinateSystemToDisplay();pCoorPress->SetValue(dispCoord);double *worldCoord = pCoorPress->GetComputedWorldValue(m_Render1);qDebug() << worldCoord[0] << worldCoord[1] << worldCoord[2];
以上代码一定要在窗口show出来以后调用,不能在初始化时进行
如果觉得《vtk世界坐标系与屏幕坐标系的转换》对你有帮助,请点赞、收藏,并留下你的观点哦!