[Tutorial] Coordinate system explanation
#1

Coordinate system explanation



Introduction

I've seen a lot of newbies being frustrated by how a little coordinate can cause their players or objects to go into bad positions. Even a lot of pro scripters do not understand the simple functioning of the X-Y-Z coordinates system of SA-MP. So I decided to make a little tutorial to explain how this came into being and how it works.


X Y Z - What do they mean?

X Y Z is a simple coordinate system, both in real life and in virtual worlds. SA-MP makes use of this system in spawns, object locations, vehicle locations, text label locations, textdraw locations and etc.
Although it is nearly impossible to detect X and Y on land (unless you refer to GTA SA's radar and carefully read the radar to find out X and Y), it is still possible to manually edit Z easily, without having to re-do all the /save ing

X – east-west direction
Y – north-south direction
Z – height information


X Y Z is mainly used in real life for GPS navigation, while more advanced examples can be the Cartesian coordinate system, or the Three-dimensional space system.







Implementation in SA-MP

pawn Код:
AddPlayerClass(105,2495.3357,-1690.2634,14.7656,4.6488,0,0,0,0,0,0); // Spawned_(CJ's_house_stairs)
AddPlayerClass(105,2494.0784,-1669.0546,13.3359,3.3954,0,0,0,0,0,0); // Moved_(Jumped_5_times_to_North)
AddPlayerClass(105,2473.6648,-1668.8138,13.3174,89.8762,0,0,0,0,0,0); // Moved_(Jumped_5_times_to_West)
AddPlayerClass(105,2513.5305,-1671.1807,13.5250,261.8980,0,0,0,0,0,0); // Moved_(Jumped_5_times_to_East)
The following example is a movement from the same starting point.
NOTE - The starting point of West and East is the point from North, while the starting point of North is from SPAWNED location.

Now, let's simplify the code so that we can only look at the X Y Z locations

pawn Код:
2495.3357,-1690.2634,14.7656; // Spawn
2494.0784,-1669.0546,13.3359; // 5 jumps to North from Spawn
2473.6648,-1668.8138,13.3174; // 5 jumps to West from North
2513.5305,-1671.1807,13.5250; // 5 jumps to East from North
The starting point is

X - 2495.3356
Y - -1690.2634.147656
Z - 14.7656

To be precise, this means

X – east-west direction - 2495.3356
Y – north-south direction - -1690.2634.147656
Z – height information - 14.7656

In even simpler words, it means 2495.3356 east, 1690.2634.147656 south and 14.7656 above sea level.

X means east-west direction
If the location is in -, then it's in west, but if it's in +, then it's in the east. The numbers indicate the DISTANCE from the center of GTA SA i.e the blueberry farm

Y means north-south direction
If it's in -, then it's in south, but if it's +, then it's in the north. The numbers indicate the distance from the center.

Z means height above sealevel.
If it's in -, then it's BELOW sea level, but if it's +, then it's above sealevel. The numbers indicate height above/below sea level.
NOTE - AVOID EDITING COORDINATES MANUALLY FROM INTERIORS
NOTE - SEA LEVEL IS ALWAYS 0 Z
NOTE 2 ^- IF YOU GET COORDINATES INSIDE THE SEA, THE Z CAN DIFFER FROM 0 DUE TO THE DIFFERENT CONDITIONS OF THE WEATHER IN GTA



I hope this helps
P.S - Images from Wiki articles
Reply
#2

A good post for newbies. You have explained it well.

+2rep matey
Reply
#3

Good Job , Well Explained
Reply
#4

A very well explained, tutorial, for which I must pass on reputation to you. Well done.
Reply
#5

nicely done , this could be expanded further though
Reply
#6

Quote:
Originally Posted by Niko_boy
Посмотреть сообщение
nicely done , this could be expanded further though
Feel free to make suggestions. I made it in about an hour (Got the idea while reading about quantum mechanism theories of Albert Einstein on space-time-matter and dark energy) so it might not be 100% accurate or may not contain exact information. Just suggest and I'll add
Reply
#7

Very useful tutorial.
Reply
#8

Let me add this:

Some of you may already know, but now it's possible to detect land by having the x and y coordinates. The Map Andreas plugin, by Kalcor can return the On Ground z coordinate by inserting x and y. Kalcor implemented the relief map in this awesome plugin.
Reply
#9

please fix:
the typos in the float value -1690.2634.147656, theres the .147656 too much, its a leftover from the Z=14.7656 obviously...
the minus sign - is a bad choice as delimeter infront of a negative number. it can be read, but its distracting.
why is the lower part all bold?
the second picture is cut-off at the right border.
mentioning the "offset" of 3000.0,3000.0 for the middle of the map, relative to angel pine, will come in handy for some newbies. using negative coordinates as array pointers, can be a tricky thing

nevertheless, useful post. needs a bit polishing tho ^^
Reply
#10

Quote:
Originally Posted by HeLiOn_PrImE
Посмотреть сообщение
Let me add this:

Some of you may already know, but now it's possible to detect land by having the x and y coordinates. The Map Andreas plugin, by Kalcor can return the On Ground z coordinate by inserting x and y. Kalcor implemented the relief map in this awesome plugin.
Problem is the plugin is extremely inefficient, using large amounts of RAM, so you may wish to consult your service provider before using it. (Assuming you're using a commercial game-server host)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)