Path: utzoo!attcan!uunet!wuarchive!zaphod.mps.ohio-state.edu!ncar!gatech!prism!ccastjr From: ccastjr@prism.gatech.EDU (COOOooOoooooOOOOoOOoOOooKIE!!!!!) Newsgroups: comp.graphics Subject: Re: Polygon orientation test ? Message-ID: <15655@hydra.gatech.EDU> Date: 22 Oct 90 17:30:19 GMT References: <4158.272311a1@cc.curtin.edu.au> Organization: Georgia Institute of Technology Lines: 54 > >Does anybody know a simple test for a polygon's orientation ? >------------------------------------------------------------------------------- I'm kind of new to graphics (well, anything beyond playing on the apple II), but the same question came to me recently, so I started thinking about it. I thought of one way, but I think it would be rather slow (ie. don't try to run this algorythm in a real-time sim). Oh...I"m assuming from your question you mean a 3-d polygon, where you are trying to determine the direction of the normal for hidden surfaces...if this is wrong, then completely ignore my alg. :) Also, it wont work for polyhedrons with serious concavities. 1) Determine the center of your solid (simply averaging all of the points of the poly's is good enough for the purposes of this test). 2) Determine the center of the plane of your polygon. 3) make this into a vector. 4) Determine the normal to your polygon (using it's current order) 5) If the Normal of the poly is in the same direction (read: within 90 degrees) as the vector from step 3, then the poly is clockwise. If the Normal is in the opposite (greater than 90 degrees), then your poly is anti-clockwise. If it's 90 degrees, then I'm not sure what you ought to do. If your return value is anti-clockwise or clockwise, then this is all you need. If you're return value is hidden or non-hidden, then substitute this for step 5 5) if the Normal of the poly is in the same direction, then determine whether or not the surface is hidden with this Normal vector. if they are in opposite directions, then use the Normal's negative (multiply the coefficients of I, J, and K by -1) for determining if the surface is hidden or not. Again, I don't know what to do if the normals turn out perpendicular (sp?). Hope this helps (btw: if anyone knows of a formalised version of this algorythm, let me know..) John Rudd -- Emporers Thought for the Day: | John E. Rudd jr. Only the insane have the strength to prosper; | ccastjr@prism.gatech.edu Only those who prosper judge what is sane. | (ex- kzin@ucscb.ucsc.edu) #include Send all comments, flames, and complaints to /dev/null.