POV-Ray : Newsgroups : povray.binaries.images : For Hugo. Irregular mesh smoothing idea. Server Time
16 Aug 2024 16:19:25 EDT (-0400)
  For Hugo. Irregular mesh smoothing idea. (Message 31 to 36 of 36)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Shay
Subject: Re: Yeaah! I got it to work!!
Date: 6 Mar 2002 16:51:22
Message: <3c868f5a$1@news.povray.org>
Apache <apa### [at] yahoocom> wrote in message
news:3c868ca3$1@news.povray.org...
> Don't think so. sqrt needs more cpu cycles. But maybe I'm wrong!

PoV's going to use square root anyway to find those lengths.
 -Shay


Post a reply to this message

From: Hugo
Subject: Re: Yeaah! I got it to work!!
Date: 6 Mar 2002 16:57:51
Message: <3c8690df$1@news.povray.org>
>>> universal formula for area of triangle:
>>> S=sqrt(p*(p-a)*(p-b)*(p-c))

>> Is that faster than using half the cross product of two of the sides?
>> Something like:
>> area = vlength(vcross(P1-P2,P3-P2))/2;

> Don't think so. sqrt needs more cpu cycles. But maybe I'm wrong!

Vlength uses sqrt internally. But the major slowdown is Povrays interpreter
and not the cpu.

Regards
Hugo


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Yeaah! I got it to work!!
Date: 6 Mar 2002 18:40:55
Message: <3C86A730.785EA5C1@hotmail.com>
Josh Seagoe wrote:
> 

> > universal formula for area of triangle:
> >
> > S=sqrt(p*(p-a)*(p-b)*(p-c))
> >
> > where a,b,c are lengths of edges and p is half of perimeter = (a+b+c)/2
> >
> 
> Is that faster than using half the cross product of two of the sides?
> (cosidering vcross is internal...)
> 
> Something like:
> area = vlength(vcross(P1-P2,P3-P2))/2;

I have not looked at their mesh code yet,
but I assume that they are calculating
the normal vectors for the triangles by
just taking the cross product of a pair
of each triangle's "edge vectors".

And if this is the case, then I don't see
the point in first calculating this cross
product, normalize it and then multiply
it by your area expression.

I.e.:

vnormalize(vcross(P1 - P2, P3 - P2))
*vlength(vcross(P1 - P2, P3 - P2))/2

They could just use the cross product
directly:

vcross(P1 - P2, P3 - P2)/2

And they don't even have to divide it
by 2 prior to the summing. Because
every triangle normal will be "double"
length.

The final normalizing of the sum of
all the "weighted" normal vectors will
eliminate it anyway.


Tor Olav


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: For Hugo. Irregular mesh smoothing idea.
Date: 6 Mar 2002 19:04:25
Message: <3C86ACB1.FF58C201@hotmail.com>

> 
> On Tue, 5 Mar 2002 09:12:47 -0600, "Shay" <sah### [at] simcopartscom> wrote:
> > The weighted normals look better. Is this the case with every mesh?
> 
> This is just more accurate method of averaging.
> 
> > This goes against everything I have seen concerning mesh normals.
> 
> Not exactly. Weighting is just longer and result is visible when there are
> differences in triangle area.
> 
> > By a weighted average, do you mean simply not normalizing the normal of each
> > triangle?
> 
> Considering you have N triangles with vertex P:
> - take all N normals as previously
> - normalize them as previously
> - new step: multiply/adjust according to area of triangle
> - add all N normals as previously
> - normalize this sum as previously (I'm not sure it is necessary)
> 
> So only new thing is muliplying. This is done to save larger triangles more
> float.

Wlodek,
if the triangle normals are calculated
with cross products, then step 2 and 3
above are not necessary.

Also see my reply in this thread to Josh
Seagoe some minutes ago:

http://news.povray.org/%3C3C86A730.785EA5C1%40hotmail.com%3E
news://news.povray.org/3C86A730.785EA5C1%40hotmail.com


Tor Olav


Post a reply to this message

From:
Subject: Re: For Hugo. Irregular mesh smoothing idea.
Date: 7 Mar 2002 02:43:31
Message: <7c6e8u88j07g71u11aci5g14l4avb92vbo@4ax.com>
On Thu, 07 Mar 2002 00:56:33 +0100, Tor Olav Kristensen
<tor### [at] hotmailcom> wrote:
> Wlodek,
> if the triangle normals are calculated
> with cross products, then step 2 and 3
> above are not necessary.

I feeled this...

ABX


Post a reply to this message

From:
Subject: Re: Does this look right to you, ABX?
Date: 7 Mar 2002 02:57:04
Message: <t47e8ugr5d8n0bucu9tu5la1fsrgbc4mel@4ax.com>
On Wed, 6 Mar 2002 12:45:09 -0600, "Shay" <sah### [at] simcopartscom> wrote:
> > #local triangle_area_engine=function{(x+y+z)*(y+z-x)*(x+y-z)*(x+z-y)/16}
> > #local triangle_area=
> >   function(x1,y1,z1,x2,y2,z2,x3,y3,z3)
> >     {sqrt(triangle_area_engine(
> >         f_r(x2-x1,y2-y1,z2-z1),
> >         f_r(x3-x2,y3-y2,z3-z2),
> >         f_r(x3-x1,y3-y1,z3-z1)
> >     ))};
>
> #include "functions.inc"
> #local triangle_area_engine=function{(x+y+z)*(y+z-x)*(x+y-z)*(x+z-y)/16}
> #local Triangle_Area =  triangle_area_engine(Side_1_Length, Side_2_Length,
Side_3_Length);
>
> Seems right to me, but I might be missing something.

You forgot about sqrt applied but since others mentioned that not normalized
cross product is sufficient then I think my method is wasting of pov-time ;-)

ABX


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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