delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/03/16/12:25:40

From: "Ya'qub" <rick AT nct-active DOT com>
Newsgroups: comp.os.msdos.djgpp
References: <36EE71C9 DOT 6A160A75 AT bellsouth DOT net>
Subject: Re: Trig Help
Date: Tue, 16 Mar 1999 16:53:18 -0000
Lines: 51
X-Newsreader: Microsoft Outlook Express 4.72.3115.0
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
NNTP-Posting-Host: 193.123.236.199
Message-ID: <36ee8a84.0@nnrp1.news.uk.psi.net>
X-Trace: 16 Mar 1999 16:44:52 GMT, 193.123.236.199
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019