I want to calculate the Elevation angle between Earth and Mars .I have the Mars and Earth exact position in space ,but need the elevation Angle from a specific Earth Station antenna ( e.g. canberra station ) .may help me ? thank alot
You can use the JPL HORIZONS system. Select the target body (Mars), the observer location (lat/long, or city name), and table settings (check Apparent AZ & EL). Select the time span you want if you don't like the default (every day for the next month). Then "Generate Ephemeris".
Do you really want to calculate it entirely from first principles? If not, you might find the PyEphem library useful.
Or e.g. this code: https://github.com/swift-nav/libswiftnav/blob/master/src/coord_system.c (you'll have to convert to the ECEF coordinate system first)