[Closed] Help converting Geoposition to Cartesian position
Hi,
I am trying to position a bunch of buildings from google earth into max. I was able to extract the geoposition of the buildings from sketchup in decimal degrees. I have a script that sort of works but it is not very precise, at least not as precise as sktchup is. The problem with sketchup is that its not very stable and crashes when I bring in more than 200 models and sometimes it doesn’t even import them at all. Don’t really know what is going on with sketchup so I decided to use max.
With max I am able to import all the models but the position is not really good, off by several meter.
Just wondering if anyone had the same problem or has a good method for importing sketchup models with their proper geolocation.
Hi Ilya,
I’ve written a KML parser to exchange shapes between google earth and 3dsMax: http://www.klaasnienhuis.nl/WordPress/2012/10/kmlparser-altitudemode-and-new-locations/
I remember that these calculations were very elaborate. I didn’t come up with them myself but converted them from this site: http://www.uwgb.edu/dutchs/usefuldata/utmformulas.htm
there are some rounding errors, but not meters. You can check out the calculations in the script and see if you can adapt them to your needs.
Klaas
thanks Klaas,
this is a different formula than I was using – it could be more accurate.
I will try it out.
thanks again,
I was using the wrong search term – conversion to UTM is the proper term not Cartesian.
There is a javascript version of the script I need in the link you sent me which I can convert to maxscript. Hopefully it will work.
ok,
so I converted the javascript I found here to a maxscript. But now i’m having problems with the precision. I am almost exact on the x value but the y value is off by 22300.
The culprit seems to be this line in javascript
//Calculate M
M = phi*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256)));
M = M - Math.sin(2*phi)*(esq*(3/8 + esq*(3/32 + 45*esq/1024)));
M = M + Math.sin(4*phi)*(esq*esq*(15/256 + esq*45/1024));
M = M - Math.sin(6*phi)*(esq*esq*esq*(35/3072));
M = M*a;//Arc length along standard meridian
which I translated to maxscript as
M = (degtorad phi)*(1 - esq*(1/4 + esq*(3/64 + 5*esq/256)))
M = M - sin(2*degtorad phi)*(esq*(3/8 + esq*(3/32 + 45*esq/1024)))
M = M + sin(4*degtorad phi)*(esq*esq*(15/256 + esq*45/1024))
M = M - sin(6* degtorad phi)*(esq*esq*esq*(35/3072))
M = M*a --Arc length along standard meridian
the numbers that come in phi, esq and a are pretty much the same but there is a huge difference in the outcome. I think the way js calculates sine is different than how maxscript does it. I read somewhere that js uses 64bit double precision for calculations not really sure what max uses. Not sure if anyone else had this problem or am I doing something wrong.
You are doing integer division in your maxscript snippet.
E.g.,
15/256 = 0.05859375 in javascript (according to Ideone.com)
15/256 = 0 in maxscript. So just convert your integers to float where it is necessary.
Does that help?
thanks that did the trick,
the other mistake I was making is that maxscript sine function needs degrees not rad