Math help
#1

I need a function or just the equation to mark a position in San Andreas on a 320 x 320 textdraw map.

I've had a look through several includes but they didn't help.
The closest I've gotten is getting the position on the screen but it wasn't accurate.

If you need any more information, please say so.
Thanks.
Reply
#2

The SA map is 6000 'units' across, so just do 320/6000 and that is one 'unit'.
Reply
#3

Thanks Mike but I'm no closer. I've been at this since yesterday morning and not having any luck, at all..

Every time I get close something goes wrong. I'm terrible at maths and appreciate any more help you can give me.

Here's a picture of the maps location.



As you can see, I can't even get the marker on the map.

The top left corner is 160 from the left, 110 from the top and is 320x320.

San Andreas X:0.0000 and Y:0.0000 is 320.0000, 273.0000 on the map.
Thanks
Reply
#4

Ok. So I have this:
pawn Код:
y = y - (y + y);
    posX = x / (6000/320) + 320;
    posY = (y / (6000/320) + 273);
The only problem now is that the closer to the edge of the map I get, the less accurate it becomes
Reply
#5

Quote:
Originally Posted by Psymetrix
Посмотреть сообщение
Ok. So I have this:
pawn Код:
y = y - (y + y);
    posX = x / (6000/320) + 320;
    posY = (y / (6000/320) + 273);
The only problem now is that the closer to the edge of the map I get, the less accurate it becomes
If you use 6000 / 320 you tell the compiler to do an integer division
And the result wouldnt be 18.75, it would be 18

pawn Код:
posX = (((3000.0 + x) / 360.0) + 160.0);
posY = (((3000.0 - y) / 360.0) + 110.0);
How did you calculated the middle, if the map is 360x360
Because if I do 160 + 360 / 2 I get 340 not 320 for x, and 290 for y

pawn Код:
posX = ((x / (6000.0 / 360.0)) + 340.0);
posY = ((y / -(6000.0 / 360.0)) + 290.0);
Reply
#6

Thanks guys. It works.

@Nero_3D

This is what I ended up with:
pawn Код:
posX = ((x / (6000.0 / 320.0)) + 320.0);
    posY = ((y / -(6000.0 / 320.0)) + 270.0);
The map is 320 x 320, not 360. That was a typo in my last post, sorry.
Reply
#7

It took a lot of courage to post this. I know this may seem very simple to most but math is not my strong point.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)