Hi all, does anyone know why the following code gives me totally
different results when running on the Windows Mobile 5 emulator and a
real Windows Mobile 6 device? I am trying to find out the distance in
metres between 2 GPS points. It works correctly on the emulator but
the WM6 device gives bizarre values!
Values given are: WM5: 0.84912711886472536 & WM6: 50481
Call to function: CalculateDistance(40.44717, -3.63763, 40.44717,
-3.63762)
Please help as I am totally lost! I am using Visual Studio 2005 + VB
with the 2.0 compact framework.
TIA
Private Function CalculateDistance(ByVal Lat1 As Double, ByVal
Lon1 As Double, ByVal Lat2 As Double, ByVal Lon2 As Double) As Integer
Dim a, b, c As Double
' 1 Degree is 69.096 miles, 1 mile is 1609.34 m
a = Math.Cos(Lat1 * Math.PI / 180) * Math.Cos(Lat2 * Math.PI /
180) * Math.Cos(Lon1 * Math.PI / 180) * Math.Cos(Lon2 * Math.PI / 180)
b = Math.Cos(Lat1 * Math.PI / 180) * Math.Sin(Lon1 * Math.PI /
180) * Math.Cos(Lat2 * Math.PI / 180) * Math.Sin(Lon2 * Math.PI / 180)
c = Math.Sin(Lat1 * Math.PI / 180) * Math.Sin(Lat2 * Math.PI /
180)
If (a + b + c) >= 1 Or (a + b + c) <= -1 Then
CalculateDistance = 0
Else
CalculateDistance = Convert.ToInt32(Math.Acos(a + b + c) *
6371000)
End If
End Function 3 1318
Hugh Janus wrote:
Hi all, does anyone know why the following code gives me totally
different results when running on the Windows Mobile 5 emulator and a
real Windows Mobile 6 device?
Have you tried getting the code to display the values of the a, b and c
variables after it has calculated each one?
If they are all showing different results between the two platforms, try
getting it to display the values of the individual trig functions that are
being used to calculate the those values.
Once you have broken it down to the individual element that is causing the
problem, it will probably be easier to try to figure out how to correct it.
--
(O)enone
On Sep 7, 12:10 pm, "\(O\)enone" <oen...@nowhere.comwrote:
Hugh Janus wrote:
Hi all, does anyone know why the following code gives me totally
different results when running on the Windows Mobile 5 emulator and a
real Windows Mobile 6 device?
Have you tried getting the code to display the values of the a, b and c
variables after it has calculated each one?
If they are all showing different results between the two platforms, try
getting it to display the values of the individual trig functions that are
being used to calculate the those values.
Once you have broken it down to the individual element that is causing the
problem, it will probably be easier to try to figure out how to correct it.
--
(O)enone
Hi, thanks for the fast response. Values a,b and c all differ. For
some reason WM6 is calculating the Math functions differently. Unless
this is a problem with the emulator although the code running in the
emulator is giving the value i expect.
High
You could always do the calculation yourself to be sure it's right - it's a
simple Great Circle calculation.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World www.OpenNETCF.com
"Hugh Janus" <my*************@hotmail.comwrote in message
news:11**********************@g4g2000hsf.googlegro ups.com...
On Sep 7, 12:10 pm, "\(O\)enone" <oen...@nowhere.comwrote:
>Hugh Janus wrote:
Hi all, does anyone know why the following code gives me totally
different results when running on the Windows Mobile 5 emulator and a
real Windows Mobile 6 device?
Have you tried getting the code to display the values of the a, b and c variables after it has calculated each one?
If they are all showing different results between the two platforms, try getting it to display the values of the individual trig functions that are being used to calculate the those values.
Once you have broken it down to the individual element that is causing the problem, it will probably be easier to try to figure out how to correct it.
--
(O)enone
Hi, thanks for the fast response. Values a,b and c all differ. For
some reason WM6 is calculating the Math functions differently. Unless
this is a problem with the emulator although the code running in the
emulator is giving the value i expect.
High This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Max |
last post by:
Hi,
Is it possible to have different Select Expert formula for
different column or Fields at once? I can't figure out
how to calculate totals for different fields such as count
and total of...
|
by: Max |
last post by:
Hi,
Is it possible to have different Select Expert formula for
different column or Fields at once? I can't figure out
how to calculate totals for different fields such as count
and total of...
|
by: toffee |
last post by:
Hi all,
I got a pre-formatted spreadsheet. would it be possible using js to copy the
data from a table on the current webpage, open the spreadsheet and paste the
content ?
if so, anyone got any...
|
by: pereges |
last post by:
I have a C program which I created on Windows machine. I have compiled
and executed the program on windows machine and it gives me the
consistent output every time i run it. for eg.
input a = 2,...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |