Question: 2 Points in 3-dimensional space can be specified by giving their x, y and z coordinates. Given two points pl-(rl,yl, z1) and p2- (x2, y2,

2 Points in 3-dimensional space can be specified by giving their x, y and z coordinates. Given two points pl-(rl,yl, z1) and p2- (x2, y2, z2) we find the distance between them using the formula: dist(pl, p2)- V(x2 - x1)2 + (y2 y1)2 +(22 - z1)2 (2 pts) Write a Python function to find the distance between two given points; i.e., the function receives two points and returns the distance between them (2 pts) Write a Python program that reads a number of points, each point specified as a triplet, finds the distance between all pairs of points, prints for each pair of points the distance that separates them -these distances must be sorted in non decreasing order- and finally, identifies and prints a pair of points that are closest and the distance between them. Suggestion: if the sequence of input points is (4,2,1), (-1,3,5), (6,9, -2), (8, -1,5) represent them in your program as the list points 4, 2,1], [-1,3,5], [6,9, -2], [8,-1,5]] For this instance the output should look like: Sorted distances between points: 6.40 6.48 7.87 9.85 11.58 12.37 A pair of closest points is: [4, 2, 1] and [8, -1, 5] with distance - 6.40 2 Points in 3-dimensional space can be specified by giving their x, y and z coordinates. Given two points pl-(rl,yl, z1) and p2- (x2, y2, z2) we find the distance between them using the formula: dist(pl, p2)- V(x2 - x1)2 + (y2 y1)2 +(22 - z1)2 (2 pts) Write a Python function to find the distance between two given points; i.e., the function receives two points and returns the distance between them (2 pts) Write a Python program that reads a number of points, each point specified as a triplet, finds the distance between all pairs of points, prints for each pair of points the distance that separates them -these distances must be sorted in non decreasing order- and finally, identifies and prints a pair of points that are closest and the distance between them. Suggestion: if the sequence of input points is (4,2,1), (-1,3,5), (6,9, -2), (8, -1,5) represent them in your program as the list points 4, 2,1], [-1,3,5], [6,9, -2], [8,-1,5]] For this instance the output should look like: Sorted distances between points: 6.40 6.48 7.87 9.85 11.58 12.37 A pair of closest points is: [4, 2, 1] and [8, -1, 5] with distance - 6.40
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
