🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.msdos.programmer
Article #416

Re: Polygon Question...

#416
From: Glenn Clapp
Date: Tue, 21 Jul 1992 22:10
25 lines
1483 bytes
In article <1992Jul21.094844.1@camins.camosun.bc.ca> morley@camins.camosun.bc.ca writes:
>Hi!
>
>Ok, this should be an easy one...  Given 3 X,Y points that form a triangle,
>what is the simplest (fastest) way to determine if they are clock-wise or
>counter-clock-wise?  I'm not interested in general polygons of N points,
>just plain old triangles.  Yes, this is for use in a graphics app.
>
>Thanks...
>
>MARK
>morley@camins.camosun.bc.ca
>

Traverse the polygon, calculating 3 cross products (v1->v2 X v2->v3,
v2->v3 X v3->v1), and (v3->v1 X v1->v2), and if the cross products are
positive, the polygon is counterclockwise, otherwise they will be negetive.
Also, if you have a sign flip between the different cross products, then
the polygon is not convex.

-- 
| The real democratic American idea is not that everyone shall be on a     |
| level with every other, but that everyone shall have liberty, without    |
| hinderances, to be what God made him.             -- Henry Ward Bleecher |
|-------------              ----------- ----------              -----------|
Technical Details
Message-ID: <1992Jul21.221038.7051@javelin.sim.es.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!orca!javelin.sim.es.com!gclapp
References: <1992Jul21.094844.1@camins.camosun.bc.ca>

Show Full Headers
Complete Article Headers
Newsgroups: comp.os.msdos.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!orca!javelin.sim.es.com!gclapp
From: gclapp@javelin.sim.es.com (Glenn Clapp)
Subject: Re: Polygon Question...
Message-ID: <1992Jul21.221038.7051@javelin.sim.es.com>
Organization: Evans & Sutherland Computer Corporation
References: <1992Jul21.094844.1@camins.camosun.bc.ca>
Date: Tue, 21 Jul 1992 22:10:38 GMT
Lines: 25