POV-Ray : Newsgroups : povray.general : Calculating the normals of a triangle Server Time
5 Aug 2024 14:12:20 EDT (-0400)
  Calculating the normals of a triangle (Message 1 to 10 of 14)  
Goto Latest 10 Messages Next 4 Messages >>>
From: Marcus Fritzsch
Subject: Calculating the normals of a triangle
Date: 11 Sep 2002 08:03:19
Message: <3D7F30C8.9030800@fritschy.de>
Hi,

i wrote a simple triangulation algo for a noise program to generate 
something like a hieghtfield, and i wanted to use this with 
smooth_triangles, does anybody knows how to calculate the normals of the 
three points from the known triangle?

greetings, Marcus


Post a reply to this message

From: ABX
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 08:36:12
Message: <qvdunu4kj2h82glmf0i9l824m2t65gov8v@4ax.com>
On Wed, 11 Sep 2002 14:02:16 +0200, Marcus Fritzsch <m### [at] fritschyde> wrote:
> does anybody knows how to calculate the normals of the 
> three points from the known triangle?

It is averaged addition from normals of all triangles in this vertex.
Be aware it can be weighted with angle/area:
http://news.povray.org/povray.binaries.images/13313/

ABX


Post a reply to this message

From: Warp
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 08:40:51
Message: <3d7f39d3@news.povray.org>
Marcus Fritzsch <m### [at] fritschyde> wrote:
> i wrote a simple triangulation algo for a noise program to generate 
> something like a hieghtfield, and i wanted to use this with 
> smooth_triangles, does anybody knows how to calculate the normals of the 
> three points from the known triangle?

  There are basically two ways:

  1. If you know the function which was used to generate the mesh and you
can derive the function with respect to x, y and z (or x and y in the
case of a heightfield function f(x,y)), then you can use the gradient
of the function (ie. <df(x,y)/dx, df(x,y)/dy>) to calculate the normal
vector at any point of the function.

  2. If you don't know the function, or the function is not differentiable
(or it's just too difficult to do so), then you can use an approximation
which works quite well for (almost) any mesh: The normal vector at a vertex
point is the sum of all the normal vectors of the triangles sharing that
vertex.
  (The normal vector of a triangle can be calculated with the cross-product
of two of its edges. According to empirical tests, *not* normalizing these
normals gives the best result in the sum described above (because the
dot-product of the two edges of a triangle gives a normal vector which
length is equal to the area of the triangle, and not normalizing this
vector means that a larger triangle has more effect in the normal of the
vertex than other smaller triangles sharing that same vertex, which
reportedly gives better results).)

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Marcus Fritzsch
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 09:54:08
Message: <3D7F4AC0.4090901@fritschy.de>
Hi,

this was exactly what i searched!!

Warp schrieb:
> Marcus Fritzsch <m### [at] fritschyde> wrote:
> 
>>i wrote a simple triangulation algo for a noise program to generate 
>>something like a hieghtfield, and i wanted to use this with 
>>smooth_triangles, does anybody knows how to calculate the normals of the 
>>three points from the known triangle?
>   1. If you know the function...
Hmm, i guess i don't know the function...

>   2. If you don't know the function, or the function is not differentiable
> (or it's just too difficult to do so)...
I'll try this way!

thx a lot :o)

regards, Marcus


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 10:20:03
Message: <web.3d7f50003836a27fedbc6d4c0@news.povray.org>
Warp wrote:
>Marcus Fritzsch <m### [at] fritschyde> wrote:
>> i wrote a simple triangulation algo for a noise program to generate
>> something like a hieghtfield, and i wanted to use this with
>> smooth_triangles, does anybody knows how to calculate the normals of the
>> three points from the known triangle?
>
>  There are basically two ways:
......

......
>  2. If you don't know the function, or the function is not differentiable
>(or it's just too difficult to do so), then you can use an approximation
>which works quite well for (almost) any mesh: The normal vector at a vertex
>point is the sum of all the normal vectors of the triangles sharing that
>vertex.
>  (The normal vector of a triangle can be calculated with the cross-product
>of two of its edges. According to empirical tests, *not* normalizing these
>normals gives the best result in the sum described above (because the
>dot-product of the two edges of a triangle gives a normal vector which
 ^^^
I guess you meant to write 'cross-product' here ;)


>length is equal to the area of the triangle, and not normalizing this
>vector means that a larger triangle has more effect in the normal of the
>vertex than other smaller triangles sharing that same vertex, which
>reportedly gives better results).)
>...


Tor Olav


Post a reply to this message

From: Marcus Fritzsch
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 10:24:43
Message: <3D7F51EA.3080804@fritschy.de>
Hi again...

Warp schrieb:
> ...
>   (The normal vector of a triangle can be calculated with the cross-product
> of two of its edges. According to empirical tests, *not* normalizing these
> normals gives the best result in the sum described above (because the
> dot-product of the two edges of a triangle gives a normal vector which
> length is equal to the area of the triangle, and not normalizing this
> vector means that a larger triangle has more effect in the normal of the
> vertex than other smaller triangles sharing that same vertex, which
> reportedly gives better results).)
I have some problems with this part, first you told me about 
cross-product of
the edges, than, 2 lines below of the dot-product of the 2 edges... 
which one
is right? my maths aren't enough to understand this before have it used 
it and
seen the result...

greetings, Marcus


Post a reply to this message

From: Warp
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 10:27:18
Message: <3d7f52c2@news.povray.org>
Tor Olav Kristensen <tor### [at] hotmailcom> wrote:
>>dot-product of the two edges of a triangle gives a normal vector which
>  ^^^
> I guess you meant to write 'cross-product' here ;)

  Yes.

-- 
#macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb M()}}
N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}//  - Warp -


Post a reply to this message

From: Warp
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 10:28:15
Message: <3d7f52ff@news.povray.org>
Marcus Fritzsch <m### [at] fritschyde> wrote:
> I have some problems with this part, first you told me about 
> cross-product of
> the edges, than, 2 lines below of the dot-product of the 2 edges... 
> which one
> is right?

  Writing "dot-product" was a mistake. It should have been "cross-product".

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

From: Marcus Fritzsch
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 10:30:01
Message: <3D7F532A.4080802@fritschy.de>
Hi, :o)

Warp schrieb:
>>I have some problems with this part, first you told me about 
>>cross-product of
>>the edges, than, 2 lines below of the dot-product of the 2 edges... 
>>which one
>>is right?
> 
> 
>   Writing "dot-product" was a mistake. It should have been "cross-product".
oops, i wrote my message while the other was postet... :o) ok, now i 
know it, thx!

mfg Marcus


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Calculating the normals of a triangle
Date: 11 Sep 2002 10:45:13
Message: <web.3d7f566a3836a27fedbc6d4c0@news.povray.org>
Warp wrote:
>...
>(because the
>dot-product of the two edges of a triangle gives a normal vector which
>length is equal to the area of the triangle,
>...

Its length is equal to twice the area of the triangle.


Tor Olav


Post a reply to this message

Goto Latest 10 Messages Next 4 Messages >>>

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