------------------------------------------------------------------------------
| 392 | |
| 393 | //------------------------------------------------------------------------------ |
| 394 | void vtkPerspectiveTransform::SetupCamera( |
| 395 | const double position[3], const double focalPoint[3], const double viewUp[3]) |
| 396 | { |
| 397 | double matrix[4][4]; |
| 398 | vtkMatrix4x4::Identity(*matrix); |
| 399 | |
| 400 | // the view directions correspond to the rows of the rotation matrix, |
| 401 | // so we'll make the connection explicit |
| 402 | double* viewSideways = matrix[0]; |
| 403 | double* orthoViewUp = matrix[1]; |
| 404 | double* viewPlaneNormal = matrix[2]; |
| 405 | |
| 406 | // set the view plane normal from the view vector |
| 407 | viewPlaneNormal[0] = position[0] - focalPoint[0]; |
| 408 | viewPlaneNormal[1] = position[1] - focalPoint[1]; |
| 409 | viewPlaneNormal[2] = position[2] - focalPoint[2]; |
| 410 | vtkMath::Normalize(viewPlaneNormal); |
| 411 | |
| 412 | // orthogonalize viewUp and compute viewSideways |
| 413 | vtkMath::Cross(viewUp, viewPlaneNormal, viewSideways); |
| 414 | vtkMath::Normalize(viewSideways); |
| 415 | vtkMath::Cross(viewPlaneNormal, viewSideways, orthoViewUp); |
| 416 | |
| 417 | // translate by the vector from the position to the origin |
| 418 | double delta[4]; |
| 419 | delta[0] = -position[0]; |
| 420 | delta[1] = -position[1]; |
| 421 | delta[2] = -position[2]; |
| 422 | delta[3] = 0.0; // yes, this should be zero, not one |
| 423 | |
| 424 | vtkMatrix4x4::MultiplyPoint(*matrix, delta, delta); |
| 425 | |
| 426 | matrix[0][3] = delta[0]; |
| 427 | matrix[1][3] = delta[1]; |
| 428 | matrix[2][3] = delta[2]; |
| 429 | |
| 430 | // apply the transformation |
| 431 | this->Concatenate(*matrix); |
| 432 | } |
| 433 | |
| 434 | void vtkPerspectiveTransform::SetupCamera(double p0, double p1, double p2, double fp0, double fp1, |
| 435 | double fp2, double vup0, double vup1, double vup2) |
no test coverage detected