RE: [GD-DEVEL] Re: plotting data c++
| From: | Bill Frost | Date: | Fri, 01 Feb 2008 14:11:41 +0000 |
| Subject: | RE: [GD-DEVEL] Re: plotting data c++ | ||
| References: | 1 | Groups: | php.gd.devel |
| Request: | Send a blank email to php-gd-devel+get-348@lists.php.net to get a copy of this message | ||
Hi guys,
This has always sounded to me like an ideal gdLib application.
I had a bit of spare time today and I was intrigued by the problem. I dug
out some existing C++ code and modified it a bit and it now plots Patolfo's
data points as a square wave in JPEG format. If I keep the number of samples
at 256 but vary the number of terms from a high, such as 128, a square wave
is generated. If the number of terms is then set low, such as 8, a
sinusoidal-square wave is generated. Looks nice as a curved plot!
Selecting 256 samples with 128 terms runs in 0.093 seconds on a Centrino, as
gdLib / C++ is very fast.
Note that it is a utility, not a GUI application. It runs Padolfo's test
data application and opens the file using the operating system's default
JPEG handler (typically Windows Picture and Fax Viewer).
It:
* runs the sample algorithm,
* saves the sample data to a file and closes it (normally user-supplied)
* re opens the file
* extracts all data into a class, finding max and min values
* sets up a device context in gdLib, with some scaling
* creates the JPEG and thumbnail
* iterates the class and plots each x, y to a pixel
* scales and labels the axis
I've just fixed a rather embarrassing buffer overrun and I need to do a
little code clean up and make the JPEG slightly more aesthetic. Then I'll
post the source as a royalty free utility (seeing Padolfo wrote the main
algorithm!) as an example of using gdLib. Comments welcome once I have done
this as I am by no means an expert on gdLib and I still don't really know
what FFT is all about.
Cheers,
Bill
-----Original Message-----
From: Patolfo [mailto:patolfo@gmail.com]
Sent: Thursday, 31 January 2008 10:15 AM
To: Bill Frost; gd-devel@lists.php.net
Subject: [GD-DEVEL] Re: plotting data c++
ok guys here is the problem again, i am plotting x,y data, floats to be
precise, must be in C, C++, the hardway, no perl or python just know how
to us perl a little, the idea is to have the application data to do the
approximation of a square wave by means of fourier series, the job is
done, now the problem is the gui, well i tried tk with perl and
everything went smootly, till the part of converting perl to C, and
including the interpreter and all that stuff, truly i did not get it
right so it freezes and is buggy, so well back in track i found my self
on the same road, just C, the gui I plan to do them with windowsapi they
are the lesser problem, mingw, but the plotting data per se is the
biggest problem, i tried reading the wiki for libgd, and let me tell you
it is not for noobs, or at least not for the dumbest as me.
The algorithm says more or less:
number or harmonics, number of data points, using gui, some routines,
and then we have and arbitrary number of data with a max value of 1 and
the minimum of 0, arranged in pairs of x,y,
i have the suspicion it is straightforward, but i seem to fail, i am
still googling, found koolplot, which i think uses libgd, did not work
for my mingw, so, any directions where to look...
--
GD Devel Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php