Coordinates: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(15 intermediate revisions by 10 users not shown)
Line 1: Line 1:
<div style="float:right;padding:1em;background:white;">[[Image:Coordinates.png|A two-dimensional coordinate system]]</div>
{{lang|Coordinates}}
<div style="background:#262626;float:right;">[[File:Coordinates.png|A two-dimensional coordinate system]]</div>


'''Coordinates''' are used to describe locations. They are represented as groups of numbers, one per dimension, which taken together can be plotted on a grid.
'''Coordinates''' are used to describe locations. Each one is a group of "ordinate" numbers which taken together can be plotted on a grid, one ordinate per dimension.


Coordinates in Source are <code>(<span style="color:red;font-weight:bold;">X</span>,<span style="color:green;font-weight:bold;">Y</span>,<span style="color:blue;font-weight:bold;">Z</span>)</code>, where X is right, Y is forward, and Z is up. <code>(0,0,1)</code> is a point one [[unit]] directly above the origin.
Coordinates in Source are <code>(<span style="color:red;font-weight:bold;">X</span>,<span style="color:green;font-weight:bold;">Y</span>,<span style="color:blue;font-weight:bold;">Z</span>)</code>, where X is forward/East, Y is left/North, and Z is up. <code>(0,0,1)</code> is a point one [[unit]] directly above the origin.
 
Source is using right handed coordinate system.


Coordinates are often stored alongside a set of rotation [[angle]]s.
Coordinates are often stored alongside a set of rotation [[angle]]s.


{{note|'Global' or 'absolute' coordinates refer to the coordinates of the [[world]]. All other coordinate systems are 'local' to an [[entity]].}}
{{note|'Global' or 'absolute' coordinates refer to the coordinates of the [[world]]. All other coordinate systems are 'local' to an [[entity]].}}
 
{{note|In world, +X is east and +Y is north. In [[MDL (Source)|MDLs]], +X is north and +Y is west.}}
{{tip|SDK tools generally align coordinates so that the camera is looking down Y, since this tends to have the effect of making the item in question face you. Remember that this makes X appear reversed.}}
{{note|The compass shown when the {{code|nav_show_compass}} [[console variable]] is toggled shows x axis is east and y axis is south. This doesn't make any sense, because in reality, turning left from north will turn to west instead of east.}}
 
== Origin ==
== Origin ==


The '''origin''' of an object is the point at which its local coordinates are <code>(0,0,0)</code>. This is the 'centre' from which all other local coordinate values are relative.
The '''origin''' of an object is the point at which its local coordinates are <code>(0,0,0)</code>. It is the mathematical centre from which local coordinates are relative. It is rarely the centre of the visible object, however.


{{tip|There can be multiple origins within the same entity: its own origin, the origin of its model, etc. Each origin defines its own local coordinate system relative to its parent.}}
{{tip|There can be multiple origins within the same entity: its own origin, the origin of its model, etc. Each origin defines its own local coordinate system relative to its parent.}}
Line 19: Line 21:
== See also ==
== See also ==


* [[Vector]]
* [[QAngle]]
* [[Dimensions]]
* [[Wikipedia:Coordinate system]]
* [[Wikipedia:Coordinate system]]
* <code>[[GetAbsOrigin()]]</code>
* [[$origin]] and [[$autocenter]] (for [[model]]s)
* [[$origin]] and [[$autocenter]] (for [[model]]s)


[[Category:Glossary]]
[[Category:Glossary]]

Latest revision as of 11:55, 2 March 2025

English (en)Deutsch (de)Hrvatski (hr)Русский (ru)中文 (zh)Translate (Translate)
A two-dimensional coordinate system

Coordinates are used to describe locations. Each one is a group of "ordinate" numbers which taken together can be plotted on a grid, one ordinate per dimension.

Coordinates in Source are (X,Y,Z), where X is forward/East, Y is left/North, and Z is up. (0,0,1) is a point one unit directly above the origin.

Source is using right handed coordinate system.

Coordinates are often stored alongside a set of rotation angles.

Note.pngNote:'Global' or 'absolute' coordinates refer to the coordinates of the world. All other coordinate systems are 'local' to an entity.
Note.pngNote:In world, +X is east and +Y is north. In MDLs, +X is north and +Y is west.
Note.pngNote:The compass shown when the nav_show_compass console variable is toggled shows x axis is east and y axis is south. This doesn't make any sense, because in reality, turning left from north will turn to west instead of east.

Origin

The origin of an object is the point at which its local coordinates are (0,0,0). It is the mathematical centre from which local coordinates are relative. It is rarely the centre of the visible object, however.

Tip.pngTip:There can be multiple origins within the same entity: its own origin, the origin of its model, etc. Each origin defines its own local coordinate system relative to its parent.

See also