🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Polygon Question...

#267
From: T. Scott Thompson
Date: Thu, 06 Aug 1992 17:01
18 lines
1152 bytes
morley@camins.camosun.bc.ca writes:

>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.

Try this.  Calculate

      (X1 - X3)*(Y2 - Y3) - (X2 - X3)*(Y1 - Y3)

If the result is

    positive then 1 -> 2 -> 3 traverses the triangle counter-clockwise.

    negative then 1 -> 2 -> 3 traverses the triangle clockwise

    zero     then 1, 2, and 3 lie on a straight line.
Technical Details
Message-ID: <thompson.713120498@daphne.socsci.umn.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!destroyer!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!thompson
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!destroyer!sol.ctr.columbia.edu!The-Star.honeywell.com!umn.edu!thompson
From: thompson@atlas.socsci.umn.edu (T. Scott Thompson)
Subject: Re: Polygon Question...
Message-ID: <thompson.713120498@daphne.socsci.umn.edu>
Sender: news@news2.cis.umn.edu (Usenet News Administration)
Nntp-Posting-Host: daphne.socsci.umn.edu
Organization: University of Minnesota
References: <1992Jul21.094844.1@camins.camosun.bc.ca>
Date: Thu, 6 Aug 1992 17:01:38 GMT
Lines: 18