POV-Ray : Newsgroups : povray.newusers : Mesh and polygons area Server Time
29 Jul 2024 00:31:22 EDT (-0400)
  Mesh and polygons area (Message 4 to 13 of 23)  
<<< Previous 3 Messages Goto Latest 10 Messages Next 10 Messages >>>
From: alphaQuad
Subject: Re: Mesh and polygons area
Date: 2 Nov 2007 22:00:01
Message: <web.472be3b8881ace7c3bb21de50@news.povray.org>
"Penelope20k" <pen### [at] caramailfr> wrote:
> Assuming that with a polygone you must know each points coordinates
> then the area of triangle is
>
> Area = abs(   (xB*yA - xA*yB)  + (xC*yB -x B*yC)+( xA*yC - xC*yA ) ) /2
>
>

> > Mesh are 3D by nature, you're stuck to the triangle per triangle
> > solution, IMHO.


what is that "triangle per triangle" method. Not that I can imagine a need for
the area of a polyhedron.




As for Penelope's 2D function, I get frustrated because triangles can be defined
in 3D space and 2D is almost useless. Hence I tried to simply mentally
extrapolate to 3D and failed.

If you can, post it. When you give up, scroll down. There are 2 methods compared
to functions in triangulation.inc. (tested in script of course)


  ; abs((xB*yA - xA*yB)  + (xC*yB -xB*yC)+( xA*yC - xC*yA)) / 2
  ; extrapolate to 3D ???!!???














































alias pntarea {
  ; return $sss-area($vlen($subv($1,$2)), $vlen($subv($2,$3)),
$vlen($subv($3,$1))) = 13405.000015
  ; return $sss-area2(279.72843974111748, 183.3712082089225, 156.24659996300718)
= 13405.000127

  tokenize 32 $1-
  ; = 9 to 3 lens
  var %a = $sqrt($calc((($1 - $4) ^ 2) + (($2 - $5) ^ 2) + (($3 - $6) ^ 2)))
  var %b = $sqrt($calc((($7 - $4) ^ 2) + (($8 - $5) ^ 2) + (($9 - $6) ^ 2)))
  var %c = $sqrt($calc((($1 - $7) ^ 2) + (($2 - $8) ^ 2) + (($3 - $9) ^ 2)))

  var %s = $calc(0.5 * (%a + %b + %c))
  ; return $sqrt($calc(%s * (%s - %a) * (%s - %b) * (%s - %c)))
  ; $pntarea(383 156 0, 645 254 0, 465 289 0) = 13404.999966

  return $calc(0.5 * (%a + %b + %c) * $&
    $calc($sqrt($calc(((%b + %c - %a) * (%c + %a - %b) * (%a + %b - %c)) / (%a +
%b + %c)))) / 2)
  ; = 13404.999974

  ; 2D
  return $calc($abs($calc(($4 * $2 - $1 * $5) + ($7 * $5 - $4* $8) + ($1 * $8 -
$7 * $2))) / 2)
  ; $pntarea(383 156 0, 645 254 0, 465 289 0) = 13405
  ; abs((xB*yA - xA*yB)  + (xC*yB -xB*yC)+( xA*yC - xC*yA)) / 2

}


Post a reply to this message

From: alphaQuad
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 00:15:00
Message: <web.472c036d881ace7c3bb21de50@news.povray.org>
seems in my search I use 'area' as opposed to 'volume', doh.


http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/volume.html


Post a reply to this message

From: alphaQuad
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 00:30:00
Message: <web.472c065d881ace7c3bb21de50@news.povray.org>
"alphaQuad" <alp### [at] earthlinknet> wrote:
> seems in my search I use 'area' as opposed to 'volume', doh.
>
>
> http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/volume.html

and that guy is bonkers or what???

" The volume of the pyramid is the area of the base polygon times the distance
from the base plane to the origin. Either of these might be negative."

AND

"Be careful of signs since some tetrahedra should have negative volumes"


a negative volume to me would mean an error!



