|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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?
Thanks in advance,
Remco
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
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
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Thorsten Froehlich wrote:
>
> 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
Wow, that's fast!
The first part is something I had sort of figured out by myself
(although I wasn't really sure). The second part I can understand, but
I'd like to know how to calculate them without using the POV-functions.
I've been trying to set up a macro in POV using this but it took days
(!) to parse, so now I'm trying to do it in an external program. After
that I might be able to find some shortcuts and get it back to a
POV-macro but I'm not too sure.
Thanks for yor help anyway, it might still do the trick (I know how to
calculate vcross, I'm not too sure about vnormalize for 3D-vectors...)
Best wishes,
Remco
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Remco de Korte <rem### [at] xs4allnl> wrote:
: Thanks for yor help anyway, it might still do the trick (I know how to
: calculate vcross, I'm not too sure about vnormalize for 3D-vectors...)
Normalizing a 3D-vector is exactly like normalizing a 2D-vector: Divide its
components by the length of the vector.
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nieminen Juha wrote:
>
> Remco de Korte <rem### [at] xs4allnl> wrote:
> : Thanks for yor help anyway, it might still do the trick (I know how
> to
> : calculate vcross, I'm not too sure about vnormalize for
> 3D-vectors...)
>
> Normalizing a 3D-vector is exactly like normalizing a 2D-vector:
> Divide its
> components by the length of the vector.
>
> --
I think I confused terms here.
I know how to normalize a vector (as you describe), i _don't_ know hot
to calculate VCROSS (I mistook it for caclulating the average).
So, again: how to calculate a normal?
Remco
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Remco de Korte <rem### [at] xs4allnl> wrote:
: I know how to normalize a vector (as you describe), i _don't_ know hot
: to calculate VCROSS (I mistook it for caclulating the average).
: So, again: how to calculate a normal?
The cross-product of two vectors <x1,y1,z1> and <x2,y2,z2> can be
calculated this way:
| i j k |
| x1 y1 z1 | = (y1*z2-y2*z1)i + (x2*z1-x1*z2)j + (x1*y2-x2*y1)k
| x2 y2 z2 |
ie:
<y1*z2-y2*z1, x2*z1-x1*z2, x1*y2-x2*y1>
--
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Nieminen Juha wrote:
>
> Remco de Korte <rem### [at] xs4allnl> wrote:
> : I know how to normalize a vector (as you describe), i _don't_ know
> hot
> : to calculate VCROSS (I mistook it for caclulating the average).
> : So, again: how to calculate a normal?
>
> The cross-product of two vectors <x1,y1,z1> and <x2,y2,z2> can be
> calculated this way:
>
> | i j k |
> | x1 y1 z1 | = (y1*z2-y2*z1)i + (x2*z1-x1*z2)j + (x1*y2-x2*y1)k
> | x2 y2 z2 |
>
> ie:
>
> <y1*z2-y2*z1, x2*z1-x1*z2, x1*y2-x2*y1>
>
> --
>
Thanks!
Actually I already found the information I needed just a couple of
minutes ago.
Where?
In your mesh-smoother 8)
Remco
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
|
|