Posted: Mon Oct 5

Due: Tuesday 10/6 10:00am

Submission name: w09_graphs

Background Information

For this assignment, you should refer to:

Write the following functions:

  • getSineY(int theta, float amplitude, int k)
    • Returns the y value given:
      • \[y = amplitude\sin(\theta) + k\]
    • Assume theta represents a measure in degrees.
  • drawSineCurve(int x, float amplitude, int k, int d)
    • Calls getSinY, using x as the value for theta and uses that value for y.
    • Draws a dot of diameter d with the center of (x, y)
  • plotCircle(int theta, int r, int cx, int cy, int d)
    • Draws a dot of diameter d at (x, y) where (x, y) is a point on the circumference of a circle with center (cx, cy) and radius r.
    • Remember your algebra:
      • \[x = amplitude\cos(\theta) + cx\]
      • \[y = amplitude\sin(\theta) + cy\]

Put it all together:

Write a program with setup and draw to test these functions:

  • Create a 600x600 screen.
  • In draw use the current frame for theta and user that for the circle and sine curve.
  • Have the sine curve wrap back to the left side of the screen when it reaches the right edge.
  • Use the top half of the screen for the since curve.
  • Use the bottom half of the screen for the circle.

Reference Image:

a09_graphs