Code Red > AutoLISP (Vanilla / Visual)
C++ to lisp
ymg:
There is also the proj.lsp library by David Allison in Autolisp which can be downloaded
here: http://www.usouthal.edu/geography/allison/mappro/mappro.zip
Does Transverse Mercator, Polyconic, Lambert Conformal Conic, Alber's Equal Area, and Mercator.
ymg
pedroantonio123:
Thanks for the help. I tried the convert. Everything I have not done. Can someone please help me?
--- Code: --- var e2cuadrada = Math.Pow(e2, 2);
(setq e2cuadrada (expt e2 2))
var c = Math.Pow(c_sa, 2) / c_sb;
(setq c (/ (expt c_sa 2) c_sb)
var x = utmX - 500000;
(setq x (- utmX 500000))
var y = isNorthHemisphere ? utmY : utmY - 10000000;
(setq y (if isNorthHemisphere (/ utmY (- utmY 10000000))))
var s = ((zone * 6.0) - 183.0);
(setq s (- (* zone 6.0) 183.0))
var lat = y / (6366197.724 * 0.9996); // Change c_sa for 6366197.724
(setq lat (/ y (* 6366197.724 0.9996)))
var v = (c / Math.Pow(1 + (e2cuadrada * Math.Pow(Math.Cos(lat), 2)), 0.5)) * 0.9996;
(setq v (* (/ c (expt (+ 1 (* e2cuadrada (expt (cos lat) 2) 0.5)) 0.9996))
var a = x / v;
(setq a (/ x v))
var a1 = Math.Sin(2 * lat);
(setq a1 (sin (* 2 lat)))
var a2 = a1 * Math.Pow((Math.Cos(lat)), 2);
(setq a2 (* a1 (expt (cos lat) 2)))
var j2 = lat + (a1 / 2.0);
(setq j2 (+ lat (/ a1 2.0)))
var j4 = ((3 * j2) + a2) / 4.0;
(setq j4 (/ (+ (* 3 j2) a2) 4.0))
var j6 = (5 * j4 + a2 * Math.Pow((Math.Cos(lat)), 2)) / 3.0;
(setq j6 (/ (+ (* 5 j4) (* a2 (expt (cos lat) 2))) 3.0))
var alfa = (3.0 / 4.0) * e2cuadrada;
(setq alfa (* (/ 3.0 4.0) e2cuadrada))
var beta = (5.0 / 3.0) * Math.Pow(alfa, 2);
(setq beta (* (/ 5.0 3.0) (expt alpfa 2)))
var gama = (35.0 / 27.0) * Math.Pow(alfa, 3);
(setq gama (* (/ 35.0 27.0) (expt alfa 3)))
var bm = 0.9996 * c * (lat - alfa * j2 + beta * j4 - gama * j6);
(setq bm (* 0.9996 c (- (+ (- lat (* alfa j2)) (* beta j4)) (* gama j6))))
var b = (y - bm) / v;
(setq b (/ (- y bm) v))
var epsi = ((e2cuadrada * Math.Pow(a, 2)) / 2.0) * Math.Pow((Math.Cos(lat)), 2);
(setq epsi (* (/ (* e2cuadrada (expt a 2)) 2.0) (expt (cos lat) 2)))
var eps = a * (1 - (epsi / 3.0));
(setq eps (* a (- 1 (/ epsi 3.0))))
var nab = (b * (1 - epsi)) + lat;
(setq nab (+ (* b (1- epsi)) lat))
var senoheps = (Math.Exp(eps) - Math.Exp(-eps)) / 2.0;
(setq senoheps (/ ????
var delt = Math.Atan(senoheps / (Math.Cos(nab)));
(setq delt (/ ???)
var tao = Math.Atan(Math.Cos(delt) * Math.Tan(nab));
(setq tao (* ???
longitude = (delt / Math.PI) * 180 + s;
(setq longitude (+ (* (/ delt pi) 180) s))
latitude = (((lat + (1 + e2cuadrada * Math.Pow(Math.Cos(lat), 2) - (3.0 / 2.0) * e2cuadrada * Math.Sin(lat) * Math.Cos(lat) * (tao - lat)) * (tao - lat))) / Math.PI) * 180; // era incorrecto el calculo
(setq latitude ????
--- End code ---
irneb:
--- Quote from: pedroantonio123 on December 02, 2014, 01:53:54 AM ---Thanks for the help. I tried the convert. Everything I have not done. Can someone please help me?
--- End quote ---
Here's one error in that translation. The C# conditional operator is like a Lisp if statement - the piece following ? is the then portion, and the piece following the : is the else portion. So the translation should rather be:
--- Code - Auto/Visual Lisp: ---;; var y = isNorthHemisphere ? utmY : utmY - 10000000;(setq y (if isNorthHemisphere utmY (- utmY 10000000)))
irneb:
Also, if you've got issues with converting infix notation to prefix (i.e Polish / s-expressions) for Lisp. You could try my Lisp code to do those things for you: http://www.theswamp.org/index.php?topic=41681.10
Just note I have found some errors in it before. I cannot guarantee that it works in every single instance - though it "should" :wink:
As an example, here's that long line you're having problems with:
--- Code: ---_$ (infix->prefix '(((((lat + (1 + e2cuadrada * Cos(lat) ^ 2) - (3.0 / 2.0) * e2cuadrada * Sin(lat) * Cos(lat) * (tao - lat)) * (tao - lat))) / PI) * 180))
(* (/ (* (+ LAT (- (+ 1 (* E2CUADRADA (^ (COS LAT) 2))) (* (/ 3.0 2.0) (* E2CUADRADA (* (SIN LAT) (* (COS LAT) (- TAO LAT))))))) (- TAO LAT)) PI) 180)
--- End code ---
Note I had to do a bit of altering in there - e.g. Changing the Math.Pow into ^ and Math.Sin into Sin. Else it went all haywire.
Thereafter the ^ function is simply expt. So you either add something like this:
--- Code - Auto/Visual Lisp: ---(setq ^ expt)Or you find-n-replace all ^ with expt in that line.
pedroantonio123:
Thanks for the help. There are still 3 lines to translate. Can anyone help me with this yet?
Thank you :-P :-D
--- Code: --- var senoheps = (Math.Exp(eps) - Math.Exp(-eps)) / 2.0;
(setq senoheps (/ ????
var delt = Math.Atan(senoheps / (Math.Cos(nab)));
(setq delt (/ ???)
var tao = Math.Atan(Math.Cos(delt) * Math.Tan(nab));
(setq tao (* ???
--- End code ---
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version