Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

HW 6 In 3 D space, the Cartesian coordinates ( x , y , z ) can be converted to spherical coordinates ( radius r

HW 6
In 3D space, the Cartesian coordinates (x,y,z) can be converted to spherical coordinates (radius r, polar angle, , azimuth angle, ) by the following equations:
r=x2+y2+z22,=cos-1(zr),=tan-1(yx)
Write a function fn_printspherical that prints the Cartesian coordinates (x,y,z) and corresponding spherical coordinates, (r,,). The function fn_ printspherical calls a subfunction fn_convert2spher that converts from Cartesian to spherical coordinates.
Write a script, CartSpher that reads the Cartesian coordinates from an external file, convert to spherical coordinate, and print the results. When the script reads the Cartesian coordinates from a file, assume that x,y,z are saved in matrix, thus fn_printspherical should be in the loop to print all the results.
Here is the requirement for the script:
xYZ.txt
\table[[8.1,1.6,6.6],[9.1,9.7,0.4],[1.3,9.6,8.5],[9.1,4.9,9.3],[6.3,8,6.8],[1,1.4,7.6],[2.8,4.2,7.4],[5.5,9.2,3.9],[9.6,7.9,6.6],[9.6,9.6,1.7]]
Read the file (XYZ.txt) by using the following function
-input (Let user input file name)
-load (read the file that user input)
When you load the data, assign the data values to the matrix variable. Use this matrix variable as input variable(s) to the function, fn_printspherical
Display should follow the below format
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Introduction To Databases And Data Warehouses

Authors: Nenad Jukic, Susan Vrbsky, Svetlozar Nestorov

1st Edition

1943153191, 978-1943153190

More Books

Students also viewed these Databases questions