Homework 4 - Lissajous Curves

A Lissajous curve is the graph of the system of parametric equations given by

x = A * sin(a * θ + d)
y = B * sin(b * θ)

In this lab, you will write a program that will draw Lissajous curves where A = B = 1 and a, b, and d are entered by the user.

Output Requirements

Write a graphics program that draws a Lissajous curve in a graphics window.

Input Requirements

The user enters the values of a, b, and d in that order. The program will terminate when the user enters a non-positive value for a. The value of d will be entered in degrees (and converted to radians by your application).

Process Requirements

After the user has entered the desired parameters, your application will clear the graphics window and draw the corresponding Lissajous curve.

Miscellaneous Requirements

The graphics window should be 401 pixels wide and 401 pixels high. The title of the graphics window should be "Lissajous Curve".

Since A and B are both one, the values of x and y will range from -1 to 1. Your world coordinate system should go from -1.1 to 1.1 in order to allow a bit of a margin around the Lissajous curve.

The actual drawing of the Lissajous curve should be done using a function named "drawLissajous". Here is the prototype of this function:

// drawLissajous
// Draw a curve in the specified world coordinate system
// based on the parametric equations
//     x = sin(a*theta + d)
//     y = sin(b*theta)
// where theta runs from 0 to 2*PI.
// In parameters: w, a, b, d
void drawLissajous(worldType w, double a, double b, double d)

Sample Run

A sample run showing both the console window and the resulting graphics window is illustrated below:

Sample Run

File Submission

Email me your Lab04 project file (PRJ) and program file (cpp) as email attachments.