![]() ![]() Recently I had data that looked like the scatter plot, and I needed to recover the angles that correspond to the points along the curve. * create (x,y) coordinates of polar curve for (golden) logarithmic spiralĬall scatter(x,y) other="refline 0 / axis=y refline 0 / axis=x " The scatter plot shows points that lie along a logarithmic spiral as computed by the following program. But to reconstruct the curve, you need to compute angles outside that interval. The ATAN2 function enables you to compute an angle in (-π, π] for a given data point. Suppose that you have data points such as are shown in the scatter plot at the left. You can convert radians to degrees by multiplying the radian measure by 180/π. Notice also that both functions return their values in radians. Notice that the ATAN and ATAN2 functions agree for points that are in the first and fourth quadrants. Theta = i *pi/4 /* angle in [0, 2*pi) */ x = cos (theta ) /* (x,y) on unit circle */Ītan = atan ( y/ x ) /* ATAN takes one argument */Ītan2 = atan2 (y, x ) /* ATAN2 takes two arguments: Notice order! */ output Notice that order of the arguments for the ATAN2 function is the reverse of what you might expect! The ATAN2 function evaluated at ( y, x) returns the polar angle in (-π, π]. The ATAN function evaluated at y/x returns the principal arctangent function. The following statements compute the points on the unit circle for several polar angles. The ATAN and ATAN2 functions are supported in Base SAS, so you can call them from the DATA step or from the SAS/IML language. The ATAN2 function takes two arguments (the coordinates of an ( x, y) pair) and returns the angle in the range (-π, π] that corresponds to the vector angle. SAS provides the ATAN2 function for this computation. You can extend the Arctan function in a natural way: given the coordinates ( x, y) of a point in the plane, you can compute the angle formed between the x axis and the vector from the origin to ( x, y). In SAS software, the ATAN function computes the Arctan function. ![]() For example, the Arctan function returns a principal value in the range (-π/2, π/2), such as Arctan(1) = π/4. In order to obtain a unique solution to the equation, we define the "arc" functions: inverse trigonometric functions that return a principal value. For example, the solution to the equation tan(θ)=1 is θ = π/4 + kπ, where k is any integer. Equations that involve trigonometric functions can have infinitely many solutions. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |