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_iSampl e; ++count) {
double iSinValue=sin(c ount * PI);//do the sin calculation
int iFinalSinValue= iSinValue * 200;//convert result so that it will
display correctly
pDC->LineTo( ??? , iFinalSinValue) ;//draw the line
} 5 3974
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" <ma************ *****@hotmail.c om> wrote in message
news:d3******** *************** ***@posting.goo gle.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_iSampl e; ++count) { double iSinValue=sin(c ount * 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
your math is right, Y is a function of X
"adbarnet" <ad@dontmailmet hx> wrote in message
news:41******** **@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" <ma************ *****@hotmail.c om> wrote in message news:d3******** *************** ***@posting.goo gle.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_iSampl e; ++count) { double iSinValue=sin(c ount * 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
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" <ma************ *****@hotmail.c om> wrote in message news:d3******** *************** ***@posting.goo gle.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_iSampl e; ++count) { double iSinValue=sin(c ount * 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
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" <ma************ *****@hotmail.c om> wrote in message news:d3******** *************** ***@posting.goo gle.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_iSampl e; ++count) { double iSinValue=sin(c ount * 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
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" <ma************ *****@hotmail.c om> wrote in message news:d3******** *************** ***@posting.goo gle.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_iSampl e; ++count) { double iSinValue=sin(c ount * 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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Josiah Carlson |
last post by:
Good day everyone,
I have produced a patch against the latest CVS to add support for two
new formatting characters in the struct module. It is currently an RFE,
which I include a link to at the end of this post. Please read the
email before you respond to it.
Generally, the struct module is for packing and unpacking of binary
data. It includes support to pack and unpack the c types:
byte, char, short, long, long long, char, *, and...
|
by: Vinodh Kumar |
last post by:
Number One:
=========
I know its a 100% offline post.But seeing the diversity of the domain from
which people are participating,
I would like to post this question here.Pardon me.At the least, u can guide
me to the proper newsgroup.Thanks.
Number Two:
=========
I want to draw a curve for a set of observations(i.e, x,y pairs) using
|
by: MLH |
last post by:
This question, I apologize, is more of a math question than it is
an Access question - I'm almost certain.
The bell curve is another name for the normal distribution, which is a
common type of graph that has more or less the shape of a bell. "The
Bell Curve" was also the title of a book, a controversial book back in
1994. It was about intelligence. If you graph scores on an IQ test on
the horizontal axis, and number of people who got...
|
by: nmukh1 |
last post by:
Hey guys,
I'm trying to optimize a program that measures the length of a curve.
Suppose I define a function f and I have two bounds and am trying
to find the arc length. The familiar calculus equation
/
| sqrt(1+f'(x)) dx provides us the arc length.
/
I'm trying to use C to numerically find the arc length.
|
by: Sandy |
last post by:
I have two tables, tblPost - (Cols PostID, TopicID, UserID, Question, PostMsg
and PostDT) and tblTopic - (Cols TopicID, Topic). I am trying to get
tblPost.Question and tblPost.PostDT into DataGrid1 when the DropDownList1
(which consists of Topic) is clicked.
I have the following code:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
| |
by: Peter Olcott |
last post by:
Cab you write code directly in the Common Intermediate language? I need to
optimize a critical real-time function.
|
by: anand |
last post by:
Dear all,
I am trying to "find the area under the curve f(x)=sin(x)/x for x=1 to
3"
a) Use the trapezoidal rule method. Prove that your trapezoidal rule
method is second order
accurate (using he program)
b) Use the Romberg method. Compare the grid size neccessary to get
convergence to within 1e-8 using TR (part a) versus the Romberg method.
|
by: babyinc |
last post by:
Please help me. I am totally beginner of C++ and my tutor give us these huge program to solve within 20 days. As a MSc student I am really gonna cry. Please anyone can help me. sumon1in1@yahoo.com
Here is added assignment:
http://eent3.lsbu.ac.uk/staff/dimitrsa/OOPN/Assignment/OOPN_assignment_2006-07.pdf
• Your Application
Example: You can either select to design one of the following recommended fractals:
1. Peano curve
2. Hilbert...
|
by: sa6113 |
last post by:
Hello there,
I have a problem on curve fitting , would you please help me ?!
I want to to develop a application that reads a text file with 2 columns of floating point data (as x and y) and performs a polynomial curve fit of the data at the order specified by the end user and then provides the curve-fit coefficients
as well as the curve fit errors.
My problem is in curve fit errors , I want to abtain Max and L2-norm of error.
In...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |