3

I have two XYZ coordinates and I would like to calculate the Distance, Azimuth and Dip between them.

I have come across a similar question on this site that calculates it the other way around (with a given starting coordinate and a given Distance, Azimuth and Dip and it calculates an end coordinate.)

I have been trying to figure it out and I am sure its very simple.

Here is that other question page. It says that this is a conversion between a spherical and Cartesian coordinates.

How to convert Distance, Azimuth, Dip to XYZ?

  • Thank you very much for your help but I calculate distance and it not same yours this is mine =5.590169944 – Kasem May 2 '17 at 19:36
8

For a line, it is a plunge and not a dip (for 3D planes)

It is an elementary problem in analytic geometry:

The distance = SQRT((x2 –x1)2+(y2 –y1)2+(z2 –z1)2)

The plunge = arcsin ((z2 – z1) / distance)

The azimuth = arctan((x2 –x1)/(y2 –y1)) (always in two dimensions)

The value θ returned will be in the range of ±90° and must be corrected to give the true azimuth over the range of 0 to 360°

You can also use the direction cosines of the line (the slopes on the xy, xz and yz planes)

enter image description here

In Python:

 import math
 x1,y1,z1 = 5.0,6.7,1.5
 x2,y2,z2 = 4.0,1.2,1.6
 distance = math.sqrt((x2-x1)**2+(y2-y1)**2+(z2 -z1)**2)
 print distance
 5.5910642993977451
 plunge = math.degrees(math.asin((z2-z1)/distance)
 print plunge
 1.0248287567800018 # the resulting dip_plunge is positive downward if z2 > z1
 azimuth = math.degrees(math.atan2((x2-x1),(y2-y1)))
 print azimuth
 -169.69515353123398 # = 360 + azimuth = 190.30484646876602 or  180+ azimuth = 10.304846468766016 over the range of 0 to 360°

With the direction cosines:

cosalpha =(x2-x1)/distance
cosbeta=(y2-y1)/distance
cosgamma= (z2-z1)/distance
plunge = math.degrees(math.asin(cosgamma))
print plunge
1.0248287567800018 # the resulting dip_plunge is positive downward if z2 > z1
azimuth = math.degrees(math.atan2(cosa, cosb))
print azimuth
-169.69515353123398 #  = 360 + azimuth = 190.30484646876602 or  180+ azimuth = 10.304846468766016 over the range of 0 to 360°
0

azimuth in ruby

def cartographical_azimuth_radians(point1, point2)
  Math::atan2(point2.x-point1.x, point2.y-point1.y)
end

def cartographical_azimuth_decimal_degrees(point1, point2)
  180/Math::PI * cartographical_azimuth_radians(point1, point2)
end

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.