0
$\begingroup$

I am creating a map application and I need help in calculation.

map

I am having an image of map which is say 125px in height and 250px in width, I know coordinates of all the corners, now I want to find an offset for a point 80.25,12.5. How can I do that ? Can anyone suggest a formula for that ?

Please help.

  • 0
    Fair warning: "this is urgent" makes people more likely to not answer your question...2011-11-06
  • 0
    Ok I will keep in mind2011-11-06

1 Answers 1

0

You need simple proportions. Your full height in pixels is $125px$; the height in your coordinate system is $80$, hence $12.5/80=X/125px$. More generally, if $x$ and $y$ are the coordinates in the original coordinate system and $X$ and $Y$ are the coordinates in the pixel space then $X=250px\times x/100$ and $Y=125px\times y/80$.

  • 0
    will this work if coordinates are not starting from 0,0, i.e. if top left corner has coordinates 10,10. then what will this formula work ?2011-11-06
  • 0
    No it won't. You'll need to subtract the coordinates of the top left corner.2011-11-06
  • 0
    Ok so the new formula could be something like X=250px*x0-x1/100 and Y=125x*y0-y1/80 correct ?2011-11-06
  • 0
    No, $X=250px\times (x-x_0)/100$ and $Y=125px\times (y-y_0)/80$. This assumes that $100$ and $80$ are your _full_ width and height.2011-11-06
  • 0
    perfect thank you so much :-)2011-11-06
  • 0
    @AlekseyPichugin maybe you can help me with this question: http://math.stackexchange.com/questions/1548841/calculate-point-coordinates2015-11-27