943,496 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 7802
  • C RSS
Dec 4th, 2004
0

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

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Reagan is offline Offline
5 posts
since Nov 2004
Dec 6th, 2004
0

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

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?
Reputation Points: 10
Solved Threads: 1
Newbie Poster
nvanevski is offline Offline
12 posts
since Dec 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Help with UNIX more c code
Next Thread in C Forum Timeline: help with significant figure function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC