------------------------------------------------------------------------------ Project triangle defined in 3D to 2D coordinates. Returns 0 if degenerate triangle; non-zero value otherwise. Input points are x1->x3; output 2D points are v1->v3.
| 920 | // triangle; non-zero value otherwise. Input points are x1->x3; output 2D |
| 921 | // points are v1->v3. |
| 922 | int vtkTriangle::ProjectTo2D(const double x1[3], const double x2[3], const double x3[3], |
| 923 | double v1[2], double v2[2], double v3[2]) |
| 924 | { |
| 925 | double n[3], v21[3], v31[3], v[3]; |
| 926 | |
| 927 | // Get normal for triangle |
| 928 | vtkTriangle::ComputeNormal(x1, x2, x3, n); |
| 929 | |
| 930 | for (int i = 0; i < 3; i++) |
| 931 | { |
| 932 | v21[i] = x2[i] - x1[i]; |
| 933 | v31[i] = x3[i] - x1[i]; |
| 934 | } |
| 935 | |
| 936 | double xLen = vtkMath::Normalize(v21); |
| 937 | if (xLen <= 0.0) |
| 938 | { |
| 939 | return 0; |
| 940 | } |
| 941 | |
| 942 | // The first point is at (0,0); the next at (xLen,0); compute the other |
| 943 | // point relative to the first two. |
| 944 | v1[0] = v1[1] = 0.0; |
| 945 | v2[0] = xLen; |
| 946 | v2[1] = 0.0; |
| 947 | |
| 948 | vtkMath::Cross(n, v21, v); |
| 949 | |
| 950 | v3[0] = vtkMath::Dot(v31, v21); |
| 951 | v3[1] = vtkMath::Dot(v31, v); |
| 952 | |
| 953 | return 1; |
| 954 | } |
| 955 | |
| 956 | //------------------------------------------------------------------------------ |
| 957 | // Support triangle clipping. Note that the table defines triangles (three ids |
nothing calls this directly
no test coverage detected