Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting polar degrees to coordinates.

Status
Not open for further replies.

jerryreeve

Vendor
Jan 16, 2002
2,765
US
I am trying to convert a list of polar coordinates (in degrees not pi) and distance from center to XY coordinates. Problem is that x=r COS(angle) and y = r sine(angle) while returntin to me values the positive and negative values are a bit hosed

Code:
	R	     Angle	     X	        Y	         expected quad`	       resultant quad
	Distance  Angle	     R Cos(Angle) R Sine(Angle) (1-90 I) (90-180 2) etc  (+,+ q1)(-,+ q2)(-,- q3) etc
1    4.39      220.514624	   3.615426602   2.490138648	III	               I
2    4.39      220.5086908	  3.63013724    2.468644085	III	               I 
3    8.6       101.5693036	  4.365809477   7.40943369	 II	                I
4	10.5       53.38094708   -10.49641616    0.274313163	I	                 II
5	11.4	  317.6069916    -10.86996747   -3.435666933	Iv	                III
6	11.4	  317.6030641    -10.88337744   -3.392947914	Iv	                III
7	11.4	  115.1453482     -5.236114523  10.12635693	 II	                II
8	11.8	  331.7618106      3.754261488 -11.18684588	 Iv	                Iv
9	11.9	   26.08947075     6.856733126   9.726006932	I	                 I
10   15.9	  153.2679944    -12.46231427    9.874245447	II	                II
11   16.5	   63.99576602     6.529859842  15.15291822	 I	                 I
12   16.6	  272.1195961     -6.031152544  15.46561344	 Iv	                II
13   16.6	  272.1225627     -6.077005821  15.44765355	 Iv	                II
14   16.8	  298.5250696    -16.75431086   -1.238171125	Iv	                III
15   18.8	  293.9063649      3.133402155 -18.53703835	 Iv	                Iv
16   19.3	  224.9916435      6.939011071 -18.00944545	 III	               Iv

Only lines 8 9 10 11 and 15 give me the expected result that is the coordinates for x and y being (+,+) for quadrant 1 (+,-) for quadrant 2 (-,-) for quad 3 and (-,+) for quad 4 by that I mean in line 1 with an anble of 220 degrees I know the result will be in the third quad but the formula result is showing first quad. What am I missing? do I need to do a complex if statement to define the quads first then figure the resulting angles into coordinates?



----------------------------
Hill?? What hill??
I didn't see any $%@#(*$ Hill!!
----------------------------
JerryReeve
Communication Systems Int'l
com-sys.com

 
All your results are wrong and it's not the problem of sign only: SIN and COS functions require arguments in radians, you pass degrees ([radians] = [degrees] * PI() /180)

combo
 
Thanks, it has been years since algebra and I couldn't bring it back up in the mind even though I knew what I was looking for with the results. R COS (Degrees * PI()/180) is giving me a good output. I thought that the number results were off but I was trying to get the quadrants straight first, Probably should have been working on finding the correct formula first. appreciate it.

----------------------------
Hill?? What hill??
I didn't see any $%@#(*$ Hill!!
----------------------------
JerryReeve
Communication Systems Int'l
com-sys.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top