boolean edgeIntersectPolygon2D(Vector3d normal, Point3d[] coord,
Point3d[] seg)
{
double absNrmX, absNrmY, absNrmZ;
Point2d coord2D[] = new Point2d[coord.length];
Point2d seg2D[] = new Point2d[2];
int i, j, axis;
// Project 3d points onto 2d plane.
// Note : Area of polygon is not preserve in this projection, but
// it doesn't matter here.
// Find the axis of projection.
absNrmX = Math.abs(normal.x);
absNrmY = Math.abs(normal.y);
absNrmZ = Math.abs(normal.z);
if(absNrmX > absNrmY)
axis = 0;
else
axis = 1;
if(axis == 0) {
if(absNrmX < absNrmZ)
axis = 2;
}
else if(axis == 1) {
if(absNrmY < absNrmZ)
axis = 2;
}
// System.err.println("Normal " + normal + " axis " + axis );
for(i=0; i<coord.length; i++) {
coord2D[i] = new Point2d();
switch (axis) {
case 0:
coord2D[i].x = coord[i].y;
coord2D[i].y = coord[i].z;
break;
case 1:
coord2D[i].x = coord[i].x;
coord2D[i].y = coord[i].z;
break;
case 2:
coord2D[i].x = coord[i].x;
coord2D[i].y = coord[i].y;
break;
}
// System.err.println("i " + i + " u " + uCoor[i] + " v " + vCoor[i]);
}
for(i=0; i<2; i++) {
seg2D[i] = new Point2d();
switch (axis) {
case 0:
seg2D[i].x = seg[i].y;
seg2D[i].y = seg[i].z;
break;