[vtkusers] setting camera orientation
Tim Soper
tim_d_soper at yahoo.com
Wed Dec 12 14:04:08 EST 2007
So I searched online to find any reference as to why there is no easy SetOrientation method as part of the vtkCamera. I 'm not sure I understand. This seems really basic. As of now, I have to port the code snippet below into every application I use. Can anyone explain why this can't just be put into the vtkCamera class directly? Once the three angles are known, the view matrix can be computed. It seems a bit laborious to have to compute the focus and view up explicitly to change the orientation, but I don't see another way of doing this with the current methods in the vtkCamera class.
void SetCameraPositionOrientation( vtkCamera* cam, double position[3],
double orientation[3] )
{
double focus[3];
double viewup[3];
if( cam == NULL )
return;
focus[0] = position[0] - -cos(orientation[0])*sin(orientation[1]);
focus[1] = position[1] - sin(orientation[0]);
focus[2] = position[2] - cos(orientation[0])*cos(orientation[1]);
viewup[0] = cos(orientation[1])*sin(orientation[2])+
sin(orientation[1])*sin(orientation[2])*cos(orientation[2]);
viewup[1] = cos(orientation[0])*cos(orientation[2]);
viewup[2] = sin(orientation[1])*sin(orientation[2])-
cos(orientation[1])*sin(orientation[0])*cos(orientation[2]);
//set the camera position and orientation
cam->SetPosition( position );
cam->SetViewUp( viewup );
cam->SetFocalPoint( focus );
}
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
More information about the vtkusers
mailing list