Alpha Engine: AEMath.h File Reference

AlphaEngine

AEMath.h File Reference

Header file for the math library. More...

#include "AEVec2.h" #include "AEMtx33.h"
#include "AELineSegment2.h"
#include <float.h>
#include "math.h"

Go to the source code of this file.

Macros

#define AESinDeg(x)   AESin(AEDegToRad(x))
 Macros for the trigo functions that take input in degree. More...
 
#define AECosDeg(x)   AECos(AEDegToRad(x))
 Macros for the trigo functions that take input in degree. More...
 
#define AETanDeg(x)   AETan(AEDegToRad(x))
 Macros for the trigo functions that take input in degree. More...
 
#define AEASinDeg(x)   AERadToDeg(AEASin(x))
 Macros for the trigo functions that take input in degree. More...
 
#define AEACosDeg(x)   AERadToDeg(AEACos(x))
 Macros for the trigo functions that take input in degree. More...
 
#define AEATanDeg(x)   AERadToDeg(AEATan(x))
 Macros for the trigo functions that take input in degree. More...
 

Functions

f32 AEDegToRad (f32 x)
 Convert an angle from Degree to Radians. More...
 
f32 AERadToDeg (f32 x)
 Convert an angle from Radians to Degree. More...
 
f32 AESin (f32 x)
 Calculate the Sine value of an angle. More...
 
f32 AECos (f32 x)
 Calculate the Cosine value of an angle. More...
 
f32 AETan (f32 x)
 Calculate the Tangent value of an angle. More...
 
f32 AEASin (f32 x)
 Calculate the ArcSine value of an angle. More...
 
f32 AEACos (f32 x)
 Calculate the ArcCosine value of an angle. More...
 
f32 AEATan (f32 x)
 Calculate the ArcTangent value of an angle. More...
 
u32 AEIsPowOf2 (u32 x)
 Check if x is a power of 2. More...
 
u32 AENextPowOf2 (u32 x)
 Calculate the next power of 2 that is greater than x. More...
 
u32 AELogBase2 (u32 x)
 Calculate the log2 of x. More...
 
f32 AEClamp (f32 X, f32 Min, f32 Max)
 Clamp x to between x0 and x1. More...
 
f32 AEWrap (f32 x, f32 x0, f32 x1)
 Wraparound for x with respect to range (x0 to x1). More...
 
f32 AEMin (f32 x, f32 y)
 Find which of the 2 value is lower. More...
 
f32 AEMax (f32 x, f32 y)
 Find which of the 2 value is higher. More...
 
s32 AEInRange (f32 x, f32 x0, f32 x1)
 Find if x is in the range (x0 to x1), inclusive. More...
 
f32 AECalcDistPointToCircle (AEVec2 *pPos, AEVec2 *pCtr, f32 radius)
 Calculate the shortest distance from a point to the edge of a circle. More...
 
f32 AECalcDistPointToRect (AEVec2 *pPos, AEVec2 *pRect, f32 sizeX, f32 sizeY)
 Calculate the shortest distance from a point to the edge of a rectangle. More...
 
f32 AECalcDistPointToLineSeg (AEVec2 *pPos, AEVec2 *pLine0, AEVec2 *pLine1)
 Calculate the shortest distance from a point to a line segment. More...
 
f32 AECalcDistPointToConvexPoly (AEVec2 *pPos, AEVec2 *pVtx, u32 vtxNum)
 Calculate the shortest distance from a point to the edge of a convex polygon. More...
 
f32 AECalcDistCircleToCircle (AEVec2 *pCtr0, f32 radius0, AEVec2 *pCtr1, f32 radius1)
 Calculate the shortest distance between the edges of two circles. More...
 
f32 AECalcDistCircleToRect (AEVec2 *pCtr, f32 radius, AEVec2 *pRect, f32 sizeX, f32 sizeY)
 Calculate the shortest distance between the edges of a circle and a rectangle. More...
 
f32 AECalcDistRectToRect (AEVec2 *pRect0, f32 sizeX0, f32 sizeY0, AEVec2 *pRect1, f32 sizeX1, f32 sizeY1, AEVec2 *pNormal)
 Calculate the shortest distance between the edges of two rectangles. More...
 
