mathomatic/tests/pyth3d.in

11 lines
507 B
Plaintext

; This arrives at the distance between two points in 3D space from the
; Pythagorean theorem (distance between two points on a 2D plane).
; The coordinate of point 1, 2D: (x1, y1), 3D: (x1, y1, z1).
; The coordinate of point 2, 2D: (x2, y2), 3D: (x2, y2, z2).
distance2D^2=(x1-x2)^2+(y1-y2)^2 ; Distance formula for a 2D Cartesian plane.
distance3D^2=distance2D^2+(z1-z2)^2 ; Add another leg.
eliminate distance2D ; Combine the two equations.
distance3D ; Solve to get the distance in 3D Cartesian space.