POV-Ray : Newsgroups : povray.general : Calculating normals : Re: Calculating normals Server Time
10 Aug 2024 11:25:08 EDT (-0400)
  Re: Calculating normals  
From: Thorsten Froehlich
Date: 1 Jan 2000 09:39:41
Message: <386e11ad@news.povray.org>
In article <386E0DD0.9753804C@xs4all.nl> , Remco de Korte 
<rem### [at] xs4allnl>  wrote:

> I thought I'd find this in a FAQ but I couldn't.
> I know it's been discussed in the newsgroups more then once but I
> couldn't find those threads either, so here it goes:
>
> How do I calculate the normal for a triangle?
>
> I know this isn't really very difficult and there are several ways. I'd
> like to be able to understand this. How would I do it, without using the
> POV-statements or a matrix?

An easy way is using the following vector math, POV-Ray has all the
functions you need:

A triangle with the points P1,P2,P3.
Get two vectors, A and B where A = P2-P1 and B = P3-P1.
Now you can find the normal which is simply N = A x B.
You may want to normalise the vector with N0 = N : |N|

In POV-Ray this would look like this (not tested, insert your data):

#declare P1 = <...>;
#declare P2 = <...>;
#declare P3 = <...>;

#declare A = P2 - P1;
#declare B = P3 - P1;

#declare N = vcross(A, B);
#declare N0 = vnormalize(N);


    Thorsten

____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.