2 Replies - 2732 Views - Last Post: 07 June 2011 - 07:14 PM Rate Topic: **--- 3 Votes

#1 nazmul_nazim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-April 11

sine wave

Posted 01 June 2011 - 09:32 PM

problem:how i can superimpose this two waves??
error: no compilation error
information:i have used graphics.h
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<process.h>
#include<math.h>
#include<dos.h>
#define PI 3.1416
int main()
{
int gdriver=DETECT,gmode,errorcode;
int x,x1;
double y,y1;
char ch;
int COLOR;
clrscr();
printf("Initiating graphics mode press any key to continue");

initgraph(&gdriver,&gmode,"C:\\TC\\BGI\\");
errorcode=graphresult();
if(errorcode!=0)
{
printf("ERROR:%s",grapherrormsg(errorcode));
getch();
exit(1);
}
/*to do here*/

for(x=0,x1=0,COLOR=1;!(kbhit());x++,x1++)
{
y=sin(x*PI/180);
if(y>0)
putpixel(x,int(y*100)+100,COLOR);
if(y<0)
putpixel(x,int(100-(-1)*y*100),COLOR);
y1=cos(x1*PI/180);
if(y1>0)
putpixel(x1,int(y1*100)+100,COLOR+1);
if(y1<0)
putpixel(x1,int(100-(-1)*y1*100),COLOR+1);
if(COLOR==16)
COLOR=0;
if(x>630)
{
x=0;
COLOR=0;
}
else COLOR=1;
if(x1>630)
{
x1=0;
COLOR=0;
}
else COLOR=1;
delay(10);
}
getch();
closegraph();
return 0;
}


This post has been edited by nazmul_nazim: 01 June 2011 - 09:34 PM


Is This A Good Question/Topic? 0
  • +

Replies To: sine wave

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: sine wave

Posted 01 June 2011 - 10:08 PM

well I could be wrong but I believe that superposition of waves is addition.

so just add the y values and plot with the same x.
Was This Post Helpful? 1
  • +
  • -

#3 nazmul_nazim  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 10-April 11

Re: sine wave

Posted 07 June 2011 - 07:14 PM

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1