Question

In: Computer Science

Define two C structures, one to represent rectangular coordinates and one to represent polar coordinates. Rewrite...

Define two C structures, one to represent rectangular coordinates and one to represent polar coordinates. Rewrite the rec_to_polar function to use variables declared using the new structures.

Solutions

Expert Solution

thanks for the question, here is the code in C language, I have created the two structures, however the function rec_to_polar was not shared, I have assumed the function will take in a rectangular struct object and return a polar struct object.

Hope this helps, let me know for any help with any other question.

here is the code.

===============================================================

#include<stdio.h>

#include<math.h>

struct RectangularCordinate{

               

                float x;

                float y;

};

struct PolarCordinate{

               

                float radius;

                float theta;

};

struct PolarCordinate rect_to_polar(struct RectangularCordinate rect){

               

                float radius = pow(rect.x*rect.x + rect.y*rect.y,0.5);

                float angle = atan(rect.y/rect.x);

               

                struct PolarCordinate pol = {radius,angle};

               

                return pol;

}

int main(){

               

                struct RectangularCordinate rect {3,4};

               

                struct PolarCordinate pol = rect_to_polar(rect);

               

                printf("Radius: %.2f\n", pol.radius)          ;

                printf("Angle: %.2f\n", pol.theta)              ;

}

===============================================================


Related Solutions

Determine the following for a point with the rectangular coordinates (1.380, 2.690) m. (a) the polar...
Determine the following for a point with the rectangular coordinates (1.380, 2.690) m. (a) the polar coordinates r and θ (Enter your answers to at least three significant figures.) r = m θ = ° (b) the rectangular coordinates of the point with the polar coordinates (2r, θ) x = m y = m (c) the rectangular coordinates of the point with the polar coordinates (r, 2θ) x = m y = m
(MUST BE DONE IN C (NOT C++)) Define two different structures at the top of your...
(MUST BE DONE IN C (NOT C++)) Define two different structures at the top of your program. Define each structure with exactly three members (each member has to be a different datatype). You may set them up whichever way you want. Don’t forget your semicolons. - Inside main, declare two structures. One for each of the two structures you defined. - Then, initialize each one of the members manually (the three members of your first structure and the three elements...
Separate the wave equation in two-dimensional rectangular coordinates x, y. Consider a rectangular membrane, rigidly attache...
Separate the wave equation in two-dimensional rectangular coordinates x, y. Consider a rectangular membrane, rigidly attache to supports along its sides, such that a ≤ x ≤ 0 and b ≤ y ≤ 0. Find the solution, including the specification of the characteristic frequencies of the membrane oscillations. In the case of a = b, show that two or more modes of vibration correspond to a single frequency
Two vectors in polar coordinates (R, θ) are given byV1 = (5.0, 125°) and V2 =...
Two vectors in polar coordinates (R, θ) are given byV1 = (5.0, 125°) and V2 = (4.0, 260°). Find the sum V1 + V2 in polar coordinates. Give the answer to 2 significant figures for the magnitude and to the nearest degree in angle. Hint: first convert the vectors to Cartesian form and add them to get the resultant vector. Then convert this resultant vector to polar form
Solve the two-dimensional wave equation in polar coordinates and discuss the eigen values of the problem.
Solve the two-dimensional wave equation in polar coordinates and discuss the eigen values of the problem.
Consider a particle that is free (U=0) to move in a two-dimensional space. Using polar coordinates...
Consider a particle that is free (U=0) to move in a two-dimensional space. Using polar coordinates as generalized coordinates, solve the differential equation for rho and demonstrate that the trajectory is a straight line.
Convert from rectangular to polar form and vice versa: a. ?6 b. 2√5∠135∘ c. −2 −...
Convert from rectangular to polar form and vice versa: a. ?6 b. 2√5∠135∘ c. −2 − ?2√3 d. √2∠45∘ Please show your steps because I need to understand how we reached the solution Thank you
2) Give examples of “Cartesian” and “polar” coordinates. Explain how we translate between the two coordinate systems.
2) Give examples of “Cartesian” and “polar” coordinates. Explain how we translate between the two coordinate systems.     Answer: Cartesian is ( x, y) and polar is (r, theta)3) The force table generates a force at its center by means of a hanging mass attached to a string. What formula do we use to calculate the force generated given a certain amount of hanging mass?   Answer: From newtons second law. f=ma, a=g hence f=mg4) What formula do we use to calculate...
C++ Write a program that creates two rectangular shapes and then animates them. The two shapes...
C++ Write a program that creates two rectangular shapes and then animates them. The two shapes should start on opposite ends of the screen and then move toward each other. When they meet in the middle of the screen, each shape reverses course and moves toward the edge of the screen. The two shapes keep oscillating and bouncing off of each other in the middle of the screen. The program terminates when the shapes meet each other in the middle...
which one of the following molecules is polar? a. CS2, b. SO2 c. XeF2 d.XeF4, e....
which one of the following molecules is polar? a. CS2, b. SO2 c. XeF2 d.XeF4, e. SO3
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT