And here is an Example for testing the library :) Enjoy! \ Distance and iniBearing of two points on Earth \ Example for Amforth with floating point asm library installed \ Calculates distance in meters and initial bearing in degrees based on \ latidute and longitude of two points on Earth. \ Uses the Haversine formula \ c IgorM 5/2015 \ GNU GPL v3 \ No warranties of any kind \ Provided as-is
-distbear marker -distbear $0fdb $4049 fconstant PI 6.371e6 fconstant R_E fvariable lat1 fvariable lon1 fvariable lat2 fvariable lon2 : torad PI 180.0e f/ f* ; : todeg 180.0e PI f/ f* ; : PHI1 lat1 f@ torad ; : PHI2 lat2 f@ torad ; : DPHI lat2 f@ lat1 f@ f- torad ; : DLAMBDA lon2 f@ lon1 f@ f- torad ; : A_ DPHI 2e f/ fsin fdup f* PHI1 fcos PHI2 fcos DLAMBDA 2e f/ fsin fdup f* f* f* f+ ; : C_ A_ fsqrt 1e A_ f- fsqrt fatan2 2e f* ; : distance lon2 f! lat2 f! lon1 f! lat1 f! R_E C_ f* ; : inibearing \ lon2 f! lat2 f! lon1 f! lat1 f! DLAMBDA fsin PHI2 fcos f* PHI1 fcos PHI2 fsin f* PHI1 fsin PHI2 fcos DLAMBDA fcos f* f* f- fatan2 todeg ; \ lat1 lon1 lat2 lon2 (degree) \ 50.0e 15.0e 50.0001e 15.0001.0e distance fs. inibearing fe. ( 13.22m, 32 43 56 = 32.73222 ) \ 50.0e 15.0e 60.0e 80.0e distance fs. inibearing fe. ( 4108km, 48 56 13 = 48.93694 ) \ 50.0e 15.0e -60.0e -170.0e distance fs. inibearing fe. ( 18860km, 166 01 30 = 166.025 ) ______________________________________________________________ > Od: "pito" <p...@volna.cz> > Komu: <amforth-devel@lists.sourceforge.net> > Datum: 28.05.2015 23:56 > Předmět: Floating point - All_math library in asm > >Hi, there is a "complete fp asm lib" for amforth at >https://github.com/igor-m/Amforth-Floating-Point-in-ASM >You need Leon's fp lib for the fp handling, the f* f+ f- f/ fsqrt fsin fcos >ftan facos fasin fatan fexp flog ..... etc. come from the asm lib. >Not sure how it will work with latest Amforth as it was tested in 4.8 or >something like that. >The speed is great, not comparable with my forth sincostan library, of course. >Precision standard 32bit fp. >With that precision you can calculate distance of two points on Earth with >~800m diff over 19.000km with Haversine :). >P. > ------------------------------------------------------------------------------ _______________________________________________ Amforth-devel mailing list for http://amforth.sf.net/ Amforth-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/amforth-devel