s32 AETestPointToCircle (AEVec2 *pPos, AEVec2 *pCtr, f32 radius)
 Test if a point is inside a circle. More...
 
s32 AETestPointToRect (AEVec2 *pPos, AEVec2 *pRect, f32 sizeX, f32 sizeY)
 Test if a point is inside a rectangle. More...
 
s32 AETestCircleToCircle (AEVec2 *pCtr0, f32 radius0, AEVec2 *pCtr1, f32 radius1)
 Test for collision between two circles. More...
 
s32 AETestCircleToRect (AEVec2 *pCtr, f32 radius, AEVec2 *pRect, f32 sizeX, f32 sizeY)
 Test for collision between a circle and a rectangle. More...
 
s32 AETestRectToRect (AEVec2 *pRect0, f32 sizeX0, f32 sizeY0, AEVec2 *pRect1, f32 sizeX1, f32 sizeY1)
 Test for collision between two rectangles. More...
 
f32 AEStaticPointToStaticLineSegment (AEVec2 *pPos, AELineSegment2 *pLine)
 Calculate the shortest distance from a point to a line. More...
 
f32 AEAnimatedPointToStaticLineSegment (AEVec2 *pStart, AEVec2 *pEnd, AELineSegment2 *pLine, AEVec2 *pInter)
 Calculate the collision between a moving point with a line. More...
 
f32 AEAnimatedCircleToStaticLineSegment (AEVec2 *pStart, AEVec2 *pEnd, f32 radius, AELineSegment2 *pLine, AEVec2 *pInter)
 Calculate the collision between a moving circle with a line. More...
 
f32 AEReflectAnimatedPointOnStaticLineSegment (AEVec2 *pStart, AEVec2 *pEnd, AELineSegment2 *pLine, AEVec2 *pInter, AEVec2 *pReflect)
 Calculate the collision between a moving point with a line and the reflected path of the point. More...
 
f32 AEReflectAnimatedCircleOnStaticLineSegment (AEVec2 *pStart, AEVec2 *pEnd, f32 radius, AELineSegment2 *pLine, AEVec2 *pInter, AEVec2 *pReflect)
 Calculate the collision between a moving circle with a line and the reflected path of the circle. More...
 
f32 AEAnimatedPointToStaticCircle (AEVec2 *pStart, AEVec2 *pEnd, AEVec2 *pCtr, f32 radius, AEVec2 *pInter)
 Calculate the collision between a moving point with a circle. More...
 
f32 AEReflectAnimatedPointOnStaticCircle (AEVec2 *pStart, AEVec2 *pEnd, AEVec2 *pCtr, f32 radius, AEVec2 *pInter, AEVec2 *pReflect)
 Calculate the collision between a moving point with a circle and the reflected path of the point. More...
 
f32 AEAnimatedCircleToStaticCircle (AEVec2 *pCtr0s, AEVec2 *pCtr0e, f32 radius0, AEVec2 *pCtr1, f32 radius1, AEVec2 *pInter)
 Calculate the collision between a moving circle with a static circle. More...
 
f32 AEReflectAnimatedCircleOnStaticCircle (AEVec2 *pCtr0s, AEVec2 *pCtr0e, f32 radius0, AEVec2 *pCtr1, f32 radius1, AEVec2 *pInter, AEVec2 *pReflect)
 Calculate the collision between a moving circle with a static circle and the reflected path of moving circle. More...
 

Detailed Description

Header file for the math library.

Project: Alpha Engine
Author
Sun Tjen Fam
Date
January 31, 2008
Copyright
Copyright (C) 2013 DigiPen Institute of Technology. Reproduction or disclosure of this file or its contents without the prior written consent of DigiPen Institute of Technology is prohibited.

Definition in file AEMath.h.

Macro Definition Documentation

#define AEACosDeg (   x)    AERadToDeg(AEACos(x))

Macros for the trigo functions that take input in degree.

Definition at line 169 of file AEMath.h.

#define AEASinDeg (   x)    AERadToDeg(AEASin(x))

Macros for the trigo functions that take input in degree.

Definition at line 168 of file AEMath.h.

#define AEATanDeg (   x)    AERadToDeg(AEATan(x))

Macros for the trigo functions that take input in degree.

Definition at line 170 of file AEMath.h.

#define AECosDeg (   x)    AECos(AEDegToRad(x))

