Mail Archives: djgpp/1999/03/16/12:25:40
Greetings,
I believe that the trig. functions require the angle argument to be in
radians not degrees. Maybe that's where it's going wrong.
Regards
Ya'qub
Lester Davis wrote in message <36EE71C9 DOT 6A160A75 AT bellsouth DOT net>...
>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.
>Thanks
>Ringo
>
>
>
>
>#include <conio.h> // For the getch() function.
>#include <stdio.h>
>#include <math.h>
>#define cone 20
>int main()
>{
>//screen is 640 W 480 H
> double x1,x2,y1,y2;
> int angle,posangle,negangle;
> int range;
>double cx1,cx2,cy1,cy2;
>
>for(range=15;range<200;range=range+15)
> {
> angle=45;
> posangle=angle+10;
> negangle=angle-10;
> x1=range*cos(posangle);
> y1=range*sin(posangle);
> x2=range*cos(negangle);
> y2=range*sin(negangle);
> printf("x1=%d y1=%d x2=%d y2=%d
>\n",(int)x1,(int)y1,(int)x2,(int)y2);
> }
>return 0;
>}
>
>
- Raw text -