MEMath Class Reference

Inherits from NSObject
Declared in MEMath.h

Overview

Useful math functions.

+ mercatorTo3857:

Given a CGPoint where x represents longitude, and y represents latitude, returns a new CGPoint in EPSG:3857 coordinates where x represents longitude and y represents latitude.

+ (CGPoint)mercatorTo3857:(CGPoint)sourceCoordinate

Declared In

MEMath.h

+ toRadians:

Convert degrees to radians.

+ (double)toRadians:(double)degrees

Declared In

MEMath.h

+ toDegrees:

Convert radians to degrees.

+ (double)toDegrees:(double)radians

Declared In

MEMath.h

+ distanceBetween:lat1Radians:lon2Radians:lat2Radians:

Returns the distance in radians between two points specified in radians.

+ (double)distanceBetween:(double)lon1Radians lat1Radians:(double)lat1Radians lon2Radians:(double)lon2Radians lat2Radians:(double)lat2Radians

Declared In

MEMath.h

+ distanceBetween:point2:

Returns the great circle distance between two points in radians between two points.

+ (double)distanceBetween:(CGPoint)point1 point2:(CGPoint)point2

Declared In

MEMath.h

+ nauticalMilesBetween:point2:

Returns the great circle distance in nautical miles between two points.

+ (double)nauticalMilesBetween:(CGPoint)point1 point2:(CGPoint)point2

Declared In

MEMath.h

+ nauticalMilesBetween:location2:

Returns the great circle distance in nautical miles between two locations.

+ (double)nauticalMilesBetween:(CLLocationCoordinate2D)location1 location2:(CLLocationCoordinate2D)location2

Declared In

MEMath.h

+ nauticalMilesInRoute:

Returns the great circle distance in nautical miles of a route.

+ (double)nauticalMilesInRoute:(NSArray *)wayPoints

Declared In

MEMath.h

+ tesselateRoute:pointCount:

Given an array of way points, return a new array of points evenly spaced along that route.

+ (NSArray *)tesselateRoute:(NSArray *)wayPoints pointCount:(uint)pointCount

Declared In

MEMath.h

+ radiansToNauticalMiles:

Converts radians to nautical miles.

+ (double)radiansToNauticalMiles:(double)radians

Declared In

MEMath.h

+ nauticalMilesToRadians:

Converts nautical miles to radians.

+ (double)nauticalMilesToRadians:(double)nauticalMiles

Declared In

MEMath.h

+ nauticalMilesToMeters:

Converts nautical miles to meters.

+ (double)nauticalMilesToMeters:(double)nauticalMiles

Declared In

MEMath.h

+ metersToNauticalMiles:

Converts meters to nautical miles.

+ (double)metersToNauticalMiles:(double)meters

Declared In

MEMath.h

+ pointOnRadial:radial:distance:

Returns a point on a radial a given distance from an origin point.

+ (CGPoint)pointOnRadial:(CGPoint)point radial:(double)radial distance:(double)distance

Parameters

point

Where x = longitude, y = latitude

radial

Angle in degrees.

distance

Distance in nautical miles.

Declared In

MEMath.h

+ locationOnRadial:radial:distance:

Returns a location on a radial a given distance from an origin location.

+ (CLLocationCoordinate2D)locationOnRadial:(CLLocationCoordinate2D)location radial:(double)radial distance:(double)distance

Parameters

location

The point from which to measure.

radial

Angle in degrees.

distance

Distance in nautical miles.

Declared In

MEMath.h

+ courseFromPoint:toPoint:

Returns the degrees heading you would need to take to go from point1 to point2.

+ (double)courseFromPoint:(CGPoint)point1 toPoint:(CGPoint)point2

Declared In

MEMath.h

+ courseFromLocation:toLocation:

Returns the degrees heading you would need to take to go from location1 to location2.

+ (double)courseFromLocation:(CLLocationCoordinate2D)location1 toLocation:(CLLocationCoordinate2D)location2

Declared In

MEMath.h

+ tesselateRoute:point2:nodeCount:

Tesselates a route between two geographic points into an array of points of nodeCount size.

+ (NSArray *)tesselateRoute:(CGPoint)point1 point2:(CGPoint)point2 nodeCount:(int)nodeCount

Declared In

MEMath.h

+ tesselateRoute:point2:milesPerNode:

Tesselates a route between two geographic points into an array of points along the route separating each node by milesPerNode nautical miles.

+ (NSArray *)tesselateRoute:(CGPoint)point1 point2:(CGPoint)point2 milesPerNode:(double)milesPerNode

Declared In

MEMath.h

+ pointBetween:point2:fraction:

Returns the point that is f/1 the distance between point1 and point2. When f = 0, point 1 will be returned, when f = 1, point 2 will be returned. This is used for route-line point tesselation. The units of point1 and point 2 should be degrees x=lon/y=lat. Returned point will be degrees x=lon/y=lat.

+ (CGPoint)pointBetween:(CGPoint)point1 point2:(CGPoint)point2 fraction:(double)f

Declared In

MEMath.h

+ locationBetween:andLocation:fraction:

Returns the location that is f percent the distance between locations

+ (CLLocationCoordinate2D)locationBetween:(CLLocationCoordinate2D)a andLocation:(CLLocationCoordinate2D)b fraction:(double)f

Declared In

MEMath.h

+ isPowerOfTwo:

Returns YES if x is a power of 2.

+ (BOOL)isPowerOfTwo:(uint)x

Declared In

MEMath.h

+ nextPowerOfTwo:

Returns the next power of 2.

+ (int)nextPowerOfTwo:(int)x

Declared In

MEMath.h

+ getEarthRadiusInMeters

Returns Earth’s radius in meters.

+ (double)getEarthRadiusInMeters

Declared In

MEMath.h

+ getEarthCircumferenceInMeters

Returns Earth’s circumference in meters.

+ (double)getEarthCircumferenceInMeters

Declared In

MEMath.h

+ getEarthCircumferenceInNauticalMiles

Returns Earth’s circumference in nautical miles.

+ (double)getEarthCircumferenceInNauticalMiles

Declared In

MEMath.h

+ getEpsilon

Returns the internal ‘epsilon’ value used for determining if certain floating point results are equivalent to zero (0).

+ (double)getEpsilon

Declared In

MEMath.h

+ getMercatorMax

Returns the maximum spherical mercator projection latitude.

+ (double)getMercatorMax

Declared In

MEMath.h

+ getMercatorMin

Returns the minimum spherical mercator projection latitude.

+ (double)getMercatorMin

Declared In

MEMath.h

+ getHeightScaleDivisor

Returns the internal height scale divisor constant.

+ (double)getHeightScaleDivisor

Declared In

MEMath.h

+ getMaxLevel

Returns the current spherical mercator max level supported by the engine.

+ (unsigned int)getMaxLevel

Declared In

MEMath.h

+ createCircleAroundLocation:radius:segmentCount:

Returns an array points that form a circle around a location. The returned array contains NSValue objects that ‘wrap’ a CGPoint struct where the x value is longitude and the y value is latitude.

+ (NSMutableArray *)createCircleAroundLocation:(CLLocationCoordinate2D)location radius:(double)radius segmentCount:(int)segmentCount

Parameters

location

The geographic center of the circle.

radius

The radius in nautical miles of the circle.

segmentCount

The number of segments to break the circle into.

Declared In

MEMath.h