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