/* automatically created by mc from ../git-pge/m2/interpen.def. */ #if !defined (_interpen_H) # define _interpen_H # ifdef __cplusplus extern "C" { # endif # if !defined (PROC_D) # define PROC_D typedef void (*PROC_t) (void); typedef struct { PROC_t proc; } PROC; # endif
# include "Gcoord.h" # include "Gsegment.h" # include "Ghistory.h" # if defined (_interpen_C) # define EXTERN # else # define EXTERN extern # endif typedef struct interpen_interCircle_r interpen_interCircle; struct interpen_interCircle_r { double radius; coord_Coord center; };
/* segmentCollide - returns TRUE if segment, a, overlaps with, b. If true is returned then collisionPoint will be set to the intersection point. */ EXTERN unsigned int interpen_segmentsCollide (segment_Segment a, segment_Segment b, coord_Coord *p, history_whereHit *at0, history_whereHit *at1, unsigned int *ptn0, unsigned int *ptn1);
/* circleCollide - return TRUE if circles, a, b, collide. */ EXTERN unsigned int interpen_circleCollide (interpen_interCircle a, interpen_interCircle b);
/* circleSegmentCollide - Pre-condition: interCirle, c, and Segment, s, are well formed. Post-condition: return TRUE if circle, c, collides with segment, s. If true is returned then the, point, on the line in deepest collision with the circle is filled in and likewise, at, is set to corner or edge. Indicating which part of the segment collides with the circle. ptn will be set to 0 if point1 of the segment collides with the circle. ptn will be set to 1 if point2 of the segment collides with the circle. */ EXTERN unsigned int interpen_circleSegmentCollide (interpen_interCircle c, segment_Segment s, coord_Coord *point, history_whereHit *at, unsigned int *ptn);
/* initCircle - create and return an interpen_interCircle structure. */ EXTERN interpen_interCircle interpen_initCircle (double radius, coord_Coord point); /* unitTest - run some basic unit tests for the module. */ EXTERN void interpen_unitTest (void); # ifdef __cplusplus } # endif # undef EXTERN #endif
$HOME/Sandpit/git-pge/c/interpen.c
unsigned int interpen_circleCollide (interpen_interCircle a, interpen_interCircle b) { double radiusSum; coord_Coord distance; radiusSum = a.radius+b.radius; distance = coord_subCoord (a.center, b.center); return (coord_lengthCoord (distance)) <= radiusSum; }
$HOME/Sandpit/git-pge/c/interpen.c
/* circlePointCollide - returns TRUE if circle, c, and point, p, collide. */ static unsigned int circlePointCollide (interpen_interCircle c, coord_Coord p) { coord_Coord distance; distance = coord_subCoord (c.center, p); return (coord_lengthCoord (distance)) <= c.radius; }
pge/c/Ginterpen.h
/* circleSegmentCollide - Pre-condition: interCirle, c, and Segment, s, are well formed. Post-condition: return TRUE if circle, c, collides with segment, s. If true is returned then the, point, on the line in deepest collision with the circle is filled in and likewise, at, is set to corner or edge. Indicating which part of the segment collides with the circle. ptn will be set to 0 if point1 of the segment collides with the circle. ptn will be set to 1 if point2 of the segment collides with the circle. */ EXTERN unsigned int interpen_circleSegmentCollide (interpen_interCircle c, segment_Segment s, coord_Coord *point, history_whereHit *at, unsigned int *ptn);
/* segmentCollide - returns TRUE if segment, a, overlaps with, b. If true is returned then, p, will be set to the intersection point. ata, atb determine where segment, a, and segment, b, hit (corner or edge). If ata == corner then ptna is either 0 or 1 representing the point which collided. Likewise if atb == corner then ptna is either 0 or 1 representing the point which collided. */ EXTERN unsigned int interpen_segmentsCollide (segment_Segment a, segment_Segment b, coord_Coord *p, history_whereHit *ata, history_whereHit *atb, unsigned int *ptna, unsigned int *ptnb);
This document was produced using groff-1.22.