MathCommon.cpp File Reference

Implements common/useful functions. More...

#include <assert.h>
#include <ctime>
#include <SDL_opengl.h>
#include "Math/MathCommon.h"
#include "Common/Globals.h"

Functions

float ClosestPoints (const Line &l1, const Line &l2, Point2f &out1, Point2f &out2)
 Computes the closest points between the two given lines.
int Intersect (const Ray &r, const Circle &c, float &t1, float &t2)
 Intersects a Ray with a Circle and finds the enter and exit time.
int Intersect (const Line &l, const Circle &c, float &t1, float &t2)
 Intersects a Line with a Circle and finds the enter and exit time.
Point2f ScreenToNormCoords (const Point2f &p)
 Converts a point in absolute Screen coordinates to normalized device coordinates.
Point2f NormToScreenCoords (const Point2f &p)
 Converts a point in normalized device coordinates to absolute Screen coordinates.
uint TimeSeed ()
 Computes a pretty good seed for a random number generator using the system time.

Detailed Description

Implements common/useful functions.

Author:
Joe Forte
Date:
3/27/2008

Function Documentation

float ClosestPoints ( const Line l1,
const Line l2,
Point2f out1,
Point2f out2 
)

Computes the closest points between the two given lines.

Parameters:
[in] l1 the first line.
[in] l2 the second line.
[out] out1 the closest point on the first line.
[out] out2 the closest point on the second line.
Returns:
The distance between out1 and out2.

pg 149

int Intersect ( const Line l,
const Circle &  c,
float &  t1,
float &  t2 
)

Intersects a Line with a Circle and finds the enter and exit time.

Parameters:
[in] l the Line.
[in] c the circle.
[out] t1 the time the Line l enters the Circle c.
[out] t2 the time the Line l exits the Circle c.
Returns:
The number of intersections the Line l has with the Circle c. If 0 is returned there where was no intersection. If 1 is returned then there was one intersection and t1 holds the time. If 2 is returned then there were two intersections and the times are in t1 and t2 where t1 < t2.
int Intersect ( const Ray r,
const Circle &  c,
float &  t1,
float &  t2 
)

Intersects a Ray with a Circle and finds the enter and exit time.

Parameters:
[in] r the Ray.
[in] c the circle.
[out] t1 the time the Ray r enters the Circle c.
[out] t2 the time the Ray r exits the Circle c.
Returns:
The number of intersections the Ray r has with the Circle c. If 0 is returned there where was no intersection. If 1 is returned then there was one intersection and t1 holds the time. If 2 is returned then there were two intersections and the times are in t1 and t2 where t1 < t2.

pg 178

Point2f NormToScreenCoords ( const Point2f p  ) 

Converts a point in normalized device coordinates to absolute Screen coordinates.

Parameters:
[in] p the point to convert.
See also:
ScreenToNormCoords
Returns:
The point p in absolute Screen coordinates.
Point2f ScreenToNormCoords ( const Point2f p  ) 

Converts a point in absolute Screen coordinates to normalized device coordinates.

Parameters:
[in] p the point to convert.
See also:
NormToScreenCoords
Returns:
The point p in normalized device coordinates.
uint TimeSeed (  ) 

Computes a pretty good seed for a random number generator using the system time.

Returns:
A seed value.
Generated on Mon Apr 5 19:08:04 2010 for BrickOut |ReDuX| by  doxygen 1.6.3