## LSL Wiki : GlobalCoordinate

HomePage :: PageIndex :: RecentChanges :: RecentlyCommented :: UserSettings :: You are ia360925.us.archive.org

## Global Coordinates

Global coordinates are used to describe a position relative to one point on the entire Second Life world, hence the word "global". This means that every place on the grid has a different vector value when represented in global coordinates. This allows global coordinates to describe a position without adverse effects occuring when a sim border is crossed.

A region coordinate can be converted into a global coordinate by adding to it the region corner of the simulator the coordinate is relative to.

`vector currentGlobalPos = llGetRegionCorner() + llGetPos();`

Using global coordinates, it's easy to create an object that can traverse the world. llSetPos and llMoveToTarget use region coordiantes; to use these functions to travel to a particular global coordinate, pass the result of subtracting the current region's corner from the global coordinate to the function. This converts the global coordinate into a region coordinate.

Example:
```// Pass a global position to this function, and the object
// will move there.
setGlobalPos(vector globalDest) {
vector localDest;
do {
localDest = globalDest - llGetRegionCorner();
llSetPos(localDest);
} while (llVecDist(llGetPos(), localDest) > 0.1);
}

default {
state_entry() {
vector DABOOM_CORNER = <256000, 256000, 0>; // DaBoom's region corner.
setGlobalPos(DABOOM_CORNER + <128, 128, 128>); // Travel to <128,128,128> in DaBoom.
}
}```

### Q & A:

Q: Is the global coordinate origin point (<0, 0, 0>) located somewhere in the sim Da Boom?
A: No, Da Boom is merely the sim from which it all started. See coordinate.

Q: How do I convert the landmark positions (retrieved using llRequestInventoryData) to global coordinates?
A: Add the dataserver's return value to llGetRegionCorner before moving; the coordinate is relative to the simulator where you made the dataserver request.

Now to complicate things. Say you want to move a prim from one sim into another sim that is diagonal from it. An example situation would be calling llSetPos(<257,257,50>); from <254,254,50>. Your prim will first transfer into the sim on the x axis of the move and then into the sim on the y axis. If there is no sim on the x axis your prim will go offworld. So if you move a prim from Tan to Kissling it will go off world. But if you move a prim from Kissling to Tan it won't. -BW

(map)

Q: What is the cutoff of a vector being interpreted as local or global? >256? >256000 ?
A: There is no cutoff. Any coordinate of any manitude, positive or negative, is a valid local or global coordinate, although it may or may not correspond to an existing in-world location. Whether a vector is interpreted as local or global is determined by context, not value. For example, any vector sent to a function that takes a local coordinate is interpreted as a local coodinate, regardless of the values. Since it's perfectly valid to specify out-of-sim locations in terms of the local coodinate system, this is a Good Thing(tm).

Coordinates | Local Coordinates | Region Coordinates | Region Corner | Grid/World
Hi. Would someone be so kind as to futher comment / explain this script.
I have spoke with a number of people, and we are all confused.

* Also, why for example are the vars flipped
setPos(vector regionCorner, vector regionCoords) {
vector localCoords = getLocalVec(regionCoords, regionCorner);

in these functions??? confuses for no apparent reason.

* A simple in / out example would be very appreciated that just prints out globals to local and vice versa perhaps?

* what exactly is the purpose of
vector DABOOM_CORNER = <1000, 1000, 0> * 256;
so destination has to be hard coded? Do i have to build look up list if i want something to follow me around? do i just have to wear object that gets my position, and shouts out region coordes every 2 seconds?

If I do manage to figure it out at some point, I will post more details addition.
-- MaxCase (2005-05-30 18:49:47)
These functions are for moving around on a global scale; moving a prim from one side of the grid to the other. The reason for having the sim corner and the local sim position separate is because floats only have 23 bits and if you add them you loose the lower precision. Thats why the two big numbers are dealt with first in getLocalVec().

How this works, you pass it a sim courner and the position in the sim you want the script to travel to. It then goes there.
-- BlindWanderer (2005-05-30 19:18:44)
Ack, sorry about invalidating the two above comments with my changes... I really felt that this concept needed simplification.
-- ChristopherOmega (2006-02-12 18:25:04)
Is there a way to determine the sim name at a certain set of global coordinates?
-- DustinWidget (2006-08-03 15:14:32)
Likewise, is there a way to get the region corner from a sim name?
-- CirrMarat (2006-08-30 03:57:59)
Not yet... unless somebody wants to map out the sims and make a reverse-lookup script.
If someone gets the data, I'd be glad to write the script and put it in the wiki.
you can use the map api script for lookups (including reverse).
-- BlindWanderer (2006-08-30 23:04:13)
How the blazes do I find the global coordinates that I'm in? Do I just have to make an object that finds them and then says them? Or can I do something with the map? For a globally teleporting item (such as an ICBM or a Santabot that gifts friends in a graphically pleasing way), this would be really nice to know.
-- SovereignTaov (2007-01-15 15:22:49)
You can find your current global position by enabling the client/server debug menu (Ctrl+Shift+Alt+D), and navigating to the Client>HUDs>Camera menu option. In the lower right corner of the screen, it should show information about your current position, as well as the current position of your camera.
-- ChristopherOmega (2007-01-18 06:50:15)
Question; will the global position mover thing listed above work if there is no straight line to the target?
-- SovereignTaov (2007-01-21 15:56:36)
If anyone is still paying attention... I have a question. Why is llMoveToTarget() not used in the example?
-- 72-161-171-159.dyn.centurytel.net (2007-08-12 23:51:19)
Well, as you probably know, that's for physical objects, and has a maximum distance of 55 Meters per a call.
(Probably used for Missiles)
Most likely because it would be hard >_>
But I don't know