![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Apache <apa### [at] yahoo com> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
>>> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
>
> On Tue, 5 Mar 2002 09:12:47 -0600, "Shay" <sah### [at] simcoparts com> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Thu, 07 Mar 2002 00:56:33 +0100, Tor Olav Kristensen
<tor### [at] hotmail com> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
On Wed, 6 Mar 2002 12:45:09 -0600, "Shay" <sah### [at] simcoparts com> 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
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |