PDA

View Full Version : comet



hcrisp
05-11-2009, 10:11 AM
Has anyone written a WAVE function like the comet command in MATLAB? Or do you have any ideas how you would go about doing this?

Link to comet documentation (http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/comet.html)

"A comet graph is an animated graph in which a circle (the comet head) traces the data points on the screen. The comet body is a trailing segment that follows the head. The tail is a solid line that traces the entire function."

donb
05-11-2009, 07:46 PM
Yes, PV-WAVE has such a routine...actually, a version written to display 3D data in a 3D space. It uses a rather standard technique of continual draws and erases to accomplish this 'animation'. It's the same technique used by MATLAB in their 2D comet routine.

Here's the PV-WAVE code used to create the same data used in their comet example:


t=dindgen(2*!Pi/.01+1)*.01
x=cos(2*t)*(cos(t)^2)
y=sin(2*t)*(sin(t)^2)

Attached is this code (runfollow.pro), along with a routine that handles the 2D display case (follow.pro). Save the files to a location somewhere in the PV-WAVE path, and then at the PV-WAVE prompt enter:

@runfollow

The 3D example is also attached - save the files (runfollow3d.pro and follow3d.pro) and then at the PV-WAVE prompt enter:

@runfollow3d

You can change the length of the tail with the 'Numdisp' keyword. You'll notice some debug output to the PV-WAVE window when you run either of these routines. There is a PRINT statement added to slow things down a bit. Without this PRINT the plotting is so fast you only see the end position of the data. There is a keyword to the routines (Delay) that is used to slow things as well...the issue on Windows is you can't set the delay to fractions of a second (Windows limitation). If you run this on a Unix system, comment out the PRINT and add ', Delay=.2' to the FOLLOW or FOLLOW3D call.

Hope this helps,

Don B.

hcrisp
05-14-2009, 02:20 PM
Thanks, Don, that is most helpful. I may have to tweak it a bit to change the solid tail into a fading one, but I'm glad to know a routine already exists for this. Most appreciated.