Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96627979
inside.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, 05:10
Size
1 KB
Mime Type
text/x-c
Expires
Tue, Dec 31, 05:10 (2 d)
Engine
blob
Format
Raw Data
Handle
23219030
Attached To
R1448 Lenstool-HPC
inside.c
View Options
#include<stdio.h>
#include<math.h>
#include<fonction.h>
#include<constant.h>
#include<dimension.h>
#include<structure.h>
/****************************************************************/
/* nom: inside */
/* auteur: Jean-Paul Kneib */
/* date: 10/02/92 */
/* place: Toulouse */
/****************************************************************
* Return 1 if P is inside the triangle T, 0 otherwise.
* Parameters :
* - P : a point
* - T : a triplet of points.
*/
int inside(struct point *P, struct triplet *T)
{
double s, s1, s2, d;
d = determinant(&T->a, &T->b, &T->c);
s = determinant(&T->a, &T->b, P) * d;
s1 = determinant(&T->b, &T->c, P) * d;
s2 = determinant(&T->c, &T->a, P) * d;
return((s > 0.) && (s1 > 0.) && (s2 > 0.));
}
/****************************************************************
* Return 1 if P is inside the triangle T or on its border, 0 otherwise.
* Parameters :
* - P : a point
* - T : a triplet of points.
*/
int insidebord(struct point *P, struct triplet *T)
{
double s, s1, s2, d;
d = determinant(&T->a, &T->b, &T->c);
s = determinant(&T->a, &T->b, P) * d;
s1 = determinant(&T->b, &T->c, P) * d;
s2 = determinant(&T->c, &T->a, P) * d;
return((s >= 0.) && (s1 >= 0.) && (s2 >= 0.));
}
Event Timeline
Log In to Comment