Returns indeces of the two elements of points on a face to use as a 2d projection Parameters: normal - the surface normal of the face ii,jj - filled in with elements numbers (0,1, or 2)
| 976 | // Parameters: normal - the surface normal of the face |
| 977 | // ii,jj - filled in with elements numbers (0,1, or 2) |
| 978 | void GetIJ(const vector *normal, int *ii, int *jj) { |
| 979 | |
| 980 | // To project onto 2d, find the largest element of the surface normal |
| 981 | if (fabs(normal->x) > fabs(normal->y)) |
| 982 | if (fabs(normal->x) > fabs(normal->z)) { |
| 983 | if (normal->x > 0) { |
| 984 | *ii = 2; |
| 985 | *jj = 1; // x > y, x > z |
| 986 | } else { |
| 987 | *ii = 1; |
| 988 | *jj = 2; |
| 989 | } |
| 990 | } else { |
| 991 | if (normal->z > 0) { |
| 992 | *ii = 1; |
| 993 | *jj = 0; // z > x > y |
| 994 | } else { |
| 995 | *ii = 0; |
| 996 | *jj = 1; |
| 997 | } |
| 998 | } |
| 999 | else // y > x |
| 1000 | if (fabs(normal->y) > fabs(normal->z)) { |
| 1001 | if (normal->y > 0) { |
| 1002 | *ii = 0; |
| 1003 | *jj = 2; // y > x, y > z |
| 1004 | } else { |
| 1005 | *ii = 2; |
| 1006 | *jj = 0; |
| 1007 | } |
| 1008 | } else { |
| 1009 | if (normal->z > 0) { |
| 1010 | *ii = 1; |
| 1011 | *jj = 0; // z > y > x |
| 1012 | } else { |
| 1013 | *ii = 0; |
| 1014 | *jj = 1; |
| 1015 | } |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | // 2d cross product |
| 1020 | #define cross(v0, v1) (((v0)[ii] * (v1)[jj]) - ((v0)[jj] * (v1)[ii])) |
no outgoing calls
no test coverage detected