Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90524644
area.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Nov 2, 11:31
Size
1 KB
Mime Type
text/x-python
Expires
Mon, Nov 4, 11:31 (2 d)
Engine
blob
Format
Raw Data
Handle
22092872
Attached To
rGEAR Gear
area.py
View Options
# http://fr.wikipedia.org/wiki/Aire_et_centre_de_masse_d%27un_polygone
# info pour le centre de masse
from
numpy
import
*
"""
3.37792690924
[[ 7.89272115e-02 3.56209427e-01 0.00000000e+00]
[ 7.86051601e-02 3.44835401e-01 0.00000000e+00]
[ -1.65303441e-04 2.60916293e-01 0.00000000e+00]
[ -3.71612213e-03 2.62126237e-01 0.00000000e+00]
[ -2.41694115e-02 3.86349469e-01 0.00000000e+00]]
0.333918269909
[[ 0.99983442 0.2609162 0. ]
[ 0.99628341 0.26212624 0. ]
[ 0.97583008 0.3863498 0. ]
[ 1.07892728 0.35620958 0. ]
[ 1.07860518 0.34483576 0. ]]
"""
pos
=
array
([[
7.89272115e-02
,
3.56209427e-01
,
0.00000000e+00
],
[
7.86051601e-02
,
3.44835401e-01
,
0.00000000e+00
],
[
-
1.65303441e-04
,
2.60916293e-01
,
0.00000000e+00
],
[
-
3.71612213e-03
,
2.62126237e-01
,
0.00000000e+00
],
[
-
2.41694115e-02
,
3.86349469e-01
,
0.00000000e+00
]])
'''
pos = array([[ 0.99983442, 0.2609162, 0. ],
[ 0.99628341, 0.26212624, 0. ],
[ 0.97583008, 0.3863498, 0. ],
[ 1.07892728, 0.35620958, 0. ],
[ 1.07860518, 0.34483576, 0. ]])
'''
print
pos
print
A
=
0
for
i
in
xrange
(
len
(
pos
)
-
1
):
pos1
=
pos
[
i
]
pos2
=
pos
[
i
+
1
]
x1
=
pos1
[
0
]
y1
=
pos1
[
1
]
x2
=
pos2
[
0
]
y2
=
pos2
[
1
]
print
x1
,
y1
print
x2
,
y2
A
=
A
+
(
x1
*
y2
-
x2
*
y1
)
# first again
pos1
=
pos
[
len
(
pos
)
-
1
]
pos2
=
pos
[
0
]
x1
=
pos1
[
0
]
y1
=
pos1
[
1
]
x2
=
pos2
[
0
]
y2
=
pos2
[
1
]
print
x1
,
y1
print
x2
,
y2
A
=
A
+
(
x1
*
y2
-
x2
*
y1
)
A
=
0.5
*
A
print
print
A
Event Timeline
Log In to Comment