Alpha Engine
|
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)) |
#define AEASinDeg | ( | x | ) | AERadToDeg(AEASin(x)) |
#define AEATanDeg | ( | x | ) | AERadToDeg(AEATan(x)) |
#define AECosDeg | ( | x | ) | AECos(AEDegToRad(x)) |
#define AESinDeg | ( | x | ) | AESin(AEDegToRad(x)) |
#define AETanDeg | ( | x | ) | AETan(AEDegToRad(x)) |
Function Documentation
Calculate the ArcCosine value of an angle.
- Parameters
-
[in] x The angle in Radians.
- Return values
-
f32 The 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] pCtr0s Pointer to AEVec2 containing start pos of circle0. [in] pCtr0e Pointer to AEVec2 containing end pos of the circle0. [in] radius0 The radius of circle0. [in] pCtr1 Pointer to AEVec2 containing the center of circle1. [in] radius1 The radius of the circle1. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
- Return values
-
f32 Returns 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] pStart Pointer to AEVec2 containing start pos of the circle. [in] pEnd Pointer to AEVec2 containing end pos of the circle. [in] radius The radius of the circle. [in] pLine Pointer to AELineSegment2 containing the line. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
- Return values
-
f32 Returns 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] pStart Pointer to AEVec2 containing start pos of the point. [in] pEnd Pointer to AEVec2 containing end pos of the point. [in] pCtr Pointer to AEVec2 containing the center of the circle. [in] radius The radius of the circle. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
- Return values
-
f32 Returns 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] pStart Pointer to AEVec2 containing start pos of the point. [in] pEnd Pointer to AEVec2 containing end pos of the point. [in] pLine Pointer to AELineSegment2 containing the line. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision.
- Return values
-
f32 Returns the time of collision, if there is one. Else return -1.0f.
Calculate the ArcSine value of an angle.
- Parameters
-
[in] x The angle in Radians.
- Return values
-
f32 The value of asin(x).
Calculate the ArcTangent value of an angle.
- Parameters
-
[in] x The angle in Radians.
- Return values
-
f32 The value of atan(x).
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] pCtr0 Pointer to AEVec2 containing the center of circle0. [in] radius0 The radius of circle0. [in] pCtr1 Pointer to AEVec2 containing the center of circle1. [in] radius1 The radius of circle1.
- Return values
-
f32 Returns the shortest distance between the edge of both circles. This value will be negative if the circles are overlapping.
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] pCtr Pointer to AEVec2 containing the center of the circle. [in] radius The radius of circle. [in] pRect Pointer to AEVec2 containing the center of the rect. [in] sizeX The width of the rect. [in] sizeY The height of the rect.
- Return values
-
f32 Returns the shortest distance between the edges of the circle and the rect. This value will be negative if the circle and rect are overlapping.
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] pPos Pointer to AEVec2 containing the positon of the point. [in] pCtr Pointer to AEVec2 containing the position of the center of the circle [in] radius The radius of the circle.
- Return values
-
f32 Returns the shortest distance from the point to the edge of the circle. This value will be negative if the point is inside the circle.
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] pPos Pointer to AEVec2 containing the position of the point. [in] pVtx Pointer to an array of AEVec2 containing the vertices of the polygon. [in] vtxNum The number of vertices in the polygon
- Return values
-
f32 Returns the shortest distance from the point to the edge of the polygon. This value will be negative if the point is inside the polygon.
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] pPos Pointer to AEVec2 containing the position of the point. [in] pLine0 Pointer to AEVec2 containing the start of the line segment. [in] pLine1 Pointer to AEVec2 containing the end of the line segment.
- Return values
-
f32 Returns the shortest distance from the point to the line segment.
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] pPos Pointer to AEVec2 containing the position of the point. [in] pRect Pointer to AEVec2 containing the position of the center of the rect. [in] sizeX Width of the rect, i.e. the size of the rect along the x-axis. [in] sizeY Height of the rect, i.e. the size of the rect along the y-axis.
- Return values
-
f32 Returns 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] pRect0 Pointer to AEVec2 containing the center of rect0. [in] sizeX0 The width of rect0. [in] sizeY0 The height of rect0. [in] pRect1 Pointer to AEVec2 containing the center of rect1. [in] sizeX1 The width of rect1. [in] sizeY1 The height of rect1. [out] pNormal Pointer to AEVec2 where the direction from rect1 to rect0 is stored. May be left null if not needed.
- Return values
-
f32 Returns the shortest distance between the edges of both rects. This value will be negative if they are overlapping.
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] x The input value. [in] x0 The minimum value. [in] x1 The maximum value.
- Return values
-
f32 The clamped value of x.
Calculate the Cosine value of an angle.
- Parameters
-
[in] x The angle in Radians.
- Return values
-
f32 The value of cos(x).
Convert an angle from Degree to Radians.
- Parameters
-
[in] x The angle in Degree to be converted.
- Return values
-
f32 The angle in Radians after conversion.
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] x The input value. [in] x0 The lower bound of range. [in] x1 The upper bound of range.
- Return values
-
s32 Returns true if x is between x0 and x1, inclusive. Else return false.
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] x The value to be checked.
- Return values
-
u32 Returns true (non-zero value) if x is a power of 2. Else return false (zero).
Calculate the log2 of x.
Calculate the log2 of x, rounded to the lower integer.
- Parameters
-
[in] x The input value.
- Return values
-
u32 The log2 of x, rounded to lower integer.
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] x The first input value. [in] y The second input value.
- Return values
-
f32 The higher of the 2 value.
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] x The first input value. [in] y The second input value.
- Return values
-
f32 The lower of the 2 value.
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] x The input value.
- Return values
-
u32 Returns the next power of 2 greater than x.
Convert an angle from Radians to Degree.
- Parameters
-
[in] x The angle in Radians to be converted.
- Return values
-
f32 The 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] pCtr0s Pointer to AEVec2 containing start pos of circle0. [in] pCtr0e Pointer to AEVec2 containing end pos of the circle0. [in] radius0 The radius of circle0. [in] pCtr1 Pointer to AEVec2 containing the center of circle1. [in] radius1 The radius of the circle1. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision. [out] pReflect Pointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
- Return values
-
f32 Returns 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] pStart Pointer to AEVec2 containing start pos of the circle. [in] pEnd Pointer to AEVec2 containing end pos of the circle. [in] radius The radius of the circle. [in] pLine Pointer to AELineSegment2 containing the line. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision. [out] pReflect Pointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
- Return values
-
f32 Returns 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] pStart Pointer to AEVec2 containing start pos of the point. [in] pEnd Pointer to AEVec2 containing end pos of the point. [in] pCtr Pointer to AEVec2 containing the center of the circle. [in] radius The radius of the circle. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision. [out] pReflect Pointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
- Return values
-
f32 Returns 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] pStart Pointer to AEVec2 containing start pos of the point. [in] pEnd Pointer to AEVec2 containing end pos of the point. [in] pLine Pointer to AELineSegment2 containing the line. [out] pInter Pointer to AEVec2 for storing the point of intersection. Will not be used if there is no collision. [out] pReflect Pointer to AEVec2 for storing the reflected path. Will not be used if there is no collision.
- Return values
-
f32 Returns the time of collision, if there is one. Else return -1.0f.
Calculate the Sine value of an angle.
- Parameters
-
[in] x The angle in Radians.
- Return values
-
f32 The 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] pPos Pointer to AEVec2 containing the point. [in] pLine Pointer to AELineSegment2 containing the line.
- Return values
-
f32 Returns 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.
Calculate the Tangent value of an angle.
- Parameters
-
[in] x The angle in Radians.
- Return values
-
f32 The value of tan(x).
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] pCtr0 Pointer to AEVec2 containing the center of circle0. [in] radius0 The radius of circle0. [in] pCtr1 Pointer to AEVec2 containing the center of circle1. [in] radius1 The radius of circle1.
- Return values
-
s32 Returns true if the circles are colliding. Else return false.
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] pCtr Pointer to AEVec2 containing the center of the circle. [in] radius The radius of circle. [in] pRect Pointer to AEVec2 containing the center of the rect. [in] sizeX The width of the rect. [in] sizeY The height of the rect.
- Return values
-
s32 Returns true if the circle and the rect are colliding. Else return false.
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] pPos Pointer to AEVec2 containing the position of the point. [in] pCtr Pointer to AEVec2 containing the center of the circle. [in] radius The radius of circle0.
- Return values
-
s32 Returns true if the point is inside the circle. Else return false.
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] pPos Pointer to AEVec2 containing the position of the point. [in] pRect Pointer to AEVec2 containing the center of the rect. [in] sizeX The width of the rect. [in] sizeY The height of the rect.
- Return values
-
s32 Returns 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] pRect0 Pointer to AEVec2 containing the center of rect0. [in] sizeX0 The width of rect0. [in] sizeY0 The height of rect0. [in] pRect1 Pointer to AEVec2 containing the center of rect1. [in] sizeX1 The width of rect1. [in] sizeY1 The height of rect1.
- Return values
-
s32 Returns true if the rects are colliding. Else return false.
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] x The input value. [in] x0 The lower bound of range [in] x1 The upper bound of range.
- Return values
-
f32 The wraparound value of x with respect to range.
Generated on Sat Jan 4 2014 02:06:22 for Alpha Engine by