The Volume of pyramid is [area of the pyramid's base] X [height] X
[1/3], and is expressed in cubic units.
from: [http://www.aaamath.com/B/geo79_x6.htm]



SHEESH


Post a reply to this message

From: alphaQuad
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 01:20:01
Message: <web.472c11c0881ace7c3bb21de50@news.povray.org>
"alphaQuad" <alp### [at] earthlinknet> wrote:

> The Volume of pyramid is [area of the pyramid's base] X [height] X
> [1/3], and is expressed in cubic units.
> from: [http://www.aaamath.com/B/geo79_x6.htm]

also given 4 3d points, volume of the tetrahedron =


This can be rewritten as a dot and cross product, yielding

    V = \frac { |(\mathbf{d}-\mathbf{a}) \cdot
((\mathbf{d}-\mathbf{b}) \times (\mathbf{d}-\mathbf{c}))| } {6}.
http://en.wikipedia.org/wiki/Tetrahedron


OMG LOL!!!!!!!

tested
alias pyramid_area {
  ; (4 3d pnts)
  return $calc($abs($dotprod($subv($4,$1), $&
         $cross($subv($4,$2), $subv($4,$3)))) / 6)
}


POV
#macro pyramid_area(A,B,C,D)
  vdot(D-A,vcross(D-B,D-C)) / 6
#end


Post a reply to this message

From: alphaQuad
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 01:25:00
Message: <web.472c1324881ace7c3bb21de50@news.povray.org>
#macro pyramid_area(A,B,C,D)
#local #result = abs(vdot(D-A,vcross(D-B,D-C))) / 6
  result
#end

ooops


Post a reply to this message

From: alphaQuad
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 01:25:00
Message: <web.472c1429881ace7c3bb21de50@news.povray.org>
#macro pyramid_volume(A,B,C,D)
  abs(vdot(D-A,vcross(D-B,D-C))) / 6
#end



sheesh brain fried, see you guys after a month in aruba


Post a reply to this message

From: Le Forgeron
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 02:04:18
Message: <472c1d72$1@news.povray.org>
Le 03.11.2007 03:58, alphaQuad nous fit lire :
> "Penelope20k" <pen### [at] caramailfr> wrote:
>> Assuming that with a polygone you must know each points coordinates
>> then the area of triangle is
>>
>> Area = abs(   (xB*yA - xA*yB)  + (xC*yB -x B*yC)+( xA*yC - xC*yA ) ) /2
>>
>>

>>> Mesh are 3D by nature, you're stuck to the triangle per triangle
>>> solution, IMHO.
> 
> 
> what is that "triangle per triangle" method. Not that I can imagine a need for
> the area of a polyhedron.
> 

A mesh is just a collection of triangles, and you cannot assert any
properties for the mesh.
(they are not in the same plane, share no common edges... )
Therefore, you have to parse the whole mesh, one triangle at a time,
triangle after triangle!

> 
> 
> As for Penelope's 2D function, I get frustrated because triangles can be defined
> in 3D space and 2D is almost useless. Hence I tried to simply mentally
> extrapolate to 3D and failed.

That formula works (???) only in the plane of the triangle. A
triangle is always 2D.
back to the origin of that formula:
For an ABC triangle, the area is half the length of the cross
product of any two vectors of the triangle from the same origin.

area = | AB x AC | /2 = | BA x BC | /2 = | CA x CB | / 2
with | x | being length of vector x (not abs()!!!), and every AB a
vector.

Therefore the previous formula of penelope2k seems a bit wrong about
the computation...
because the distance we are interested in is only the euclidian
(slow) one!
(square root of the sum of the squared delta)
-- 
The superior man understands what is right;
the inferior man understands what will sell.
-- Confucius


Post a reply to this message

From: Francesco
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 03:15:00
Message: <web.472c2d15881ace7c73fa22050@news.povray.org>
Thanks a lot for the assistance to everybody.

> "Penelope20k" <pen### [at] caramailfr> wrote:
> >> the area of triangle is
> >> Area = abs(   (xB*yA - xA*yB)  + (xC*yB -x B*yC)+( xA*yC - xC*yA ) ) /2

> >>>> "Le Forgeron" <jgr### [at] freefr>
> > Mesh...are not in the same plane, share no common edges... )

Don't they share edges? Ok, they are not in the same plane but they share at
least one edge, or not?

>> That formula works (???) only in the plane of the triangle. A
>> triangle is always 2D.....
>> the previous formula of penelope2k seems a bit wrong about
>> the computation...

Calculating area triangle per triangle I can always suppose z=0 (translating and
rotating axis) as triangles are 2D. So I think the formula posted by Penelope20k
is good.


Francesco


Post a reply to this message

From: Francesco
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 04:25:00
Message: <web.472c3dfb881ace7c73fa22050@news.povray.org>
"Francesco" <nas### [at] gmailcom> wrote:
>
> Calculating area triangle per triangle I can always suppose z=0 (translating
> and rotating axis) as triangles are 2D. So I think the formula posted by >
> Penelope20k is good.
>

If I rotate axis the coordinates are different, so I am really confused : ))

May be I could also use Eron's formula, Area= sqrt (s(s-a)(s-b)(s-c)).


Post a reply to this message

From: Le Forgeron
Subject: Re: Mesh and polygons area
Date: 3 Nov 2007 05:27:20
Message: <472c4d08$1@news.povray.org>
Le 03.11.2007 10:23, Francesco nous fit lire :
> "Francesco" <nas### [at] gmailcom> wrote:
>> Calculating area triangle per triangle I can always suppose z=0 (translating
>> and rotating axis) as triangles are 2D. So I think the formula posted by >
>> Penelope20k is good.
>>
> 
> If I rotate axis the coordinates are different, so I am really confused : ))

Illumination is on its way... continue.

> 
> May be I could also use Eron's formula, Area= sqrt (s(s-a)(s-b)(s-c)).
> 
It's Heron... and why do you want to compute the length of the side,
when all you need from the 3 vertices are their coordinaates.
Heron's formula is fine when you only have the lengths.

Actually, from a mesh's triangle:

On one hand, two vectors differences, a cross product, three
squaring, a sum and a square root ending with a division.

On the other end, three vectors differences, nine squaring, three
sums, three square root, an intermediate variable (yet a sum and a
division), then three differences, a product of four element, and a
square root.

Of course, you can use Area = 1/4*sqrt( (a+b+c)(a+b-c)(b+c-a)(c+b-a) )
this will avoid the intermediate variable, but the costy part is
computing the length a, b and c anyway!

-- 
The superior man understands what is right;
the inferior man understands what will sell.
-- Confucius


Post a reply to this message

<<< Previous 3 Messages Goto Latest 10 Messages Next 10 Messages >>>

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