home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / msdos / programm / 7996 < prev    next >
Encoding:
Text File  |  1992-07-21  |  1.4 KB  |  36 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!orca!javelin.sim.es.com!gclapp
  3. From: gclapp@javelin.sim.es.com (Glenn Clapp)
  4. Subject: Re: Polygon Question...
  5. Message-ID: <1992Jul21.221038.7051@javelin.sim.es.com>
  6. Organization: Evans & Sutherland Computer Corporation
  7. References: <1992Jul21.094844.1@camins.camosun.bc.ca>
  8. Date: Tue, 21 Jul 1992 22:10:38 GMT
  9. Lines: 25
  10.  
  11. In article <1992Jul21.094844.1@camins.camosun.bc.ca> morley@camins.camosun.bc.ca writes:
  12. >Hi!
  13. >
  14. >Ok, this should be an easy one...  Given 3 X,Y points that form a triangle,
  15. >what is the simplest (fastest) way to determine if they are clock-wise or
  16. >counter-clock-wise?  I'm not interested in general polygons of N points,
  17. >just plain old triangles.  Yes, this is for use in a graphics app.
  18. >
  19. >Thanks...
  20. >
  21. >MARK
  22. >morley@camins.camosun.bc.ca
  23. >
  24.  
  25. Traverse the polygon, calculating 3 cross products (v1->v2 X v2->v3,
  26. v2->v3 X v3->v1), and (v3->v1 X v1->v2), and if the cross products are
  27. positive, the polygon is counterclockwise, otherwise they will be negetive.
  28. Also, if you have a sign flip between the different cross products, then
  29. the polygon is not convex.
  30.  
  31. -- 
  32. | The real democratic American idea is not that everyone shall be on a     |
  33. | level with every other, but that everyone shall have liberty, without    |
  34. | hinderances, to be what God made him.             -- Henry Ward Bleecher |
  35. |-------------              ----------- ----------              -----------|
  36.