| Topic: |
DEVELOP > c-Plus-Plus |
| User: |
"reagan" |
| Date: |
05 Dec 2004 04:53:14 PM |
| Object: |
How to code a sin curve???? HELP! |
I am trying to get a program(in visual C++) 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
}
.
|
|
| User: "adbarnet ad@dontmailmethx" |
|
| Title: Re: How to code a sin curve???? HELP! |
05 Dec 2004 05:40:33 PM |
|
|
Forgive me if my maths is not up to scratch - but isn't the value of the y
axis a function of the x axis, where x is the angle being 'sin'ed?
If so - your x-axis should be divided by the number of lines you want to
draw:
Point point(0,0);
Point newPoint(0,0);
for (int iPointIndex = 0; iPointIndex < m_iSample; ++iPointIndex)
{
x = 360/m_iSample; // You can do this relative to PI yourself...;-)
y = sin(x);
newPoint = (x,y)
drawLine (point, newPoint);
point = newPoint;
}
"reagan" <malcolmlynnmckinley@hotmail.com> wrote in message
news:d360860f.0412051453.724591f1@posting.google.com...
I am trying to get a program(in visual C++) 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
}
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.
|
|
|
| User: "reagan" |
|
| Title: Re: How to code a sin curve???? HELP! |
06 Dec 2004 07:06:50 PM |
|
|
Not exactly sure what you mean by Point. Are point and newPoint
objects? Sorry, dumb newbie questions, I know.
adbarnet wrote:
Forgive me if my maths is not up to scratch - but isn't the value of
the y
axis a function of the x axis, where x is the angle being 'sin'ed?
If so - your x-axis should be divided by the number of lines you want
to
draw:
Point point(0,0);
Point newPoint(0,0);
for (int iPointIndex = 0; iPointIndex < m_iSample; ++iPointIndex)
{
x = 360/m_iSample; // You can do this relative to PI
yourself...;-)
y = sin(x);
newPoint = (x,y)
drawLine (point, newPoint);
point = newPoint;
}
"reagan" <malcolmlynnmckinley@hotmail.com> wrote in message
news:d360860f.0412051453.724591f1@posting.google.com...
I am trying to get a program(in visual C++) 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
}
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.
|
|
|
|
| User: "reagan" |
|
| Title: Re: How to code a sin curve???? HELP! |
06 Dec 2004 07:07:10 PM |
|
|
Not exactly sure what you mean by Point. Are point and newPoint
objects? Sorry, dumb newbie questions, I know.
adbarnet wrote:
Forgive me if my maths is not up to scratch - but isn't the value of
the y
axis a function of the x axis, where x is the angle being 'sin'ed?
If so - your x-axis should be divided by the number of lines you want
to
draw:
Point point(0,0);
Point newPoint(0,0);
for (int iPointIndex = 0; iPointIndex < m_iSample; ++iPointIndex)
{
x = 360/m_iSample; // You can do this relative to PI
yourself...;-)
y = sin(x);
newPoint = (x,y)
drawLine (point, newPoint);
point = newPoint;
}
"reagan" <malcolmlynnmckinley@hotmail.com> wrote in message
news:d360860f.0412051453.724591f1@posting.google.com...
I am trying to get a program(in visual C++) 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
}
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.
|
|
|
|
| User: "reagan" |
|
| Title: Re: How to code a sin curve???? HELP! |
06 Dec 2004 07:09:44 PM |
|
|
Not exactly sure what you mean by Point. Are point and newPoint
objects? Sorry, dumb newbie questions, I know.
adbarnet wrote:
Forgive me if my maths is not up to scratch - but isn't the value of
the y
axis a function of the x axis, where x is the angle being 'sin'ed?
If so - your x-axis should be divided by the number of lines you want
to
draw:
Point point(0,0);
Point newPoint(0,0);
for (int iPointIndex = 0; iPointIndex < m_iSample; ++iPointIndex)
{
x = 360/m_iSample; // You can do this relative to PI
yourself...;-)
y = sin(x);
newPoint = (x,y)
drawLine (point, newPoint);
point = newPoint;
}
"reagan" <malcolmlynnmckinley@hotmail.com> wrote in message
news:d360860f.0412051453.724591f1@posting.google.com...
I am trying to get a program(in visual C++) 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
}
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.
|
|
|
|
| User: "Jeremy A. Smith" |
|
| Title: Re: How to code a sin curve???? HELP! |
05 Dec 2004 06:47:23 PM |
|
|
your math is right, Y is a function of X
"adbarnet" <ad@dontmailmethx> wrote in message
news:41b39b36$1_5@127.0.0.1...
Forgive me if my maths is not up to scratch - but isn't the value of the y
axis a function of the x axis, where x is the angle being 'sin'ed?
If so - your x-axis should be divided by the number of lines you want to
draw:
Point point(0,0);
Point newPoint(0,0);
for (int iPointIndex = 0; iPointIndex < m_iSample; ++iPointIndex)
{
x = 360/m_iSample; // You can do this relative to PI yourself...;-)
y = sin(x);
newPoint = (x,y)
drawLine (point, newPoint);
point = newPoint;
}
"reagan" <malcolmlynnmckinley@hotmail.com> wrote in message
news:d360860f.0412051453.724591f1@posting.google.com...
I am trying to get a program(in visual C++) 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
}
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
.
|
|
|
|
|

|
Related Articles |
|
|