Macros for the trigo functions that take input in degree.

Definition at line 166 of file AEMath.h.

#define AESinDeg (   x)    AESin(AEDegToRad(x))

Macros for the trigo functions that take input in degree.

Definition at line 165 of file AEMath.h.

#define AETanDeg (   x)    AETan(AEDegToRad(x))

Macros for the trigo functions that take input in degree.

Definition at line 167 of file AEMath.h.

Function Documentation

f32 AEACos ( f32  x)

Calculate the ArcCosine value of an angle.

Parameters
[in]xThe angle in Radians.
Return values
f32The value of acos(x).
f32 AEAnimatedCircleToStaticCircle ( AEVec2 pCtr0s,
AEVec2 pCtr0e,
f32  radius0,
AEVec2 pCtr1,
f32  radius1,
AEVec2 pInter 
)

Calculate the collision between a moving circle with a static circle.

Given the start position (pCtr0s) and end position (pCtr0e) of moving circle0 of size (radius0) and the center of static circle1 (pCtr1) of size (radius1), calculate the time and point of intersection.

Warning
Radius of circles should be a non-negative value.
Parameters
[in]pCtr0sPointer to AEVec2 containing start pos of circle0.
[in]pCtr0ePointer to AEVec2 containing end pos of the circle0.
[in]radius0The radius of circle0.
[in]pCtr1Pointer to AEVec2 containing the center of circle1.
[in]radius1The radius of the circle1.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AEAnimatedCircleToStaticLineSegment ( AEVec2 pStart,
AEVec2 pEnd,
f32  radius,
AELineSegment2 pLine,
AEVec2 pInter 
)

Calculate the collision between a moving circle with a line.

Given the start position (pStart) and end position (pEnd) of a moving circle of size (radius) and a line (pLine), calculate the time and point of intersection.

Warning
Line is assumed to stretch to infinity.
Radius of circle should be a non-negative value.
Parameters
[in]pStartPointer to AEVec2 containing start pos of the circle.
[in]pEndPointer to AEVec2 containing end pos of the circle.
[in]radiusThe radius of the circle.
[in]pLinePointer to AELineSegment2 containing the line.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AEAnimatedPointToStaticCircle ( AEVec2 pStart,
AEVec2 pEnd,
AEVec2 pCtr,
f32  radius,
AEVec2 pInter 
)

Calculate the collision between a moving point with a circle.

Given the start position (pStart) and end position (pEnd) of a moving point and the center of a circle (pCtr) of size (radius), calculate the time and point of intersection.

Warning
Radius of circle should be a non-negative value.
Parameters
[in]pStartPointer to AEVec2 containing start pos of the point.
[in]pEndPointer to AEVec2 containing end pos of the point.
[in]pCtrPointer to AEVec2 containing the center of the circle.
[in]radiusThe radius of the circle.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AEAnimatedPointToStaticLineSegment ( AEVec2 pStart,
AEVec2 pEnd,
AELineSegment2 pLine,
AEVec2 pInter 
)

Calculate the collision between a moving point with a line.

Given the start position (pStart) and end position (pEnd) of a moving point and a line (pLine), calculate the time and point of intersection.

Warning
Line is assumed to stretch to infinity.
Parameters
[in]pStartPointer to AEVec2 containing start pos of the point.
[in]pEndPointer to AEVec2 containing end pos of the point.
[in]pLinePointer to AELineSegment2 containing the line.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AEASin ( f32  x)

Calculate the ArcSine value of an angle.

Parameters
[in]xThe angle in Radians.
Return values
f32The value of asin(x).
f32 AEATan ( f32  x)

Calculate the ArcTangent value of an angle.

Parameters
[in]xThe angle in Radians.
Return values
f32The value of atan(x).
f32 AECalcDistCircleToCircle ( AEVec2 pCtr0,
f32  radius0,
AEVec2 pCtr1,
f32  radius1 
)

Calculate the shortest distance between the edges of two circles.

Given the center of circle0 (pCtr0) of size (radius0) and the center of circle1 (pCtr1) of size (radius1), calculate the shortest distance between their edges.

