Organize the correct code statements to find the distance between point (x1, y1) an...
Check the final answer first, then review the worked steps.
Answer
\(xDist = Math.pow(x2 - x1, 2); yDist = Math.pow(y2 - y1, 2); pointsDistance = Math.\sqrt{xDist + yDist};\)
Approach
xDist = (x2 - x1)^2; yDist = (y2 - y1)^2; Dist = sqrt(xDist + yDist)
Step-by-step solution
- Calculate the squared difference for the x-coordinates: $xDist = Math.pow(x2 - x1, 2);$.
- Calculate the squared difference for the y-coordinates: $yDist = Math.pow(y2 - y1, 2);$.
- Use the square root function to find the final distance: $pointsDistance = Math.sqrt(xDist + yDist);$.