Question: Write a function drones to import a CSV file available online which is created by the 3D imaging system. On each line of the CSV

Write a function drones to import a CSV file available online which is created by the 3D imaging system. On each line of the CSV file, it contains information about a sphere around drone. The first three integers on each line represent the centre of the sphere in three dimensional space, which are x, y and z. The fourth integer on the line represents the radius of the sphere. All dimensions are provided in meters.

The function needs to provide the output that informs which of the spheres are colliding or touching each other and which are not touching with any other sphere. In addition, how many overlaps between two spheres exist? One overlap is considered when two spheres around drones touch or intersect each other. Therefore, one sphere around a drone can have multiple overlaps or touches with many other spheres around other drones. The distance between two points (x_1,y_1,z_1) and (x_2,y_2,z_2 ) in three dimension can be found by:

In addition, the function also needs to plot the spheres in three dimensional spaces [use surf or mesh] in one figure having two plots [use subplot]. In the first plot all spheres returned are plotted. While in the second plot only non-touching spheres are plotted. Dont forget to label the axes and include the title for each plot. Follow all the guidelines of plotting and visualization explained to you during the lectures. Ensure that the view of your plots look similar to the referenced plots shown in testing results in Cody Coursework. [Hint: You need to study these commands: subplot, surf, mesh, sphere, view]

Below is the sample function definition mentioning the inputs and required outputs.

[touches, touchlist, ntouchlist] = drones(fileLink)

where input fileLink is the link of the CSV file and the outputs are: touches: Number of overlaps/touches among all spheres present in the CSV file. touchlist: A structure containing information of all spheres which have overlap with any other sphere. The fields of the structure are: x, y, z and radius. The order of spheres data must remain the same as provided in the CSV file excluding non-touching spheres. ntouchlist: A structure containing information of all spheres which are not touching any other sphere. The fields of the structure are: x, y, z and radius. The order of spheres data must remain the same as provided in the CSV file excluding touching spheres.

The sample CSV file provided is drone.csv which is available on LMS and at the link ( http://teaching.csse.uwa.edu.au/units/CITS2401/drone.csv ). Following are the sample commands and their results for validating your code. The sample data is provided for testing purpose and values of answers need to be matched. Ignore text formatting of the commands and their outputs. The sample plots generated by the execution of the sample command are also given below. Remember your default plots may look different depending on the use of surf or mesh. You need to rotate plots in 3D so that they look like the reference plots. For Cody Coursework, change the view of the plot to ensure that it looks similar to the reference testing plots.

>> fileLink = 'http://teaching.csse.uwa.edu.au/units/CITS2401/drone.csv';

>> [touches, touchlist, ntouchlist] = drones(fileLink)

touches = 15

touchlist = 1x8 struct array with fields:

 x 
 y 
 z 
 radius 

ntouchlist = 1x2 struct array with fields:

 x 
 y 
 z 
 radius 

>> struct2table(touchlist)

ans =

 x y z radius 
 _ _ __ ______ 
 5 3 8 4 
 4 7 3 3 
 2 2 9 1 
 5 5 10 4 
 5 0 -1 2 
 7 4 2 3 
 8 6 2 4 
 8 3 3 5 

>> struct2table(ntouchlist)

ans =

 x y z radius 
 __ __ __ ______ 
 12 14 10 7 
 0 2 1 3 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!