POV-Ray : Newsgroups : povray.binaries.images : For Hugo. Irregular mesh smoothing idea. : Re: Yeaah! I got it to work!! Server Time
16 Aug 2024 16:23:22 EDT (-0400)
  Re: Yeaah! I got it to work!!  
From:
Date: 6 Mar 2002 12:15:17
Message: <8tic8ugj54obbclgs7jrjedqg7spe4mell@4ax.com>
On Wed, 6 Mar 2002 18:08:12 +0100, "Hugo" <hua### [at] post3teledk> wrote:
> I'd very much like to have the best
> smoothing algoritm in my program..

Algorithm is very simple:

1. start loop on all triangles and calculate
a) triangle has vertices V1,V2,V3
b) normal=vnormalize(vcross(V2-V1,V3-V1))
c) area=triangle_area(V1.x,V1.y,V1.z,V2.x,V2.y,V2.z,V3.x,V3.y,V3.z)
d) multiply above and store area*normal in temporary array

2. start second loop on all vertices
a) for each vertex find all its triangles: triangle1, triangle2, ... triangleN
b) calculate weighted normal with equation:
Normal=(area1*normal1+area2*normal2+...+areaN*normalN)/N
(note all multiplications was precalculated and stored in array)
c) store new weighted normal for triangle

That's all.

Of course there can be variations and optimizations according to particular
situation but it is how it looks in general

ABX


Post a reply to this message

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