Warning
radius of circles should be a non-negative value.
Parameters
[in]pCtr0Pointer to AEVec2 containing the center of circle0.
[in]radius0The radius of circle0.
[in]pCtr1Pointer to AEVec2 containing the center of circle1.
[in]radius1The radius of circle1.
Return values
f32Returns the shortest distance between the edge of both circles. This value will be negative if the circles are overlapping.
f32 AECalcDistCircleToRect ( AEVec2 pCtr,
f32  radius,
AEVec2 pRect,
f32  sizeX,
f32  sizeY 
)

Calculate the shortest distance between the edges of a circle and a rectangle.

Given the center of a circle (pCtr) of size (radius) and the center of a rect (pRect) of width (sizeX) and height (sizeY), calculate the shortest distance between their edges.

Warning
radius of circles should be a non-negative value.
The width and height of the rect should be non-negative values.
Function will only work if the rect is not rotated, i.e. the sides of the rect are parallel to the axis.
Parameters
[in]pCtrPointer to AEVec2 containing the center of the circle.
[in]radiusThe radius of circle.
[in]pRectPointer to AEVec2 containing the center of the rect.
[in]sizeXThe width of the rect.
[in]sizeYThe height of the rect.
Return values
f32Returns the shortest distance between the edges of the circle and the rect. This value will be negative if the circle and rect are overlapping.
f32 AECalcDistPointToCircle ( AEVec2 pPos,
AEVec2 pCtr,
f32  radius 
)

Calculate the shortest distance from a point to the edge of a circle.

Given a point (pPos) and the center of a circle (pCtr) of size (radius), calculate the shortest distance from the point to the circumference of the circle.

Warning
Radius of circle should be a non-negative value.
Parameters
[in]pPosPointer to AEVec2 containing the positon of the point.
[in]pCtrPointer to AEVec2 containing the position of the center of the circle
[in]radiusThe radius of the circle.
Return values
f32Returns the shortest distance from the point to the edge of the circle. This value will be negative if the point is inside the circle.
f32 AECalcDistPointToConvexPoly ( AEVec2 pPos,
AEVec2 pVtx,
u32  vtxNum 
)

Calculate the shortest distance from a point to the edge of a convex polygon.

Given a point (pPos) and an array of vertices (pVtx) of size (vtxNum) making up a convex polygon, calculate the shortest distance from the point to the edge of the polygon.

Warning
Function not implemented. Do not use. Currently returns -1.0f.
Parameters
[in]pPosPointer to AEVec2 containing the position of the point.
[in]pVtxPointer to an array of AEVec2 containing the vertices of the polygon.
[in]vtxNumThe number of vertices in the polygon
Return values
f32Returns the shortest distance from the point to the edge of the polygon. This value will be negative if the point is inside the polygon.
f32 AECalcDistPointToLineSeg ( AEVec2 pPos,
AEVec2 pLine0,
AEVec2 pLine1 
)

Calculate the shortest distance from a point to a line segment.

Given a point (pPos) and start (pLine0) and end (pLine1) of a line segment, calculate the shortest distance from the point to the line segment.

Parameters
[in]pPosPointer to AEVec2 containing the position of the point.
[in]pLine0Pointer to AEVec2 containing the start of the line segment.
[in]pLine1Pointer to AEVec2 containing the end of the line segment.
Return values
f32Returns the shortest distance from the point to the line segment.
f32 AECalcDistPointToRect ( AEVec2 pPos,
AEVec2 pRect,
f32  sizeX,
f32  sizeY 
)

Calculate the shortest distance from a point to the edge of a rectangle.

Given a point (pPos) and the center of a rect (pRect) of width (sizeX) and height (sizeY), calculate the shortest distance from the point to the perimeter of the rect.

Warning
The width and height of the rect should be non-negative values.
Function will only work if the rect is not rotated, i.e. the sides of the rect are parallel to the axis.
Parameters
[in]pPosPointer to AEVec2 containing the position of the point.
[in]pRectPointer to AEVec2 containing the position of the center of the rect.
[in]sizeXWidth of the rect, i.e. the size of the rect along the x-axis.
[in]sizeYHeight of the rect, i.e. the size of the rect along the y-axis.
Return values
f32Returns the shortest distance from the point to the edge of the rect. This value will be negative if the point is inside the rect.
f32 AECalcDistRectToRect ( AEVec2 pRect0,
f32  sizeX0,
f32  sizeY0,
AEVec2 pRect1,
f32  sizeX1,
f32  sizeY1,
AEVec2 pNormal 
)

