3

how to know if vertices are counter clockwise? This: s.o. page

says if cross is negative then it is clockwise. How can a vector be negative? That doesn't make any sense.

Community
  • 1
  • 1
Sam Adamsh
  • 3,331
  • 8
  • 32
  • 53

2 Answers2

3

Your question is a good one. The answer is nontrivial.

You are right that the cross product of two vectors yields a third vector and that none of these vectors is negative as such. However, the most common use of a cross product is either [a] to take the divergence of it (which does not apply in your case) or [b] to dot-multiply it with a fourth vector. The dot product is a scalar which, of course, can indeed be negative.

In your case, the fourth vector would be a vector from one vertex or another of the polygon to the observer's viewpoint. Check the sign of the resulting dot product, and it will tell you whether the rotation is counterclockwise (positive) or clockwise (negative) as seen by the observer.

The disadvantage of the technique is that it seems abstract to those who are not versed in vector algebra. However, the disadvantage is far outweighed by the advantage: the cross-and-dot technique is blazing fast.

thb
  • 13,796
  • 3
  • 40
  • 68
1

The resultant vector will be perpendicular to the two input vectors -- and depending upon the order of the input vectors, it'll either point towards the view or away from the view -- or, if it parallels the plane of the view, it'll go in the opposite direction when you swap the order of the multiplication.

You'll have to arbitrarily pick some plane that separates a "positive" half and a "negative" half of the universe.

sarnold
  • 102,305
  • 22
  • 181
  • 238