Static Public Member Functions

MathHelper Class Reference

Helpful Math routines and commonly used calculations. More...

#import <MathHelper.h>

List of all members.

Static Public Member Functions

(CGPoint) + getTouchLocation:
 Returns the location on screen (converted to GL coordinates) of the touch.
(CGPoint) + getTouchesLocation:
 Returns the location on screen (converted to GL coordinates) of any of the touches.
(CGPoint) + getNormalizedDirectionVector:
 returns the normalized direction vector from a rotation angle (direction)
(CGPoint) + getDistantPointInDirection:fromLocation:
 Returns a point on the line defined by location and direction (angle in degrees) which is far away.
(bool) + isDistanceBetweenPoint:andPoint:smallerThan:
 Returns true if the distance between the two points is smaller than the given distance.
(bool) + isDistanceBetweenPoint:andPoint:greaterThan:
 Returns true if the distance between the two points is greater than the given distance.
(float) + getFixedSpeedDurationBetweenPoint:andPoint:forSpeed:
 Returns the duration (for actions) to move an object between two points at the given speed.
(float) + getDirectionFromPoint:toPoint:
 Returns the rotation angle (in degrees) to have an object at point1 rotate to and face point2.
(CCNode *) + getClosestNode:otherNode:location:
 returns the CCNode that is closer to the given location

Detailed Description

Helpful Math routines and commonly used calculations.


Member Function Documentation

+ (CCNode *) getClosestNode: (CCNode*)  node1
otherNode: (CCNode*)  node2
location: (CGPoint)  location 

returns the CCNode that is closer to the given location

+ (float) getDirectionFromPoint: (CGPoint)  point1
toPoint: (CGPoint)  point2 

Returns the rotation angle (in degrees) to have an object at point1 rotate to and face point2.

Requires your object's image to be drawn so that they point to the right when they aren't rotated. If your images have the object point upwards then you need to add +90 to the angle.

+ (CGPoint) getDistantPointInDirection: (float)  direction
fromLocation: (CGPoint)  location 

Returns a point on the line defined by location and direction (angle in degrees) which is far away.

The intention being that the returned point is guaranteed to be outside of the screen, even if the location itself is somewhat outside the screen.

+ (float) getFixedSpeedDurationBetweenPoint: (CGPoint)  point1
andPoint: (CGPoint)  point2
forSpeed: (float)  speed 

Returns the duration (for actions) to move an object between two points at the given speed.

Thanks to cjl for the solution posted in the cocos2d forum: http://www.cocos2d-iphone.org/forum/topic/1071

+ (CGPoint) getNormalizedDirectionVector: (float)  direction  

returns the normalized direction vector from a rotation angle (direction)

+ (CGPoint) getTouchesLocation: (NSSet*)  touches  

Returns the location on screen (converted to GL coordinates) of any of the touches.

+ (CGPoint) getTouchLocation: (UITouch*)  touch  

Returns the location on screen (converted to GL coordinates) of the touch.

+ (bool) isDistanceBetweenPoint: (CGPoint)  point1
andPoint: (CGPoint)  point2
greaterThan: (float)  distance 

Returns true if the distance between the two points is greater than the given distance.

+ (bool) isDistanceBetweenPoint: (CGPoint)  point1
andPoint: (CGPoint)  point2
smallerThan: (float)  distance 

Returns true if the distance between the two points is smaller than the given distance.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Enumerations Enumerator Properties