Calculate the shortest distance between the edges of two rectangles.

Given the center of rect0 (pRect0) of width (sizeX0) and height (sizeY0) and the center of rect1 (pRect1) of width (sizeX1) and height (sizeY1), calculate the shortest distance between their edges.

Warning
The width and height of the rect should be non-negative values.
Function will only work if the rect is not rotated, i.e. the sides of the rect are parallel to the axis.
Parameters
[in]pRect0Pointer to AEVec2 containing the center of rect0.
[in]sizeX0The width of rect0.
[in]sizeY0The height of rect0.
[in]pRect1Pointer to AEVec2 containing the center of rect1.
[in]sizeX1The width of rect1.
[in]sizeY1The height of rect1.
[out]pNormalPointer to AEVec2 where the direction from rect1 to rect0 is stored. May be left null if not needed.
Return values
f32Returns the shortest distance between the edges of both rects. This value will be negative if they are overlapping.
f32 AEClamp ( f32  x,
f32  x0,
f32  x1 
)

Clamp x to between x0 and x1.

If x is lower than the minimum value (x0), return x0. If x is higher than the maximum value (x1), return x1. Else return x.

Parameters
[in]xThe input value.
[in]x0The minimum value.
[in]x1The maximum value.
Return values
f32The clamped value of x.
f32 AECos ( f32  x)

Calculate the Cosine value of an angle.

Parameters
[in]xThe angle in Radians.
Return values
f32The value of cos(x).
f32 AEDegToRad ( f32  x)

Convert an angle from Degree to Radians.

Parameters
[in]xThe angle in Degree to be converted.
Return values
f32The angle in Radians after conversion.
s32 AEInRange ( f32  x,
f32  x0,
f32  x1 
)

Find if x is in the range (x0 to x1), inclusive.

If x is more than or equal to x0 OR If x is less than or equal to x1, return true. Else return false.

Parameters
[in]xThe input value.
[in]x0The lower bound of range.
[in]x1The upper bound of range.
Return values
s32Returns true if x is between x0 and x1, inclusive. Else return false.
u32 AEIsPowOf2 ( u32  x)

Check if x is a power of 2.

Powers of 2 are values which can be presented as 2 ^ N, where N is any non-negative integer. Examples of powers of 2 are:

  • 1 (2 ^ 0)
  • 2 (2 ^ 1)
  • 4 (2 ^ 2)
  • 256 (2 ^ 8)
  • 1024 (2 ^ 10)
Parameters
[in]xThe value to be checked.
Return values
u32Returns true (non-zero value) if x is a power of 2. Else return false (zero).
u32 AELogBase2 ( u32  x)

Calculate the log2 of x.

Calculate the log2 of x, rounded to the lower integer.

Parameters
[in]xThe input value.
Return values
u32The log2 of x, rounded to lower integer.
f32 AEMax ( f32  x,
f32  y 
)

Find which of the 2 value is higher.

If x is higher than y, return x. If y is higher than x, return y.

Parameters
[in]xThe first input value.
[in]yThe second input value.
Return values
f32The higher of the 2 value.
f32 AEMin ( f32  x,
f32  y 
)

Find which of the 2 value is lower.

If x is lower than y, return x. If y is lower than x, return y.

Parameters
[in]xThe first input value.
[in]yThe second input value.
Return values
f32The lower of the 2 value.
u32 AENextPowOf2 ( u32  x)

Calculate the next power of 2 that is greater than x.

Powers of 2 are values which can be presented as 2 ^ N, where N is any non-negative integer. Examples of powers of 2 are:

  • 1 (2 ^ 0)
  • 2 (2 ^ 1)
  • 4 (2 ^ 2)
  • 256 (2 ^ 8)
  • 1024 (2 ^ 10)
Parameters
[in]xThe input value.
Return values
u32Returns the next power of 2 greater than x.
f32 AERadToDeg ( f32  x)

Convert an angle from Radians to Degree.

