Mathlib
With this Codeunit 50005 (change No. to wathever you want) you can calculate following Functions insinde Navision without any external ocx or tool. The Unit works standalone and need no other Objects, references or Tablechanges in Navision.
There is no special command from 3.70, so you can convert it to any Navision (even 3.56/blue) version you like.
!
Sin
Cos
Tan
ArcSin
ArcCos
Log
Ln
Adjust
Grad>Rad
Deg>Rad
Rad>Deg
Sqrt
gcd
lcm
Prime
CrossFoot
(a+b)²
(a-b)²
(a+b)*(a-b)
Pi
E
Euler
Sign
Max
Min
Int
EuklDistance
ManhDistance
StreetDistance
ConvLongtitute2Km
ConvLatitude2Km
http://www.mibuso.com/dlinfo.asp?FileID=745
Discuss this download here.
Comments
Really missed the mathematical functions!
But since ArcSin and ArcCos depend on the (unimplemented) ArcTan,
I re-implemented those 2.
ArcCos:
ArcSin:
It's quite accurate, but not too fast. (to change the balance between accuracy and speed you could change 0.00000001 to a bigger value for more speed
Enjoy!
I made another improvement.
The sine function gave rounding errors when near the 90 degrees.
This is because small amount of terms in the taylor series.
That's why i added some to improve accuracy, but this greatly reduced the calculation speed.
That why i used Horner's rule to simplify the calculation
the new code is:
For the SIN function
and for COS: (just a phase difference (This way if you adjust the precision for sin, it also changes for Cos.
It's much mor accurate, and still faster!
Enjoy
We did a scheduling report that calculated distances from 2 locations based on zip codes, but the actual street ditance is only estimated (straight line distance from Lat/Long to Lat2/Long2 + 20% (or 30%, can't remember which one we used).
Peter
With the StreetDist you aproximate the Street Distance between 2 Coordinates (in Kilometer). We use this function exactly for the same as you do, and find on this way for example every customer with a distance between 0 and 40 Km from Our Hometown).
Just as rthsw i made some distance calculations.
I also made a quite precise distance calculation.
It computes distances in km between 2 geocoordinates. Taking in account the shape of the earth and the distibution of the coordinates.
This means that takes in account that one degree at the equator is longer in km's that say in the netherlands, or even more at the poles.
It als take in account that the earth is a sphere and not a flat plane. So it calculates a straight line across the sphere, instead of just a straight line.
Of course this is much slower that the currently present calculations, but it gives nice results.
Hope you like this one!
Peter
You can also integrate with Map & Guide, but this is quite an expensive product.
Single Codeunit without any SideEfect with some Mathematic Functions normaly not avaible in Fin. Improvements (as usable) from Forum and now with arctan! Textfile for implementation in any Navisionversion (even DOS) or Turbopascal Program for educational purposes.
!
Sin
Cos
Tan
ArcSin
ArcCos
ArcTan
Log
Ln
CalcLog
Adjust
Grad>Rad
Deg>Rad
Rad>Deg
Sqrt
gcd
lcm
Prime
CrossFoot
(a+b)²
(a-b)²
(a+b)*(a-b)
Pi
E
Euler
Sign
Max
Min
Int
EuklDistance
ManhDistance
StreetDistance
ConvLongtitute2Km
ConvLatitude2Km
http://www.mibuso.com/dlinfo.asp?FileID=745
Discuss this download here.
1. You should add ABS to the sqrt function, or calling ArcCos will generate an error sometimes, because x can get values like -0.0000002341.
2. Great Job on implementing arcTan, but the loop is kindda long and thus kindda slow, so you could considering using my ArcCos and ArcSin function, also because my function have a higher precision.
But today I have added the Exp funtion and succesfully converted Mercatorcordinates to Geodecimal.
What am I doing wrong ?
Thanks for helping !
And it gives the answer:
So it seems the code is correct, i don't have a clue as why it's not working for you. :-k