View Full Version : comet

05-11-2009, 09: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."

05-11-2009, 06: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:


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:


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


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.

05-14-2009, 01: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.