gem/oq-hazardlib — pull request #150 by monellid (2013-12-19 12:17:04+00:00)
Title: Make Rx Distance calculation working properly with complex geometries

This pr makes the ``Rx`` distance calculation working properly when dealing with complex (that is non planar) rupture surfaces.

'Rx' is the horizontal distance from a site to the rupture top edge. It's positive when the site is on the 'hanging-wall' (that is the block on the right of the fault trace), and negative on the 'foot-wall' (that is the block on the left). Notice that right and left are defined with respect to the direction of the fault trace.

In the current master, the calculation approximate the rupture top edge as a straight line with an azimuth equal to the average azimuth of the rupture top edge.

This approximation does not reflect the complexity in the rupture surface as can be seen below:

![rxdistancemaster](https://f.cloud.github.com/assets/351361/1782188/b44e7138-68a6-11e3-8b51-e1ebf701669b.png)

and may create strange patterns when calculating the ground motion fields. Below I show the median ground shaking using Abrahamson and Silva 2008:

![mediangroundmotionfieldmaster](https://f.cloud.github.com/assets/351361/1782198/e616203a-68a6-11e3-967e-b941751ce572.png)

I changed the distance calculator so that it takes into account changes in direction of the rupture top edge, and therefore a more realistic ground motion pattern is obtained:

![rxdistancefixed](https://f.cloud.github.com/assets/351361/1782201/128ae650-68a7-11e3-961e-cc39be48047c.png)

![mediangroundmotionfieldfixed](https://f.cloud.github.com/assets/351361/1782205/21015098-68a7-11e3-8dca-c655cc62d128.png)

Notice that I implemented also an optimized version of the Rx distance for planar surfaces that does not require the construction of a mesh.

I had to updated some tests, because there was an error in the definition of the strike angle.