Quote:>Hi,

>I want to know if there is any method to check if *any* polygon,

>represented by points, can be checked if it is clockwisely

>defined or anti-clockwise.

>Actually, I want to know if two polygons are equally defined in

>the same direction, will this condition make the alogorithm easier?

If the two polygons share a common edge (which is the most useful

case for checking this), then the edge they have in common should be

defined in opposite directions on each polygon.

1--------2-------3

| > | > |

| | |

|/\ 1 \/|/\ 2 \/|

| | |

| < | < |

4--------5-------6

In this case points 2 and 5 form the common edge. If both polygons are

clockwise then polygon 1 must have edge [2,5] while polygon 2 has edge

[5,2].

In a more general case (no common edge, or don't want to look for one),

take two succesive edges on each polygon, and take the cross product.

Now take the dot product of the two resulting vectors. If the value of

the dot product is less than zero, the polygons face in opposite

directions. If it is greater than 0 the polygons face the same

direction.

This only works if your polygons are pretty flat, and you consider

polygons whose normals have an included angle greater than 90 degrees

to be facing in opposite directions. You can expand on the general

theme if you want, but i doubt that it would ever be foolproof except

in the purely planar case.

Glen

--

Glen Niebur | By the force of will, my lungs are filled,

Mayo Clinic | and so i breathe.

Biomechanics Lab|