|
 |
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
|
 |