Parameters
[in]xThe angle in Radians to be converted.
Return values
f32The angle in Degree after conversion.
f32 AEReflectAnimatedCircleOnStaticCircle ( AEVec2 pCtr0s,
AEVec2 pCtr0e,
f32  radius0,
AEVec2 pCtr1,
f32  radius1,
AEVec2 pInter,
AEVec2 pReflect 
)

Calculate the collision between a moving circle with a static circle and the reflected path of moving circle.

Given the start position (pCtr0s) and end position (pCtr0e) of moving circle0 of size (radius0) and the center of static circle1 (pCtr1) of size (radius1), calculate the time, point of intersection and reflected path of circle0.

Warning
Radius of circles should be a non-negative value.
Parameters
[in]pCtr0sPointer to AEVec2 containing start pos of circle0.
[in]pCtr0ePointer to AEVec2 containing end pos of the circle0.
[in]radius0The radius of circle0.
[in]pCtr1Pointer to AEVec2 containing the center of circle1.
[in]radius1The radius of the circle1.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
[out]pReflectPointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AEReflectAnimatedCircleOnStaticLineSegment ( AEVec2 pStart,
AEVec2 pEnd,
f32  radius,
AELineSegment2 pLine,
AEVec2 pInter,
AEVec2 pReflect 
)

Calculate the collision between a moving circle with a line and the reflected path of the circle.

Given the start position (pStart) and end position (pEnd) of a moving circle of size (radius) and a line (pLine), calculate the time, point of intersection and reflected path.

Warning
Line is assumed to stretch to infinity.
Radius of circle should be a non-negative value.
Parameters
[in]pStartPointer to AEVec2 containing start pos of the circle.
[in]pEndPointer to AEVec2 containing end pos of the circle.
[in]radiusThe radius of the circle.
[in]pLinePointer to AELineSegment2 containing the line.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
[out]pReflectPointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AEReflectAnimatedPointOnStaticCircle ( AEVec2 pStart,
AEVec2 pEnd,
AEVec2 pCtr,
f32  radius,
AEVec2 pInter,
AEVec2 pReflect 
)

Calculate the collision between a moving point with a circle and the reflected path of the point.

Given the start position (pStart) and end position (pEnd) of a moving point and the center of a circle (pCtr) of size (radius), calculate the time, point of intersection and reflected path.

Warning
Radius of circle should be a non-negative value.
Parameters
[in]pStartPointer to AEVec2 containing start pos of the point.
[in]pEndPointer to AEVec2 containing end pos of the point.
[in]pCtrPointer to AEVec2 containing the center of the circle.
[in]radiusThe radius of the circle.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
[out]pReflectPointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AEReflectAnimatedPointOnStaticLineSegment ( AEVec2 pStart,
AEVec2 pEnd,
AELineSegment2 pLine,
AEVec2 pInter,
AEVec2 pReflect 
)

Calculate the collision between a moving point with a line and the reflected path of the point.

Given the start position (pStart) and end position (pEnd) of a moving point and a line (pLine), calculate the time, point of intersection and reflected path.

Warning
Line is assumed to stretch to infinity.
Parameters
[in]pStartPointer to AEVec2 containing start pos of the point.
[in]pEndPointer to AEVec2 containing end pos of the point.
[in]pLinePointer to AELineSegment2 containing the line.
[out]pInterPointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
[out]pReflectPointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
Return values
f32Returns the time of collision, if there is one. Else return -1.0f.
f32 AESin ( f32  x)

Calculate the Sine value of an angle.

Parameters
[in]xThe angle in Radians.
Return values
f32The value of sin(x).
f32 AEStaticPointToStaticLineSegment ( AEVec2 pPos,
AELineSegment2 pLine 
)

Calculate the shortest distance from a point to a line.

Given a point (pPos) and a line (pLine), calculate the shortest distance from the point to the line.

Warning
Line is assumed to stretch to infinity.
Parameters
[in]pPosPointer to AEVec2 containing the point.
[in]pLinePointer to AELineSegment2 containing the line.
Return values
f32Returns the distance from the point to the line. Negative if the point is in the line's inside half plane. Positive if the point is in the line's outside half plane. Otherwise zero if the point is on the line.
f32 AETan ( f32  x)

Calculate the Tangent value of an angle.

Parameters
[in]xThe angle in Radians.
Return values
f32The value of tan(x).
s32 AETestCircleToCircle ( AEVec2 pCtr0,
f32  radius0,
AEVec2 pCtr1,
f32  radius1 
)

