From: Shawn Hargreaves To: djgpp AT delorie DOT com MMDF-Warning: Parse error in original version of preceding line at punt-2.mail.demon.net Subject: Re: cross_product() - Allegro Date: Wed, 14 May 1997 09:06:13 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <863609349.097651.0@[194.129.18.166]> Precedence: bulk KaRNaGE writes: > i was wondering how i could use cross_product() to get the normal of a > vector (x, y, z)...and the normal of a face (triangle)...thankz... A vector doesn't have a normal, or rather it has an infinite number of them. Think about it: a normal is just a line at right angles to something else, and in 3d there are a lot of different ways to arrange two lines so they are perpendicular! The cross product returns a vector that is perpendicular to both of two input vectors. If you have a triangle, use two of its edges as the input vectors, eg. for the triangle x1,y1,z1, x2,y2,z2, x3,y3,z3, the normal is: fixed xnormal, ynormal, znormal; cross_product(x2-x1, y2-y1, z2-z1, x3-x2, y3-y2, z3-z2, &xnormal, &ynormal, &znormal); And there you have your normal. There are obviously two possible results for any single polygon: which one you get will be determined by whether your vertices were stored in a clockwise or anticlockwise direction (to get the other normal, just negate the output vector). -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk Beauty is a French phonetic corruption of a short cloth neck ornament