Openwebglobe Source Analysis 3: Coordinate system

Source: Internet
Author: User

Openwebglobe's camera mainly in the Cameranode and globenavigation these two files, the former is mainly responsible for clipping matrix, Project matrix, and the latter is mainly model matrix, although the two scripts are not much code, However, to understand the matrix calculation inside, we have to start with the coordinate system (coordinate system), through the coordinate system, one step to convert our geographic sphere (ellipsoid) into a camera, the program can recognize the virtual Earth. Geodetic coordinate System

It should not be difficult to understand the geographical information system, but I do not believe that the professional, so not so accurate, although the earth we think is the ball, but from the precision, the earth is more similar to the ellipsoid; In addition, we usually use latitude and longitude to locate our place on the Earth, and in the computer World, Does not understand the concept of latitude and longitude, we need to convert to a plane Cartesian coordinate system, that is, Cartesian coordinate system, to be able to make the computer understand, this is the first step we need to deal with, there is a geodetic coordinate between the plane Cartesian coordinate system between the transformation.

Figure 1

First one end of the transformation is the geodetic coordinate system, the other end is a ball (the radius of the ball is 6378137m), as shown in the geodetic coordinate system, B for Latitude, L for longitude, H is the height from the surface, the plane Cartesian coordinates that need to be converted to XYZ, in meters, for example, The mapping relationship between geodetic coordinate system and plane Cartesian coordinate system is established.

Figure 2

The derivation process is not here to write, the online related materials are many, here only the key results, convenient for everyone's understanding.

The formula uses the geodetic coordinate system, where e is the centrifugal rate 0.006694379990197,n the earth radius, n=6378137 meters.

With the above formula, we can calculate any one by formula (BLH) to (XYZ), completed our daily life easy to understand the latitude and longitude to the usual computer easy to understand the plane Cartesian coordinate system, that is, OpenGL can recognize the coordinate system, but it is not convenient for our maintenance of the camera, for example, Usually in daily life, we fly from Beijing to New York, we are using the center as a reference system, position unchanged, and we do the plane around the center of the rotation to reach the destination, this is the reality of the way, but if we are browsing the globe, want to fly from Beijing to New York, you will move around the globe from Beijing to New York? , few people will see New York from Beijing on their own around the globe (The Globe stationary). Most people should sit in a chair, render a globe with their hands and see New York from Beijing. So there is a difference between the two, one is the Earth's center, one is a camera-centric point, and as a global software, we tend to focus on the camera as a central point to browse the globe, rather than really moving on the earth.

So, I mean, from the geodetic coordinate system to the plane coordinate system, to solve the real geographical coordinates and computer recognition of the coordinates, but the computer and the observer's direct gap between the need to convert, that is, how to use the center and Camera-centric coordinates between the conversion, so as to facilitate our browsing, thus, Need another one to introduce another coordinate

Local coordinate System

In Openwebglobe, Ned's local coordinate system is used, i.e. North, East, and down, as

Figure 3

At this point, the x axis is the north,y axis is the EAST,Z axis downward coordinate system, if we from Beijing latitude and longitude, rotation to New York latitude and longitude, and the camera perspective is not changed, you need a globe to rotate, if rotated (b,l), the relative camera coordinates rotation angle, r (x) = 90-l, R ( Z) =90+b, according to the rotation matrix of the x-axis and z-axis, and then multiply can get the coordinate system transformation matrix as follows:

In this way, we achieve a plane from the Cartesian coordinate system to the camera-centric coordinate transformation process, so that the camera as a reference system to facilitate future camera related operations, and in the shader need to get the Earth-centric camera position, the matrix inversion can be obtained, the principle is very simple, here no longer repeat, Recommend a post: http://blog.csdn.net/popy007/article/details/5120158

At this point, our coordinate transformation work is basically done, but in our usual browsing, we sometimes want to tilt the earth, that is, an operation that rotates at any angle around the XYZ axis, similar to a flight simulation experience, and involves a very simple coordinate system.

Body coordinate System

This is simpler, nothing more than an observer in the bobbing, and all rotations can be decomposed by the rotation of XYZ, for example,

In this way, the rotation matrix of the XYZ three axes is itself, and the formula for the rotation matrix is not given here.

Summarize

At this point we understand a process of the Earth's coordinates, that is, the geographical coordinates to the computer recognition of the rectangular coordinate, at the same time to facilitate later operation, need to convert to the camera as the central point of the local system, so that the camera's translation zoom to the earth corresponding to the inverse operation, I look at a globe near, such as forward 5m Actually, it's a globe moving towards you. 5m, similar operation, and I may want to look at the Earth from the angle of the plane or other angle overlooking the view, it needs my own rotation. In this way, all three coordinate systems for the Earth's construction are described here with the basic principles and corresponding formulas, the next section, speaking Openwebglobe camera, will use these relevant knowledge, but also for the contents of the later to do a theoretical foreshadowing. OK, next section: openwebglobe.camera~

Openwebglobe Source Analysis 3: Coordinate system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.