The GPS information contained within a gpx file specify the locations of points along a route in polar coordinates, whose axes are latitude, longitude, and elevation.
The units of latitude and longitude are in degrees, while elevation is expressed as meters above sea level (where sea level is at the base radius of the earth).
The challenge is to map the GPS polar coordinates of latitude, longitude and elevation (which lie on the curved surface of the earth) to flat cartesian (x,y,z) coordinates.
Let's assume that the GPS coordinates you'll be dealing with are relatively close together, such that the curvature of the earth can be ignored. This makes it easier to perform a simple mapping.
Using this assumption, the polar elevation coordinate can be directly mapped to a cartesian z-coordinate; that is, the elevation IS the z-coordinate: za = Ea for any coordinate a.
For small distances between any two GPS coordinates a and b, the approximate cartesian distances between the coordinates can be expressed as:
Δx = [R + (Eb + Ea)/2] (φb - φa) cos[(θb+θa)/2]
Δy = [R + (Eb + Ea)/2] (θb - θa)
Δz = Eb - Ea
Where the angle θ is the latitude, φ is the longitude, E is the elevation, and R is the base radius of the earth.
Note that these formulas require the angles to be specified in radians, not degrees.
Also, since these formulas describe RELATIVE cartesian distances between any two points, the ABSOLUTE value of x and y must be stipulated. For example, you can establish that, by definition, the first coordinate on a GPS path is x0=0, y0=0.
Alternately, you can simply declare that the GPS coordinates of some "base point" (for example, the center of the MSOE athletic field) is, by definition, at x=0, y=0.
Finally, the total distance along the path can be computed by summing the individual distances between successive cartesian coordinates.
Similarly, the total elevation gain along the path can be computed by summing only the positive changes in elevation between successive cartesian coordinates.