How to code a sin curve???? HELP!



 DEVELOP > c-Plus-Plus > How to code a sin curve???? HELP!

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
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

.



  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER