Draw sin curve w/ user input, how to code sin()?

Reply

Join Date: Nov 2004
Posts: 5
Reputation: Reagan is an unknown quantity at this point 
Solved Threads: 0
Reagan Reagan is offline Offline
Newbie Poster

Draw sin curve w/ user input, how to code sin()?

 
0
  #1
Dec 4th, 2004
I am trying to get a program to draw a sine curve (from 0 to 2pi). It takes 8 lines to draw the complete curve. However, the user can choose to use up to 100 lines to make the curve smoother. How do I get the program to calculate that? I thought of using a counter to count through until it gets to the number of user chosen lines (m_iSample), but then I don't know how to calculate it. I just finished trig too, darn it.

for (count = 0; count<=m_iSample; ++count) {
double iSinValue=sin(count * PI);//do the sin calculation
int iFinalSinValue=iSinValue * 200;//convert result so that it will display correctly
pDC->LineTo( ??? , iFinalSinValue);//draw the line
}
Thanks Again!
Reagan
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 12
Reputation: nvanevski is an unknown quantity at this point 
Solved Threads: 1
nvanevski nvanevski is offline Offline
Newbie Poster

Re: Draw sin curve w/ user input, how to code sin()?

 
0
  #2
Dec 6th, 2004
Ok, bit by bit :

y=f(x) is the curve.

In our case, f is sin(), y is iSinValue, which makes x = count*PI.

What's not clear?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC