------------------------------------------------------------------------------
| 541 | |
| 542 | //------------------------------------------------------------------------------ |
| 543 | void vtkMatplotlibMathTextUtilities::RotateCorners( |
| 544 | double angleDeg, double corners[4][2], double bbox[4]) |
| 545 | { |
| 546 | double angleRad = vtkMath::RadiansFromDegrees(angleDeg); |
| 547 | double c = cos(angleRad); |
| 548 | double s = sin(angleRad); |
| 549 | // Rotate corners |
| 550 | for (int i = 0; i < 4; ++i) |
| 551 | { |
| 552 | int newpt[2]; |
| 553 | newpt[0] = c * corners[i][0] - s * corners[i][1]; |
| 554 | newpt[1] = s * corners[i][0] + c * corners[i][1]; |
| 555 | corners[i][0] = newpt[0]; |
| 556 | corners[i][1] = newpt[1]; |
| 557 | } |
| 558 | // Find new bounds |
| 559 | bbox[0] = VTK_INT_MAX; |
| 560 | bbox[1] = VTK_INT_MIN; |
| 561 | bbox[2] = VTK_INT_MAX; |
| 562 | bbox[3] = VTK_INT_MIN; |
| 563 | for (int i = 0; i < 4; ++i) |
| 564 | { |
| 565 | bbox[0] = std::min(corners[i][0], bbox[0]); |
| 566 | bbox[1] = std::max(corners[i][0], bbox[1]); |
| 567 | bbox[2] = std::min(corners[i][1], bbox[2]); |
| 568 | bbox[3] = std::max(corners[i][1], bbox[3]); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | //------------------------------------------------------------------------------ |
| 573 | // This is more or less ported from vtkFreeTypeTools. |
no test coverage detected