Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Graphics pipeline
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== The World Coordinate System ==== The world [[3d world coordinate system|coordinate system]] is the coordinate system in which the virtual world is created. This should meet a few conditions for the following mathematics to be easily applicable: * It must be a rectangular Cartesian coordinate system in which all axes are equally scaled. How the unit of the coordinate system is defined, is left to the developer. Whether, therefore, the unit vector of the system corresponds in reality to one meter or an [[Ångström]] depends on the application. * Whether a [[Left-handed coordinate system|right-handed or a left-handed]] coordinate system is to be used may be determined by the graphic library to be used. : ''Example:'' If we are to develop a flight simulator, we can choose the world coordinate system so that the origin is in the middle of the Earth and the unit is set to one meter. In addition, to make the reference to reality easier, we define that the X axis should intersect the equator on the zero meridian, and the Z axis passes through the poles. In a Right-handed system, the Y-axis runs through the 90°-East meridian (somewhere in the [[Indian Ocean]]). Now we have a coordinate system that describes every point on Earth in three-dimensional [[Cartesian coordinates]]. In this coordinate system, we are now modeling the principles of our world, mountains, valleys, and oceans. : ''Note:'' Aside from computer geometry, [[geographic coordinates]] are used for the [[Earth]], i.e., [[latitude]] and [[longitude]], as well as altitudes above sea level. The approximate conversion – if one does not consider the fact that the Earth is not an exact sphere – is simple: : <math>\begin{pmatrix} x\\ y\\ z \end{pmatrix}=\begin{pmatrix} (R+{hasl})*\cos({lat})*\cos({long})\\ (R+{hasl})*\cos({lat})*\sin({long})\\ (R+{hasl})*\sin({lat}) \end{pmatrix} </math> with R = Radius of the Earth [6.378.137m], lat = Latitude, long = Longitude, hasl = height above sea level. : All of the following examples apply in a right-handed system. For a left-handed system, the signs may need to be interchanged. The objects contained within the scene (houses, trees, cars) are often designed in their object coordinate system (also called model coordinate system or local coordinate system) for reasons of simpler modeling. To assign these objects to coordinates in the world coordinate system or global coordinate system of the entire scene, the object coordinates are transformed using translation, rotation, or scaling. This is done by multiplying the corresponding [[transformation matrix|transformation matrices]]. In addition, several differently transformed copies can be formed from one object, for example, a forest from a tree; This technique is called instancing. : To place a model of an aircraft in the world, we first determine four matrices. Since we work in three-dimensional space, we need four-dimensional [[Homogeneous coordinates|homogeneous matrices]] for our calculations. First, we need three [[rotation matrix|rotation matrices]], namely one for each of the three aircraft axes (vertical axis, transverse axis, longitudinal axis). : Around the X axis (usually defined as a longitudinal axis in the object coordinate system) <math>R_x=\begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & \cos(\alpha) & \sin(\alpha) & 0\\ 0 & -\sin(\alpha) & \cos(\alpha) & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}</math> : Around the Y axis (usually defined as the transverse axis in the object coordinate system) <math>R_y=\begin{pmatrix} \cos(\alpha) & 0 & -\sin(\alpha) & 0\\ 0 & 1 & 0 & 0\\ \sin(\alpha) & 0 & \cos(\alpha) & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}</math> : Around the Z axis (usually defined as a vertical axis in the object coordinate system) <math>R_z=\begin{pmatrix} \cos(\alpha) & \sin(\alpha) & 0 & 0\\ -\sin(\alpha) & \cos(\alpha) & 0 & 0\\ 0 & 0 & 1 & 0\\ 0 & 0 & 0 & 1 \end{pmatrix}</math> We also use a translation matrix that moves the aircraft to the desired point in our world: <math>T_{x,y,z}=\begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0\\ 0 & 0 & 1 & 0\\ x & y & z & 1 \end{pmatrix}</math>. : ''Remark'': The above matrices are [[matrix transpose|transposed]] with respect to the ones in the article [[rotation matrix]]. See further down for an explanation of why. Now we could calculate the position of the vertices of the aircraft in world coordinates by multiplying each point successively with these four matrices. Since the [[matrix multiplication|multiplication of a matrix with a vector]] is quite expensive (time-consuming), one usually takes another path and first multiplies the four matrices together. The multiplication of two matrices is even more expensive but must be executed only once for the whole object. The multiplications <math>((((v*R_x)*R_y)*R_z)*T)</math> and <math>(v*(((R_x*R_y)*R_z)*T))</math> are equivalent. Thereafter, the resulting matrix could be applied to the vertices. In practice, however, the multiplication with the vertices is still not applied, but the camera matrices (see below) are determined first. : For our example from above, however, the translation has to be determined somewhat differently, since the common meaning of ''[[Body relative direction|up]]'' – apart from at the North Pole – does not coincide with our definition of the positive Z axis and therefore the model must also be rotated around the center of the Earth: <math>T_{Kugel} = T_{x,y,z}(0,0, R+{hasl})*R_y(\Pi/2-{lat})*R_z({long})</math> The first step pushes the origin of the model to the correct height above the Earth's surface, then it is rotated by latitude and longitude. The order in which the matrices are applied is important because the [[matrix multiplication]] is ''not'' [[commutative property|commutative]]. This also applies to the three rotations, which can be demonstrated by an example: The point (1, 0, 0) lies on the X-axis, if one rotates it first by 90° around the X- and then around The Y-axis, it ends up on the Z-axis (the rotation around the X-axis does not affect a point that is on the axis). If, on the other hand, one rotates around the Y-axis first and then around the X-axis, the resulting point is located on the Y-axis. The sequence itself is arbitrary as long as it is always the same. The sequence with x, then y, then z (roll, pitch, heading) is often the most intuitive because the rotation causes the compass direction to coincide with the direction of the "nose". There are also two conventions to define these matrices, depending on whether you want to work with column vectors or row vectors. Different graphics libraries have different preferences here. [[OpenGL]] prefers column vectors, [[DirectX]] row vectors. The decision determines from which side the point vectors are to be multiplied by the transformation matrices. For column vectors, the multiplication is performed from the right, i.e. <math>v_{out} = M * v_{in}</math>, where v<sub>out</sub> and v<sub>in</sub> are 4x1 column vectors. The concatenation of the matrices also is done from the right to left, i.e., for example <math>M = T_x * R_x</math>, when first rotating and then shifting. In the case of row vectors, this works exactly the other way around. The multiplication now takes place from the left as <math>v_{out} = v_{in} * M</math> with 1x4-row vectors and the concatenation is <math>M = R_x * T_x</math> when we also first rotate and then move. The matrices shown above are valid for the second case, while those for column vectors are transposed. The rule <math>(v*M)^{T} = M^{T}*v^{T}</math><ref>{{cite book |first1=K. |last1=Nipp |first2=D. |last2=Stoffer |title=Lineare Algebra |publisher=v/d/f Hochschulverlag der ETH Zürich |date=1998 |isbn=3-7281-2649-7}}</ref> applies, which for multiplication with vectors means that you can switch the multiplication order by transposing the matrix. In matrix chaining, each transformation defines a new coordinate system, allowing for flexible extensions. For instance, an aircraft's propeller, modeled separately, can be attached to the aircraft nose through translation, which only shifts from the model to the propeller coordinate system. To render the aircraft, its transformation matrix is first computed to transform the points, followed by multiplying the propeller model matrix by the aircraft's matrix for the propeller points. This calculated matrix is known as the 'world matrix,' essential for each object in the scene before rendering. The application can then dynamically alter these matrices, such as updating the aircraft's position with each frame based on speed. The matrix calculated in this way is also called the ''world matrix''. It must be determined for each object in the world before rendering. The application can introduce changes here, for example, changing the position of the aircraft according to the speed after each frame.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)