( Index )

Brief Information about the Nov '07 CSIG Meeting

Lissajous Patterns

C++ Version 7 and Visual Studio 2005

Written by B. Arnold

Lissajous Patterns

Welcome to the CSIG, a Special Interest Group of the ACGNJ. We will be discussing Windows Programming using Visual C++ 2005 from Microsoft.

A program will be presented which displays oscilloscope type wave forms know as Lissajous Patterns. The code uses the latest C++ compiler in Microsoft's Visual Studio 2005. The program may also be compiled using the free C++ Express compiler. Some of the items that we will discuss are as follows.

Windows Programming with Microsoft Managed code
Windows Graphics
Microsoft Visual Studio 2005
Events and Controls

Back before the Civil War, about the year 1850, a French physicist Jules Lissajous developed a method for comparing frequencies. His purpose was to manufacture tuning forks with the proper resonant frequency. He found that if he mounted a small mirror on the reference tuning fork he could reflect a light beam onto a screen. If he then added the test tuning fork with a mirror vibrating at 90 degrees to the first, he would create a pattern on the screen. The pattern showed the exact frequency and phase relationship between the two tuning forks. Just imagine: his standard 'A' tuning fork vibrated at 435 cycles per second. If the second tuning fork vibrated at only 434 cycles per second, he would know by looking at his "LISSAJOUS" pattern.

Most people who use oscilloscopes have been taught this phenomenon but he used it first. The program for this month demonstrates this situation by taking two Sine Waves and plotting them on X and Y axises of a window that looks like an oscilloscope. It uses the latest Microsoft .Net C++ compiler and its window, graphics, and math libraries.

This is an exciting time for the C Language programming since Microsoft now has 4 different language compilers: C++, C++ Express, C-Sharp, and C-Sharp Express. These are all capable of creating Windows (tm) programs and the "Express" versions are free ! I see also that Microsoft is advertising a still newer version, Visual Studio 2008 Beta. Additionally, there are other companies making free and almost free compilers. Here's a link with many compilers: http://www.willus.com/ccomp.shtml

Microsoft .NET Framework Version 2.0

This is a large package, about 24 Megs. Most people running updated versions of WinXP will already have it on their computer. If not, it may be downloaded from Microsoft.

Here's the download address for the Microsoft Framework:
Microsoft Software
Or, just look for: Microsoft .NET Framework Version 2.0 Redistributable Package (x86)

There are a number of ways to refer to this compiler and code.

The beginning of the evening (starting at 7:30pm) will be a RANDOM ACCESS discussion. The main presentation will discuss the program.

Our download site has code and programs from most of our meetings. ( Source Code Files )

Sample Code - VC7

Sample Code
             double xfreq;
             double yfreq;
             double phase;
             double pi;

private: System::Void pictureBox1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
                 SolidBrush^ beamBrush = gcnew SolidBrush(System::Drawing::Color::GreenYellow);
                 Pen ^ pen1 = gcnew Pen(Brushes::Green);
                 Rectangle rr;      int x, y;
                 int xmax = pictureBox1->Size.Width;
                 int ymax = pictureBox1->Size.Height;

                 for (int i=0; iGraphics->DrawLine(pen1, 0, i, xmax, i);

                 for (int i=0; iGraphics->DrawLine(pen1, i, 0, i, ymax);

                 for (int t=0; t<5000; t += 1)      // Let's calculate a lot of time points or dots. x=sin(2*pi*f*t)
                     // Now vary the calculation over a 10 sinewave cycle range: 0 ... 20*pi;  (360 degrees = 2*pi)
                     x = (xmax/2) + (int)((xmax/2) * Math::Sin((2.0 * pi * xfreq * (double)t / 500.0) + phase));
                     y = (ymax/2) + (int)((ymax/2) * Math::Sin((2.0 * pi * yfreq * (double)t / 500.0)        ));
                     rr = Rectangle(x-3, y-3, 6, 6);
                     e->Graphics->FillEllipse(beamBrush, rr);   // it's a 6 pixel circle.
                 delete beamBrush;
                 delete pen1;

private: System::Void phaseBar_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
             phase = (pi /2.0) * ( (double)phaseBar->Value / 25.0);
             PhaseDegrees->Text = (phase * 180.0/ pi).ToString();

private: System::Void yfreqBar_ValueChanged(System::Object^  sender, System::EventArgs^  e) {
             yfreq = 1.0 * ( (double)yfreqBar->Value / 25.0);
             YFrequency->Text = yfreq.ToString();
private: System::Void Form1_Resize(System::Object^  sender, System::EventArgs^  e) {

"Random Access" questions start at 7:30 Tuesday night.


Source Code Files

For help, email me at b a r n o l d @ i e e e . o r g
Back to C++ Main Page