Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96640627
inconvexe.c
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
Sun, Dec 29, 09:21
Size
840 B
Mime Type
text/x-c
Expires
Tue, Dec 31, 09:21 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
23218798
Attached To
R1448 Lenstool-HPC
inconvexe.c
View Options
#include <grille.h>
/*
* Parameters :
* - P point that is inside or outside the contour
* - np number of points of the contour
* - I[NPOINTs] polygonal contour
*
* Return 1 if P is inside the contour, otherwise 0
*/
int
inconvexe
(
struct
point
P
,
int
np
,
struct
point
I
[
NPOINT
])
{
register
int
k
;
double
xi
,
xj
,
yi
,
yj
,
theta
=
0.
;
I
[
np
].
x
=
I
[
0
].
x
;
I
[
np
].
y
=
I
[
0
].
y
;
for
(
k
=
0
;
k
<
np
;
k
++
)
{
xi
=
I
[
k
].
x
-
P
.
x
;
xj
=
I
[
k
+
1
].
x
-
P
.
x
;
yi
=
I
[
k
].
y
-
P
.
y
;
yj
=
I
[
k
+
1
].
y
-
P
.
y
;
/* in a triangle OIJ, (OI,OJ)=atan(Det(OI,OJ)/Pscal(OI,OJ) */
theta
+=
atan2
((
xj
*
yi
-
xi
*
yj
),
(
xi
*
xj
+
yi
*
yj
));
};
if
(
fabs
(
theta
)
>
PI
)
/* if P is on the edge of the polygon theta=PI */
return
(
1
);
else
/*theta is close to 0*/
return
(
0
);
}
Event Timeline
Log In to Comment