Serving the Quantitative Finance Community

 
User avatar
Piccaso
Topic Author
Posts: 0
Joined: April 7th, 2003, 8:12 pm

Curve Sketching using Visual C++

June 18th, 2004, 1:13 am

Dear All,I am a novice in computer programming and would like to ask for your help.In order to learn programing and more numerical stuff, I am reading the book "Numerical Solutions of SDE through Computer Experiments". (By the way, I think this is a very good read for people who or weak in programming but good in math and want to learn programming while doing relevant stuff). At any rate, my course of studies has been interrupted only because I don't know how to sketch graphs using Visual C++.What I want to do is write a Visual C++ 6.0 code which can generate curves whose equations are given (in the code). For example, I want to generate a Brownian path. I have to write a code specifying the equations of approximating segments, that I can figure out. But my problem is how to display this graph? How to open a window and sketch this? Basically I guess all I need is a code in visual C++ which opens a window and draws a line segment (specified in the code). I will very very greatly appreciate any help.Thanks in advance,Ali
 
User avatar
afoster
Posts: 5
Joined: July 14th, 2002, 3:00 am

Curve Sketching using Visual C++

June 18th, 2004, 6:29 am

You have quite a few options here;1. Write code to render the whole graphic your self. 2. Buy a third party control such as ChartFX or ComponentOne Chart. This will allow you to render a chart without worrying about scaling the axis and placing labels etc.3. Use a freeware library (a quick google will turn up loads of these, such as ChartDirector for C++)4. Output the data points to a file and use something like MS Excel, or gnuplot to render the chart for you.IMHO the quickest, cheapest and by far the easiest choice would be the last one.
 
User avatar
hmerkinger
Posts: 0
Joined: May 10th, 2004, 6:39 pm

Curve Sketching using Visual C++

June 18th, 2004, 7:35 am

Picasso,it is strange that someone with your name needs help inplotting, but anyway ;-)Have a look at this:http://www.codeproject.com/miscctrl/pgl ... 2xxquoting from there:"PGL is a library that encapsulates plot capabilities in a MFC project for VC6 and VC7. It is designed to be able to easily plot data generated in a project without the need of any external software. In fact, with CView and CDialog derived classes, you can have your app display chart in 5 minutes.The aim of PGL is not to have a user-friendly environment but rather being able to generate any plot from the source code."you should be able to itegrate it in your project within 15 min.,if you are a beginner in VC++ probably 45 min.Note that it relies on Microsoft Foundation Classes, so keep thatin mind in case you need to port your code to Unix later.I would advise you to look at codeproject.com by default if youneed some functionality you do not know how to implement inVisual C++. It is IMHO by far the best code repository for VC++.HTH,Hans-Marc Erkingerwww.gloriosia.com - home of Trading with Matlab
 
User avatar
silverside
Posts: 1
Joined: January 28th, 2003, 9:57 pm

Curve Sketching using Visual C++

June 18th, 2004, 9:14 am

I concur with afoster - 4) is by far the easiest.If you have both Visual C++ and MATLAB on your machine, I have a very neat solution somewhere. Post here if you want to see it.
 
User avatar
perseus
Posts: 0
Joined: May 5th, 2003, 2:40 am

Curve Sketching using Visual C++

June 18th, 2004, 3:30 pm

Silverside,I would be very interested in the Matlab option for plotting. Could you post soultion please?
 
User avatar
silverside
Posts: 1
Joined: January 28th, 2003, 9:57 pm

Curve Sketching using Visual C++

June 18th, 2004, 4:08 pm

Here's a demonstration project which shows how to plot a 2-D curve and a 3-D surface from a simple C++ program, by using the MATLAB COM interface.It uses a wrapper class for MATLAB written by Jonathan De Halleux, the same guy who wrote the Plot Graphics Library mentioned above.I have only made some minor changes; my code is quite simple so you should have no problems understanding it.
Attachments
matlab_from_cpp.zip
(11.61 KiB) Downloaded 85 times
Last edited by silverside on June 17th, 2004, 10:00 pm, edited 1 time in total.
 
User avatar
Piccaso
Topic Author
Posts: 0
Joined: April 7th, 2003, 8:12 pm

Curve Sketching using Visual C++

June 18th, 2004, 9:18 pm

Hello all,and many thanks for all the replies.Actually searching the net for hours I finally found what I want. Let me give you the link, some other people might find it useful:http://cis.stvincent.edu/swd/graphics/Simple.cppThis is exactly what I was looking for, even though I have no idea how the code actually works, except the part which concerns drawing lines and all that (Which I know is kid's stuff compare to the rest!!).I know that Excel is used in the industry and I need to learn that also. But since I am learning C++ I thought it would be nicer(and faster and less time wasting) if I do it in C++. At any rate, discovering this code on the net was one of the most joyous moments of myrecent life......!!!Thanks again,Ali