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 (butnot 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. (Recallthat 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 isdefined 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 singlepolyline. Your program will need to draw eight different polylines to represent the cosecant. Severalapproaches to this part of the assignment will work. My approach is to have the program check when thesign of the y-coordinate of the cosecant curve changes. When it changes, my program adds to the scenethe current polyline and then creates a new, empty polyline for the next part of the curve. Use whateverapproach you think is reasonable, as long as your code is reasonably clear and concise. Remember to setthe color to blue.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education