Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
06bbfcb4
"tutorials/models/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "4ae13bd270cdcc769f3ef36f4d48155d5c6f0423"
Commit
06bbfcb4
authored
May 28, 2018
by
Davis King
Browse files
Added polygon_area() to python API
parent
263e64dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
+34
-0
tools/python/src/vector.cpp
tools/python/src/vector.cpp
+34
-0
No files found.
tools/python/src/vector.cpp
View file @
06bbfcb4
...
@@ -376,6 +376,26 @@ ensures \n\
...
@@ -376,6 +376,26 @@ ensures \n\
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
double
py_polygon_area
(
const
std
::
vector
<
dpoint
>&
pts
)
{
return
polygon_area
(
pts
);
}
double
py_polygon_area2
(
const
py
::
list
&
pts
)
{
std
::
vector
<
dpoint
>
temp
(
len
(
pts
));
for
(
size_t
i
=
0
;
i
<
temp
.
size
();
++
i
)
temp
[
i
]
=
pts
[
i
].
cast
<
dpoint
>
();
return
polygon_area
(
temp
);
}
// ----------------------------------------------------------------------------------------
void
bind_vector
(
py
::
module
&
m
)
void
bind_vector
(
py
::
module
&
m
)
{
{
{
{
...
@@ -463,5 +483,19 @@ void bind_vector(py::module& m)
...
@@ -463,5 +483,19 @@ void bind_vector(py::module& m)
register_point_transform_projective
(
m
);
register_point_transform_projective
(
m
);
m
.
def
(
"polygon_area"
,
&
py_polygon_area
,
py
::
arg
(
"pts"
));
m
.
def
(
"polygon_area"
,
&
py_polygon_area2
,
py
::
arg
(
"pts"
),
"ensures
\n
\
- If you walk the points pts in order to make a closed polygon, what is its
\n
\
area? This function returns that area. It uses the shoelace formula to
\n
\
compute the result and so works for general non-self-intersecting polygons."
/*!
ensures
- If you walk the points pts in order to make a closed polygon, what is its
area? This function returns that area. It uses the shoelace formula to
compute the result and so works for general non-self-intersecting polygons.
!*/
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment