Code Red > AutoLISP (Vanilla / Visual)

C++ to lisp

<< < (4/6) > >>

Kerry:
pedroantonio124,
Which AutoCAD build are you using ?

pedroantonio124:
AutoCad 2014

irneb:

--- Quote from: pedroantonio124 on December 08, 2014, 04:40:17 AM ---Hello irneb,

Thanks for your help  :-)

Unfortunately, I still receive the wrong result with the lisp code.
Maybe I can find the mistake if I know the result of every line.
Could you let me the C # run through over again code? Please
With a Console.WriteLine for every line.

--- End quote ---

Rather than a WriteLine per line ... just get hold of a DotNet IDE and debug step through it.

You can get a free IDE, either of these would do:

* http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
* http://www.icsharpcode.net/opensource/sd/

Kerry:
You want fries with this ?


--- Code - C#: ---using System;using System.Collections.Generic;using System.Globalization;using System.Linq;using System.Text;using System.Threading.Tasks; namespace ToLatLon{    internal class Program    {        private static void Main(string[] args)        {            Console.Write("\n UTM to LatLon test.\n From theSwamp\n http://www.theswamp.org/index.php?topic=48330.0" );            Console.Write("\n\nEnter utmX value : " );            double utmX = double.Parse(Console.ReadLine());             Console.Write("\nEnter utmY value : " );            double utmY = double.Parse(Console.ReadLine());             Console.Write("\nEnterutmZone value : " );            string utmZone = Console.ReadLine();             ToLatLon(utmX, utmY, utmZone);             Console.ReadKey();        }         public static void ToLatLon(double utmX, double utmY, string utmZone)        {            double latitude = 0;            double longitude = 0;             bool isNorthHemisphere = utmZone.Last() >= 'N';             var diflat = -0.00066286966871111111111111111111111111;            var diflon = -0.0003868060578;             var zone = int.Parse(utmZone.Remove(utmZone.Length - 1));            var c_sa = 6378137.000000;            var c_sb = 6356752.314245;             var e2 = Math.Pow((Math.Pow(c_sa, 2) - Math.Pow(c_sb, 2)), 0.5)/c_sb;            Console.WriteLine("\ne2:\t " + e2.ToString());             var e2cuadrada = Math.Pow(e2, 2);            Console.WriteLine("\ne2cuadrada:\t " + e2cuadrada.ToString());             var c = Math.Pow(c_sa, 2)/c_sb;            Console.WriteLine("\nc:\t " + c.ToString());             var x = utmX - 500000;            Console.WriteLine("\nx:\t " + x.ToString());             var y = isNorthHemisphere ? utmY : utmY - 10000000;            Console.WriteLine("\ny:\t " + y.ToString());             var s = ((zone*6.0) - 183.0);            Console.WriteLine("\ns:\t " + s.ToString());             var lat = y/(6366197.724*0.9996); // Change c_sa for 6366197.724            Console.WriteLine("\nlat:\t " + lat.ToString());             var v = (c/                     Math.Pow(1 + (e2cuadrada*Math.Pow(Math.Cos(lat), 2)), 0.5))*                    0.9996;            Console.WriteLine("\nv:\t " + v.ToString());             var a = x/v;            Console.WriteLine("\na:\t " + a.ToString());             var a1 = Math.Sin(2*lat);            Console.WriteLine("\na1:\t " + a1.ToString());             var a2 = a1*Math.Pow((Math.Cos(lat)), 2);            Console.WriteLine("\na2:\t " + a2.ToString());             var j2 = lat + (a1/2.0);            Console.WriteLine("\nj2:\t " + j2.ToString());             var j4 = ((3*j2) + a2)/4.0;            Console.WriteLine("\nj4:\t" + j4.ToString());             var j6 = (5*j4 + a2*Math.Pow((Math.Cos(lat)), 2))/3.0;            // saque a2 de multiplicar por el coseno de lat y elevar al cuadrado            Console.WriteLine("\nj6:\t " + j6.ToString());             var alfa = (3.0/4.0)*e2cuadrada;            Console.WriteLine("\nalfa:\t " + alfa.ToString());             var beta = (5.0/3.0)*Math.Pow(alfa, 2);            Console.WriteLine("\nbeta:\t " + beta.ToString());             var gama = (35.0/27.0)*Math.Pow(alfa, 3);            Console.WriteLine("\ngama:\t " + gama.ToString());             var bm = 0.9996*c*(lat - alfa*j2 + beta*j4 - gama*j6);            Console.WriteLine("\nbm:\t " + bm.ToString());             var b = (y - bm)/v;            Console.WriteLine("\nb:\t " + b.ToString());             var epsi = ((e2cuadrada*Math.Pow(a, 2))/2.0)*                       Math.Pow((Math.Cos(lat)), 2);            Console.WriteLine("\nepsi:\t " + epsi.ToString());             var eps = a*(1 - (epsi/3.0));            Console.WriteLine("\neps:\t " + eps.ToString());             var nab = (b*(1 - epsi)) + lat;            Console.WriteLine("\nnab:\t " + nab.ToString());             var senoheps = (Math.Exp(eps) - Math.Exp(-eps))/2.0;            Console.WriteLine("\nsenoheps:\t " + senoheps.ToString());             var delt = Math.Atan(senoheps/(Math.Cos(nab)));            Console.WriteLine("\ndelt:\t " + delt.ToString());             var tao = Math.Atan(Math.Cos(delt)*Math.Tan(nab));            Console.WriteLine("\ntao:\t " + tao.ToString());             longitude = (delt/Math.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             Console.WriteLine("\nLatitud:\t " + latitude.ToString() +                "\nLongitud:\t " + longitude.ToString());        }    }} 

irneb:
Damn ... you're much to quick!

Anyhow, if you don't want to install anything new, you could use IDEone: http://ideone.com/5irS8R

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version