please don't send this answer.If you don't know the answer let others answer it.
Posted: Mon May 09, 2022 5:56 am
please don't send this answer.If you don't know the answer let others answer it.
Answers Program: #include<iostream> #include<math.h> using namespace std; main() { double x[100] [100],[100],cen_x,cen_y,cen_z.x_sum=0y_sum=0,z_sum=0,d; int in cout<<"Please enter number of 3d point you want to enter": cin>>n; for(i=0;i<n;i++) cin>>x>>y>>z[0]: for(i=0;i<n;i++) { X_sum = x_sum + x; yusum = y_sum + y): z_sum =z_sum + z(0; ) cen.x = x_sum/n: cen_y = y_sum/n; cen_z = z_sum/n: cout<<"\n\nControid of the given points: ("<<cen_x<<","<<cen_y<<", "<<cen_z<<")" for(i=0;i<n;i++) { d= sart(((cen_x - x). (cen_x - x)) + ((cen_y-yD) (cen_y-yo)) + ((cen_2-2[1]) (cen_2-2[0)); cout<<"\nDistance between the controid ("<<cen_x<<","<<cen_y<<","<<cen_z<<") and point ("<<x<<", "<<y<<","<<z<<") is: "<<d; } return 0; } Sample output: Please enter number of 3d point you want to enter: Z 15 17 5 -11 -13 0 13 6 Controid of the given points (6. Distance between the controid (6 Distance between the controid (6. Distance between the controid (6 Distance between the controid (6. and point (12.-2..22) is: 16.2897 8) and point (z. 15. 17) IS: 14.4417 32 8) and point is -11.-13) is 25.6819 8) and point ie 13,6) is: 11. 2055
Data point's centroid Calculator is a simple application without graphics that calculates the centroid of a collection of data points. In mathematics, the centroid is the mean position of all the points in all of the coordinate directions. In this project, your project should have the ability to: 1. Read the points coordinates (x, y and z coordinates), then, 2. Calculates and displays the centroid of the points, and finally, 3. Finds the Distance between calculated centroid (point) and all stored data points. Figure 1 shows a mathematical walk through example of two-dimensional coordinates. Notice that this is a 2-D example; Meaning that it operates on points having 2-dimensional coordinates (x and y). You need to include z coordinates in your calculations. Centroid (5,489) The centroid of the points (-12.93), (19.2), (,)...., (x,y) is *.X, Y + y + y n n1 Figure 1: the centre of a 2-D plots
Where n is the number of stored points in your system. Then after calculating the value of the centroid, you need to use following formula to find the distance between the calculated centroid and all stored data points in your system. Distance Formula: Given the two points (x1, yı) and (x2, y2), the distance between these points is given by the formula: d = //-
* +(y2-yi) cer(5,489)dl d2 d3 db The centroid of the points (-13.33), (17.92), (5.%..., (twy.) is (**.5 *** *****, ********** 71 Figure 2: distance between calculated centroid and all stored data points Figure 2 shows an example of two-dimensional coordinates and the calculated distance between the centroid and all data points (dl, d2, d3, ....). Project Menu Description Use Functions and Menu to solve each part of project as flowing description: 1. User Menus: a. Add a new point and its corresponding coordinates (x,y and z coordinates) from the user (keyboard input). b. Delete a point and its corresponding coordination (x,y and z coordinates) using point ID entered by the user. c. Edit a point coordination (x, y and z coordinates) using point ID entered by the user.
2. File Menus: a. Read a set of points coordinates (x, y and z coordinates) from a data file without duplication, where Figure 2 shows the structure of data file. b. Write all points' coordinates to a data file. 3. Data Points Menus: a. Display stored points, point ID and its corresponding coordinates (x, y and z coordinates) on the screen. b. Calculate and display the Centroid of stored points. c. Display the distance between the calculated centroid and all stored data points 4. Exit
Point ID's must be unique (no 2 points can have the same ID). For example, the point IDs, below, are 4, 5, 2, 1, and should not be 2, 5, 2, 1 Sample data file: 4 5 4 4 3 -2 5 -4 -3 - 1 2 2 -9 8 6 1 This sample should be stored as: 5 4 3 -2 Coordination -4 -3 - 1 (x, y, z) -9 8 6 4 5 Point ID 2 1 4 # Points Figure 3: example of input data file
Answers Program: #include<iostream> #include<math.h> using namespace std; main() { double x[100] [100],[100],cen_x,cen_y,cen_z.x_sum=0y_sum=0,z_sum=0,d; int in cout<<"Please enter number of 3d point you want to enter": cin>>n; for(i=0;i<n;i++) cin>>x>>y>>z[0]: for(i=0;i<n;i++) { X_sum = x_sum + x; yusum = y_sum + y): z_sum =z_sum + z(0; ) cen.x = x_sum/n: cen_y = y_sum/n; cen_z = z_sum/n: cout<<"\n\nControid of the given points: ("<<cen_x<<","<<cen_y<<", "<<cen_z<<")" for(i=0;i<n;i++) { d= sart(((cen_x - x). (cen_x - x)) + ((cen_y-yD) (cen_y-yo)) + ((cen_2-2[1]) (cen_2-2[0)); cout<<"\nDistance between the controid ("<<cen_x<<","<<cen_y<<","<<cen_z<<") and point ("<<x<<", "<<y<<","<<z<<") is: "<<d; } return 0; } Sample output: Please enter number of 3d point you want to enter: Z 15 17 5 -11 -13 0 13 6 Controid of the given points (6. Distance between the controid (6 Distance between the controid (6. Distance between the controid (6 Distance between the controid (6. and point (12.-2..22) is: 16.2897 8) and point (z. 15. 17) IS: 14.4417 32 8) and point is -11.-13) is 25.6819 8) and point ie 13,6) is: 11. 2055
Data point's centroid Calculator is a simple application without graphics that calculates the centroid of a collection of data points. In mathematics, the centroid is the mean position of all the points in all of the coordinate directions. In this project, your project should have the ability to: 1. Read the points coordinates (x, y and z coordinates), then, 2. Calculates and displays the centroid of the points, and finally, 3. Finds the Distance between calculated centroid (point) and all stored data points. Figure 1 shows a mathematical walk through example of two-dimensional coordinates. Notice that this is a 2-D example; Meaning that it operates on points having 2-dimensional coordinates (x and y). You need to include z coordinates in your calculations. Centroid (5,489) The centroid of the points (-12.93), (19.2), (,)...., (x,y) is *.X, Y + y + y n n1 Figure 1: the centre of a 2-D plots
Where n is the number of stored points in your system. Then after calculating the value of the centroid, you need to use following formula to find the distance between the calculated centroid and all stored data points in your system. Distance Formula: Given the two points (x1, yı) and (x2, y2), the distance between these points is given by the formula: d = //-
2. File Menus: a. Read a set of points coordinates (x, y and z coordinates) from a data file without duplication, where Figure 2 shows the structure of data file. b. Write all points' coordinates to a data file. 3. Data Points Menus: a. Display stored points, point ID and its corresponding coordinates (x, y and z coordinates) on the screen. b. Calculate and display the Centroid of stored points. c. Display the distance between the calculated centroid and all stored data points 4. Exit
Point ID's must be unique (no 2 points can have the same ID). For example, the point IDs, below, are 4, 5, 2, 1, and should not be 2, 5, 2, 1 Sample data file: 4 5 4 4 3 -2 5 -4 -3 - 1 2 2 -9 8 6 1 This sample should be stored as: 5 4 3 -2 Coordination -4 -3 - 1 (x, y, z) -9 8 6 4 5 Point ID 2 1 4 # Points Figure 3: example of input data file