## March 3rd 2015, Track Rendering Engine

← January 25th 2015 Track Rendering | ● | March 4th 2015 Software Rendering Pipeline →

As outlined in the last blog entry, we need to implement a 3D track rendering engine.

The situation for displaying a GPS track in 3D is as follows:

A track consists of a series of points in ECEF coordinates. Those points construct a path by a sequence of line segments with two points each.

Those points need to be projected from the ECEF or world coordinate system into the camera coordinate system. This task is accomlished by the so called computer graphics **rendering pipeline**. The stages of the (simplified) pipeline are as follows:

- Define 3D points in the
**world**coordinate system. - Apply a
**modelling**transformation**M**to perform translations and rotations. - Apply the
**viewing**transformation**V**to the points to end up with points in the 3D camera coordinate system. - Apply the perspective
**projection**transformation**P**which projects the points onto the 2D image plane. - Take two projected points and clip each line segment in homogeneous
**clip coordinates**to remove parts that are invisible, i.e. outside the viewing frustum. - Transform the clip coordinates into
**normalized device coordinates**(NDC). - Transform the NDC coordinates into
**window pixel coordinates**. **Rasterize**the line segment using a 2D painting library (like QPainter).

So the main two tasks are the transformation of points and the clipping of line segements. Both tasks can be done in homogeneous coordinates, since all of the above required transformations of the pipeline can be represented by a sequence of multiplications of **4×4 matrices** with a 4D vector in homogeneous coordinates.

Given a 3D vector $\vec{p}$, the representation of $\vec{p}$ in homogeneous coordinates is $\vec{p} = (p_x, p_y, p_z, 1)$.

Then the perspective transformation of $\vec{p}$ onto the image plane using the 4×4 matrices $M_M$, $M_V$ and $M_P$ can be written as:

or in general:

$M_{MVP}$ is the so called combined Model-View-Projection Matrix with $M_{MVP} = M_P\cdotM_V\cdotM_M$.

← January 25th 2015 Track Rendering | ● | March 4th 2015 Software Rendering Pipeline →