Test for collision between two circles.

Given the center of circle0 (pCtr0) of size (radius0) and the center of circle1 (pCtr1) of size (radius1), check if they are colliding.

Warning
Radius of circle should be a non-negative value.
Parameters
[in]pCtr0Pointer to AEVec2 containing the center of circle0.
[in]radius0The radius of circle0.
[in]pCtr1Pointer to AEVec2 containing the center of circle1.
[in]radius1The radius of circle1.
Return values
s32Returns true if the circles are colliding. Else return false.
s32 AETestCircleToRect ( AEVec2 pCtr,
f32  radius,
AEVec2 pRect,
f32  sizeX,
f32  sizeY 
)

Test for collision between a circle and a rectangle.

Given the center of a circle (pCtr) of size (radius) and the center of a rect (pRect) of width (sizeX) and height (sizeY), check if they are colliding.

Warning
radius of circles should be a non-negative value.
The width and height of the rect should be non-negative values.
Function will only work if the rect is not rotated, i.e. the sides of the rect are parallel to the axis.
Parameters
[in]pCtrPointer to AEVec2 containing the center of the circle.
[in]radiusThe radius of circle.
[in]pRectPointer to AEVec2 containing the center of the rect.
[in]sizeXThe width of the rect.
[in]sizeYThe height of the rect.
Return values
s32Returns true if the circle and the rect are colliding. Else return false.
s32 AETestPointToCircle ( AEVec2 pPos,
AEVec2 pCtr,
f32  radius 
)

Test if a point is inside a circle.

Given a point (pPos) and the center of a circle (pCtr) of size (radius), check if the point is in the circle.

Warning
Radius of circle should be a non-negative value.
Parameters
[in]pPosPointer to AEVec2 containing the position of the point.
[in]pCtrPointer to AEVec2 containing the center of the circle.
[in]radiusThe radius of circle0.
Return values
s32Returns true if the point is inside the circle. Else return false.
s32 AETestPointToRect ( AEVec2 pPos,
AEVec2 pRect,
f32  sizeX,
f32  sizeY 
)

Test if a point is inside a rectangle.

Given a point (pPos) and the center of a rect (pRect) of width (sizeX) and height (sizeY), check if the point is in the rect.

Warning
The width and height of the rect should be non-negative values.
Function will only work if the rect is not rotated, i.e. the sides of the rect are parallel to the axis.
Parameters
[in]pPosPointer to AEVec2 containing the position of the point.
[in]pRectPointer to AEVec2 containing the center of the rect.
[in]sizeXThe width of the rect.
[in]sizeYThe height of the rect.
Return values
s32Returns true if the point is inside the rect. Else return false.
s32 AETestRectToRect ( AEVec2 pRect0,
f32  sizeX0,
f32  sizeY0,
AEVec2 pRect1,
f32  sizeX1,
f32  sizeY1 
)

Test for collision between two rectangles.

Given the center of rect0 (pRect0) of width (sizeX0) and height (sizeY0) and the center of rect1 (pRect1) of width (sizeX1) and height (sizeY1), check if they are colliding.

Warning
The width and height of the rect should be non-negative values.
Function will only work if the rect is not rotated, i.e. the sides of the rect are parallel to the axis.
Parameters
[in]pRect0Pointer to AEVec2 containing the center of rect0.
[in]sizeX0The width of rect0.
[in]sizeY0The height of rect0.
[in]pRect1Pointer to AEVec2 containing the center of rect1.
[in]sizeX1The width of rect1.
[in]sizeY1The height of rect1.
Return values
s32Returns true if the rects are colliding. Else return false.
f32 AEWrap ( f32  x,
f32  x0,
f32  x1 
)

Wraparound for x with respect to range (x0 to x1).

If x is lesser than x0, return (x + range). If x is higher than x1, return (x - range).

Warning
Wraparound does not work if x is lesser than (x0 - range) or if x is greater than (x1 + range).
Parameters
[in]xThe input value.
[in]x0The lower bound of range
[in]x1The upper bound of range.
Return values
f32The wraparound value of x with respect to range.
Generated on Sat Jan 4 2014 02:06:22 for Alpha Engine by   doxygen 1.8.5