I was working with a function that appears as follows:

Some details of the input data

– self.radius = 6371.0 – kilometers

– self.lat = math.rad(1.0)

– self.lat = math.rad(1.0)

function GeoPos:RhumbDestinationPoint(bearing,distance)

local brng = math.rad(bearing)

local dist = distance/self.radius

print(“brng”,brng)

print(“dist”,dist)

```
local lat1 = self.lat -- gets converted to rads in the Init() function
local lon1 = self.lon -- gets converted to rads in the Init() function
local lat2 = lat1 + dist*math.cos(brng)
local dLat = lat2-lat1
local dPhi = math.log(math.tan(lat2/2+math.pi/4)/math.tan(lat1/2+math.pi/4))
local q = 0.0
if bearing==90.0 or bearing==270.0 then
q = math.cos(lat1)
else
q = dLat/dPhi
end
print("q",q)
local dLon = dist*math.sin(brng)/q
local lon2 = math.fmod((lon1+dLon+3*math.pi),(2*math.pi))-math.pi
print("lat1",lat1)
print("lon1",lon1)
print("lat2",lat2)
print("lon2",lon2)
print("dPhi",dPhi)
print("dLat",dLat)
print("dLon",dLon)
return math.deg(lat2),math.deg(lon2)
```

end

This is a snippet from a class (GeoPos) I created. I am calling the function as follows:

function setup()

lat=1.0

lon=1.0

GP=GeoPos(lat,lon)

lat,lon=GP:RhumbDestinationPoint(45,.01) – 045 degrees at 10 meters

print(“–”,lat,lon)

end

If I run the function on a PC in LoveCodify or LuaForWindows or Python or C or C++ I get the following results:

brng 0.78539816339745

dist 1.5696123057605e-006

q 0.99984768527973

lat1 0.017453292519943

lon1 0.017453292519943

lat2 0.017454402403449

lon2 0.017454402572525

dPhi 1.1100525825855e-006

dLat 1.1098835052369e-006

dLon 1.1100525825857e-006

– 1.0000635916406 1.000063601328

When I run it on an iPad2 in Codify, I get these results:

brng 0.785398

dist 1.56961e-006

q 1.03472

lat1 0.0174533

lon1 0.0174533

lat2 0.0174544

lon2 0.0174539

dPhi 1.07288e-006

dLat 1.11014e-006

dLon 1.07264e-006

– 1.00006 1.00004

This is a nice function to simulate motion but it seems to fail because of precision issues on the iPad2. I can find a different way to simulate motion but I was surprised that the math functions broke down so quickly at small values. Any insight into iPad floating point architecture would be appreciated.

Thanks