qaf::Geom Class Reference

#include <qafGeom.h>

List of all members.


Detailed Description

Provides static methods for useful geometric operations.


Static Public Member Functions

static bool segmentIntersection (float s1x1, float s1y1, float s1x2, float s1y2, float s2x1, float s2y1, float s2x2, float s2y2, Vector2D *point=NULL)
 Tests for segment intersection.
static int segmentCircleIntersection (float xCenter, float yCenter, float radius, float x1, float y1, float x2, float y2, Vector2D *pvIntPoint1=NULL, Vector2D *pvIntPoint2=NULL)
 Tests if a segment is intersecting a circle.
static void renderCircle (float xCenter, float yCenter, float radius, unsigned int color)
 Renders a circle as a series of lines.
static float invSqrt (float x)
 The infamous "fast inverse square root" function.
static void clipPolygon (Container< Vector2D > *poly, const Vector2D &planeP, const Vector2D &planeN)
 Clips the polygon so it will be contained within a semiplane.
static bool insidePolygon (const Vector2D &p, const Vector2D *points, int nPoints)
 Given the polygon described by points, returns true if the point p lies inside it.
static bool insidePolygon (const Vector2D &p, const Container< Vector2D > &points)
 Given the polygon described by points, returns true if the point p lies inside it.
static void renderPolygon (const Vector2D *points, int nPoints, float translateX, float translateY, unsigned long color)
 Renders the specified polygon as a set of lines in the specified color, translated as requested.
static void renderPolygon (const Container< Vector2D > &points, float translateX, float translateY, unsigned long color)
 Renders the specified polygon as a set of lines in the specified color, translated as requested.


Member Function Documentation

static bool qaf::Geom::segmentIntersection ( float  s1x1,
float  s1y1,
float  s1x2,
float  s1y2,
float  s2x1,
float  s2y1,
float  s2x2,
float  s2y2,
Vector2D point = NULL 
) [static]

Tests for segment intersection.

Stores the intersection point, if any, in the "point" vector, if it is not NULL.

Based on the algorithms seen here: http://www.geometryalgorithms.com/Archive/algorithm_0108/algorithm_0108.htm

Returns:
true if the two segments intersect each other

static bool qaf::Geom::insidePolygon ( const Vector2D p,
const Vector2D points,
int  nPoints 
) [static]

Given the polygon described by points, returns true if the point p lies inside it.

Based on the code seen here: http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/

static bool qaf::Geom::insidePolygon ( const Vector2D p,
const Container< Vector2D > &  points 
) [inline, static]

Given the polygon described by points, returns true if the point p lies inside it.

Based on the code seen here: http://astronomy.swin.edu.au/~pbourke/geometry/insidepoly/

static int qaf::Geom::segmentCircleIntersection ( float  xCenter,
float  yCenter,
float  radius,
float  x1,
float  y1,
float  x2,
float  y2,
Vector2D pvIntPoint1 = NULL,
Vector2D pvIntPoint2 = NULL 
) [static]

Tests if a segment is intersecting a circle.

This will not detect a collision if the segment is completely contained in the circle.

There are three possible outcomes:

Parameters:
xCenter X coordinate of the circle's center.
yCenter Y coordinate of the circle's center.
radius Circle's radius.
x1 X coordinate of the segment's first point.
y1 Y coordinate of the segment's first point.
x2 X coordinate of the segment's second point.
y2 Y coordinate of the segment's second point.
pvIntPoint1 Return value of the first intersection point.
pvIntPoint2 Return value of the second intersection point.

static void qaf::Geom::renderCircle ( float  xCenter,
float  yCenter,
float  radius,
unsigned int  color 
) [static]

Renders a circle as a series of lines.

The method attempts to adapt the number of segments to the size of the circle so it will not appear too fragmented.

static void qaf::Geom::clipPolygon ( Container< Vector2D > *  poly,
const Vector2D planeP,
const Vector2D planeN 
) [static]

Clips the polygon so it will be contained within a semiplane.

Parameters:
poly The polygon to be clipped. The resulting (clipped) polygon will be stored here as well.
planeP A point determining the clipping plane's position.
planeD The clipping plane's normal, pointing towards the interior of the clipping region.


The documentation for this class was generated from the following file:
Generated on Sun Mar 25 12:32:14 2007 for Qaf Framework by  doxygen 1.5.1-p1