Solver Distance between two points in three dimensions
Algebra
->
Length-and-distance
-> Solver Distance between two points in three dimensions
Log On
Geometry: Length, distance, coordinates, metric length
Geometry
Solvers
Solvers
Lessons
Lessons
Answers archive
Answers
Source code of 'Distance between two points in three dimensions'
This Solver (Distance between two points in three dimensions)
was created by by
hummingbird(0)
:
View Source
,
Show
,
Put on YOUR site
About hummingbird
:
==section input Find distance between 2 points with the coordinates: x1 *[input x1=0] y1 *[input y1=0] z1 *[input z1=0] x2 *[input x2=1] y2 *[input y2=1] z2 *[input z2=1] You may put negative numbers for negative coordinates. ==section solution perl my $soln = sqrt(($x1-$x2)*($x1-$x2) + ($y1-$y2)*($y1-$y2) + ($z1-$z2)*($z1-$z2)); print "The distance (denoted by d) between two points in three dimensions is given by the following formula: {{{d=sqrt((x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2)}}} Thus in our case, the required distance is {{{d=sqrt(($x1-$x2)^2 + ($y1-$y2)^2 + ($z1-$z2)^2) = $soln }}} For more on this concept, refer to <A HREF=Distance_formula.wikipedia>Distance formula</A>. "; ==section output soln, ==section check x1=0 y1=0 z1=0 x2=1 y2=2 z2=2 soln=3