Write a program that plots the sine function in red and the cosecant function in blue. Hints: The above scene is 800 pixels wide and 600 pixels tall. On the x-axis, -2π is at pixel (200, 300), the...


Write a program that plots the sine function in red and the cosecant function in blue.


Hints: The above scene is 800 pixels wide and 600 pixels tall. On the x-axis, -2π is at pixel (200, 300),
the center of the axis is at (400, 300), and 2π is at (600, 300). Draw your text for these points near (but
not directly on) these coordinates. The Unicode for π is \u03c0. To display -2π, use Text(x, y, “-
2\u03c0”). My program used Font.font("Georgia", 25) as the font for each of the Text objects. (Recall
that you use the setFont(…) on a Text object to set its font.


For a trigonometric function like Math.sin(x), x is in radians. You can use the following loop to add the points to a polyline for the sine curve: Polyline sineCurve = new Polyline();


ObservableList list = sineCurve.getPoints();


for (double x = -340; x <= 340;="" x++)="">
list.add(x + 400);
list.add(300 – 100 * Math.sin((x / 200.0) * 2 * Math.PI));


Your program can draw the entire sine curve as a single polyline. Remember to set its color to red.


The cosecant is a little trickier. Recall from your pre-calculus course that the cosecant (csc) function is
defined by csc(x) = 1 / sin(x). Because the cosecant curve approaches positive and negative infinity,
alternately, on each side of each vertical asymptote, it will not work to draw the cosecant curve as a single
polyline. Your program will need to draw eight different polylines to represent the cosecant. Several
approaches to this part of the assignment will work. My approach is to have the program check when the
sign of the y-coordinate of the cosecant curve changes. When it changes, my program adds to the scene
the current polyline and then creates a new, empty polyline for the next part of the curve. Use whatever
approach you think is reasonable, as long as your code is reasonably clear and concise. Remember to set
the color to blue.

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here