954,157 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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

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

Reagan
Newbie Poster
5 posts since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

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?

nvanevski
Newbie Poster
12 posts since Dec 2004
Reputation Points: 10
Solved Threads: 1
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You