# Transform rectangle from decimal degrees to Cartesian coordinates

I'm trying to achieve the following: Given four coordinates (lat, lng) decimal degrees and a query coordinate within the formed shape, how can I transform these coordinates into Cartesian space where ideally, one of the corner points is the origin and the top right is (100, 100) and they form a rectangle? Also, how would I then get the coordinates of the query point?

I've found various programming language specific libraries that do transformations like these in Cartesian space between two shapes, but I'd be interested in a method to determine this without any specific programming language libraries that also takes the fact into account that I'm starting in decimal degrees.

Any hints?

• `Given four coordinates (lat, lng) in EPSG:3857` EPSG:3857 doesn't use lat long coordinates Aug 21 '20 at 9:33
• Pay attention to the Haversine formula and check thise article Converting from longitude\latitude to Cartesian coordinates, where you find `x = R * cos(lat) * cos(lon)` and `y = R * cos(lat) * sin(lon)` Aug 21 '20 at 9:37
• @nmtoken Apologies if I'm using the wrong terminology. I just mean lat, lng pairs. I guess the projection doesn't matter?
– Baz
Aug 21 '20 at 9:39
• @Taras Thanks! So that would convert them into cartesian space. Any hints at how to transform the result afterwards?
– Baz
Aug 21 '20 at 9:49
• Please Edit the question without the assumption that Web Mercator is in units of decimal degrees. Also be sure that there is only One question per Question. Aug 21 '20 at 14:16