POV-Ray : Newsgroups : povray.newusers : Mesh and polygons area Server Time
28 Jul 2024 16:29:05 EDT (-0400)
  Mesh and polygons area (Message 1 to 10 of 23)  
Goto Latest 10 Messages Next 10 Messages >>>
From: Francesco
Subject: Mesh and polygons area
Date: 1 Nov 2007 13:30:01
Message: <web.472a1a292946c4249c17b8500@news.povray.org>
I do not find how to measure area of mesh and polygons. I hope I do not have to
calculate it triangle by triangle. Anyone could help me please?


Post a reply to this message

From: Le Forgeron
Subject: Re: Mesh and polygons area
Date: 1 Nov 2007 14:13:08
Message: <472a2544@news.povray.org>
Le 01.11.2007 19:25, Francesco nous fit lire :
> I do not find how to measure area of mesh and polygons. I hope I do not have to
> calculate it triangle by triangle. Anyone could help me please?
> 
> 
Mesh are 3D by nature, you're stuck to the triangle per triangle
solution, IMHO.

Polygon are 2D, and there is a well-known shortcut for them, with an
evaluation on a grid (the finer the grid, the better the precision),
it's just that you have to count the number of intersections from
the grid inside the polygon.
Is it simpler for you ?

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


Post a reply to this message

From: Penelope20k
Subject: Re: Mesh and polygons area
Date: 2 Nov 2007 03:31:51
Message: <472ae077$1@news.povray.org>
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








news:472a2544@news.povray.org...
> Le 01.11.2007 19:25, Francesco nous fit lire :
> > I do not find how to measure area of mesh and polygons. I hope I do not
have to
> > calculate it triangle by triangle. Anyone could help me please?
> >
> >
> Mesh are 3D by nature, you're stuck to the triangle per triangle
> solution, IMHO.
>
> Polygon are 2D, and there is a well-known shortcut for them, with an
> evaluation on a grid (the finer the grid, the better the precision),
> it's just that you have to count the number of intersections from
> the grid inside the polygon.
> Is it simpler for you ?
>
> -- 
> The superior man understands what is right;
> the inferior man understands what will sell.
> -- Confucius


Post a reply to this message

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

Goto Latest 10 Messages Next 10 Messages >>>

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