From: Chris Hut Newsgroups: comp.os.msdos.djgpp Subject: Re: Trig Help Date: Thu, 18 Mar 1999 07:55:53 GMT Organization: Deja News - The Leader in Internet Discussion Lines: 26 Message-ID: <7cqbi6$2ro$1@nnrp1.dejanews.com> References: <36EE71C9 DOT 6A160A75 AT bellsouth DOT net> NNTP-Posting-Host: 205.252.81.184 X-Article-Creation-Date: Thu Mar 18 07:55:53 1999 GMT X-Http-User-Agent: Mozilla/4.0 (compatible; MSIE 4.01; Windows 98) X-Http-Proxy: 1.1 x13.dejanews.com:80 (Squid/1.1.22) for client 205.252.81.184 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com ringo1 AT bellsouth DOT net wrote: > Hi, IM trying to plot readings gathered from a scanning sonar device. I > get angle and range readings and would like to see them graphically. But > my problem is I'm trying to convert the (R,A) into (X,Y) but get > negative numbers alot of the time. RIght now I'm using an angle of 45 > and varying the range and looking at the data. To get X im using > R*cos(a), and y = r*sin(a). Its been a long time since trig, but I > thought this was correct, Can someone tell me whats wrong, my code id > below. Your problem (I think...) is that C uses angles measured in radians. You'll need to convert your angle measurements into radians and then manipulate those numbers. There are 2*pi radians in a circle, so you need to multiply by your number by 2(pi)/360 or pi/180 to get a new angle which you operate on. I think PI is a constant in math.h. You also need to convert the 10 degrees (in the posangle and negangle initializations) into radians -- that last detail stumped me when I was trying to figure this out. > Ringo Chris -----------== Posted via Deja News, The Discussion Network ==---------- http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own