<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=BF2_Coordinates</id>
	<title>BF2 Coordinates - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://bf2tech.uturista.pt/index.php?action=history&amp;feed=atom&amp;title=BF2_Coordinates"/>
	<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=BF2_Coordinates&amp;action=history"/>
	<updated>2026-08-06T01:15:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.40.1</generator>
	<entry>
		<id>https://bf2tech.uturista.pt/index.php?title=BF2_Coordinates&amp;diff=22&amp;oldid=prev</id>
		<title>UTurista: Creating page</title>
		<link rel="alternate" type="text/html" href="https://bf2tech.uturista.pt/index.php?title=BF2_Coordinates&amp;diff=22&amp;oldid=prev"/>
		<updated>2017-09-09T23:46:56Z</updated>

		<summary type="html">&lt;p&gt;Creating page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Battlefield 2 uses basic a basic 3-dimensional coordinate system to specify the position and orientation of objects within the game world.&lt;br /&gt;
&lt;br /&gt;
Note that only objects of the [[Object Reference#PhysicalObject|PhysicalObject]] class and classes that inherit from it ([[Object Reference#SoldierObject|SoldierObject]], [[Object Reference#ControlPointObject|ControlPointObject]], and so on) that &amp;quot;exist&amp;quot; in the game world and posssess positons and orientations. So, for example, instances of [[Object Reference#bf2.PlayerManager.Player|bf2.PlayerManager.Player]] do &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; have positions or orientations.&lt;br /&gt;
&lt;br /&gt;
So, to retrieve position and orientation for a vehicle (say, an Abrams tank), representated by the [[Object Reference#VehicleObject|VehicleObject]] &amp;lt;code&amp;gt;tank&amp;lt;/code&amp;gt;:&lt;br /&gt;
  position = tank.getPosition()&lt;br /&gt;
  rotation = tank.getRotation()&lt;br /&gt;
&lt;br /&gt;
On the other hand, to get the position and orientation of a player, representated by the [[Object Reference#bf2.PlayerManager.Player|bf2.PlayerManager.Player]] object &amp;lt;code&amp;gt;andreas&amp;lt;/code&amp;gt;:&lt;br /&gt;
  andreasSoldier = andreas.getVehicle()   # Get the [[Object Reference#SoldierObject|SoldierObject]] containing andreas&lt;br /&gt;
  position = andreasSoldier.getPosition()&lt;br /&gt;
  rotation = andreasSoldier.getRotation()&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Position ==&lt;br /&gt;
&lt;br /&gt;
Coordinates are specified by a three-element tuple, (X, Y, Z). For example:&lt;br /&gt;
  (-160.95599365234375, 162.54800415039062, -266.01699829101562)&lt;br /&gt;
Within .con files these coordinates are written with slashes: &amp;quot;X/Y/Z&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These coordinates spell out a position along three axes:&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;X&amp;#039;&amp;#039;&amp;#039; value tells how far east or west an object is; moving further east causes X to increase, moving further west causes it to decrease.&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Y&amp;#039;&amp;#039;&amp;#039; value tells your altitude; as you go higher, Y increases.&lt;br /&gt;
* The &amp;#039;&amp;#039;&amp;#039;Z&amp;#039;&amp;#039;&amp;#039; value tells how far north or south an object is; moving further north causes Z to increase, moving further south causes it to decrease.&lt;br /&gt;
&lt;br /&gt;
In all BF2 maps the origin of the coordinate system (0, 0) is at the point in the very center of the map. Each unit in the coordinate system equals approximately 1 meter in the game world.  Therefore, the example coordinate listed above will be a point 160.96 meters east and 266.02 meters south of map center, at an altitude of 162.55 meters. Note, however, that this is an &amp;quot;absolute&amp;quot; altitude; the altitude relative to the ground will depend on how high the surface of the ground is at that point; &amp;quot;sea level&amp;quot; varies quite a bit from map to map.&lt;br /&gt;
&lt;br /&gt;
There are two sizes of map included with the basic Battlefield 2 game; the size of map may be determined by using the &amp;lt;code&amp;gt;bf2.gameLogic.getWorldSize()&amp;lt;/code&amp;gt; method. This method returns a two-element tuple that gives the number of meters E/W and N/S along the edges of the map. All maps except Strike at Karkand return (2048, 2048), indicating the maps cover 4 square kilometers (2048x2048 meters), with coordinates running from -1024 to +1024 along each dimension. Strike at Karkand is the only map of a different size, and returns (1024, 1024), indicating a map covering 1 square kilometer, with coordinates running from -512 to +512 along each dimension. (&amp;lt;code&amp;gt;bf2.gameLogic.getWorldSize()&amp;lt;/code&amp;gt; appears to get it&amp;#039;s information from the &amp;lt;code&amp;gt;heightmapcluster.setHeightmapSize&amp;lt;/code&amp;gt; parameter in the file &amp;lt;code&amp;gt;Battlefield 2/mods/bf2/Levels/&amp;lt;name of map&amp;gt;/server.zip/Heightdata.con&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
The distance between any two points can easily be found by using the [[wikipedia:Pythagorean theorem|Pythagorean Theorem]]:&lt;br /&gt;
  import math&lt;br /&gt;
  &lt;br /&gt;
  def findDistance(point1, point2):&lt;br /&gt;
      &amp;lt;nowiki&amp;gt;&amp;#039;&amp;#039;&amp;#039;Use Pythagorean Theorem to find distance between two sets of coordinates.&lt;br /&gt;
      With normal BF2 scaling, the resulting distance will be in meters.&amp;#039;&amp;#039;&amp;#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
      deltaX = math.fabs(point1[0] - point2[0])&lt;br /&gt;
      deltaY = math.fabs(point1[1] - point2[1])&lt;br /&gt;
      deltaZ = math.fabs(point1[2] - point2[2])&lt;br /&gt;
    &lt;br /&gt;
      distance = math.sqrt(deltaX * deltaX +&lt;br /&gt;
                           deltaY * deltaY +&lt;br /&gt;
                           deltaZ * deltaZ)&lt;br /&gt;
      &lt;br /&gt;
      return distance&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Rotation ==&lt;br /&gt;
&lt;br /&gt;
Rotational orientation (attitude) is specified by another three-element tuple, (A, P, R). For example:&lt;br /&gt;
  (166.29025268554687, 0.0, 0.0)&lt;br /&gt;
Within .con files, these angles are written with slashes: &amp;quot;A/P/R&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;A&amp;#039;&amp;#039;&amp;#039; (&amp;quot;azimuth&amp;quot;, also known as &amp;quot;yaw&amp;quot;) gives rotation from due north going clockwise (if A is positive) or counter-clockwise (if A is negative), (or, the amount our viewpoint is rotated around a vertical axis passing through our viewpoint) measured in degrees:&lt;br /&gt;
** A=0 means due north&lt;br /&gt;
** A=90 means due east&lt;br /&gt;
** A=180 means due south&lt;br /&gt;
** A=270 means due west&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;P&amp;#039;&amp;#039;&amp;#039; (&amp;quot;pitch&amp;quot;) tells how much we&amp;#039;re tilting down compared to horizontal, (or, the amount tilted up or down along the axis passing through our viewpoint from left to right) measured in degrees:&lt;br /&gt;
** P=0 means horizontal&lt;br /&gt;
** P=45 means tilting down halfway between horizontal and vertical&lt;br /&gt;
** P=90 means looking straight down&lt;br /&gt;
** P=-45 means tilting up halfway between horizonal and vertical&lt;br /&gt;
** P=-90 means looking straight up&lt;br /&gt;
* &amp;#039;&amp;#039;&amp;#039;R&amp;#039;&amp;#039;&amp;#039; (&amp;quot;roll&amp;quot;) gives the amount the viewpoint has rolled around an axis passing from the back of our viewpoint through the front of the viewpoint, measured in degrees:&lt;br /&gt;
** R=0 means no roll&lt;br /&gt;
** R=45 means viewpoint is rolled counter-clockwise by 45 degrees&lt;br /&gt;
** R=-45 means viewpoint is rolled clockwise by 45 degrees&lt;br /&gt;
&lt;br /&gt;
If all these numbers are making your head spin, try this diagram:&lt;br /&gt;
&lt;br /&gt;
[[Image:Roll-pitch-yaw.gif]]&lt;br /&gt;
&lt;br /&gt;
Note: The pitch and roll rotational coordinates apply to aircraft and cameras in BF2, but do &amp;#039;&amp;#039;&amp;#039;not&amp;#039;&amp;#039;&amp;#039; apply to players or vehicles on the ground.  Ground players and vehicles &amp;#039;&amp;#039;&amp;#039;always&amp;#039;&amp;#039;&amp;#039; show P and R to be &amp;quot;0&amp;quot;, regardless of their actual attitude (a soldier looking straight up in the air will still have a P value of &amp;quot;0&amp;quot;, for example).&lt;/div&gt;</summary>
		<author><name>UTurista</name></author>
	</entry>
</feed>