Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Two distances are required to specify the location of a point relative to an ori

ID: 3680719 • Letter: T

Question

Two distances are required to specify the location of a point relative to an origin in two dimensional space: The horizontal and vertical distances (x, y) in Cartesian coordinates, or The radius and angle (r, theta) in polar coordinates It is relatively straightforward to compute Cartesian coordinates (x, y) on the basis of polar coordinates (r, theta). The reverse process is not so simple. The radius can be computed by the following formula: r = x^2 + y^2 If the coordinates lie in the first or fourth quadrant (i.e.,.x > 0), then the following simple formula can be used to compute theta. theta = tan^-1 (y/x) The difficulty arises for the other two quadrants and when x = 0. The table summarizes the possibilities. a. Write a well-structured flowchart for a VBA Sub procedure to calculate r and theta as a function of x and y. Express the final results for theta in degrees.

Explanation / Answer

Private Const PI As Double = 3.14159265358979

Private Function TanI(x As Double, y As Double) As Double

If x > 0 Then

TanI = Atn(y / x)

ElseIf x < 0 Then

TanI = Sgn(y) * (Pi - Atn(Abs(y / x)))

ElseIf y = 0 Then

TanI = 0

Else

TanI = Sgn(y) * Pi / 2

End If

End Function
Public Function CtoP(y As Double, x As Double)

Dim r as Double = Sqr(x*x + y*y)
Dim theta as Double = TanI(x,y)

End Function

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote