You sample the 3 vertices from the heightfield that forms a triangle around your position, and then calculate the height of the triangle at that position.
Not sure why you would do that manually when you have PhysX though.. as there's a method to get the height anywhere in the height-field, the getHeight(x, y) method.
I'm sure Unity has similar methods exposed to scripts, a quick Google shows TerrainData.GetHeight(x, y).
If you need to do it manually, you have to do the same triangle-grid as PhysX does. Each triangle forms a plane, the height of which you should be able to easily calculate when you have a position (calculate intersection of the plane along the vertical line at that position).