subject

Write 2 programs and submit on Autolab.

We provide this ZIP FILE containing PolygonTransform. java, and Sierpinski. java. For each problem update and submit the corresponding file.

Observe the following rules:

DO NOT use System. exit().
DO NOT add the project or package statements.
DO NOT change the class name.
DO NOT change the headers of ANY of the given methods.
DO NOT add any new class fields.
ONLY display the result as specified by the example for each problem.
DO NOT print other messages, follow the examples for each problem.
USE StdIn, StdOut, and StdDraw libraries.
Polygon transform (25 points). Write a library of static methods that performs various geometric transforms on polygons. Mathematically, a polygon is defined by its sequence of vertices (x0, y 0), (x 1, y 1), (x 2, y 2), …. In Java, we will represent a polygon by storing the x– and y-coordinates of the vertices in two parallel arrays x[] and y[].Three useful geometric transforms are scale, translate and rotate.

Scale the coordinates of each vertex (x i, y i) by a factor α.
x‘i = α xi
y‘i = α yi
Translate each vertex (x i, y i) by a given offset (dx, dy).
x‘i = xi + dx
y‘i = yi + dy
Rotate each vertex (x i, y i) by θ degrees counterclockwise, around the origin.
x‘i = xi cos θ – yi sin θ
y‘i = yi cos θ + xi sin θ
Write a two-dimensional transformation library by implementing the following API:public class PolygonTransform {

// Returns a new array object that is an exact copy of the given array.
// The given array is not mutated.
public static double[] copy(double[] array)

// Scales the polygon by the factor alpha.
public static void scale(double[] x, double[] y, double alpha)

// Translates the polygon by (dx, dy).
public static void translate(double[] x, double[] y, double dx, double dy)

// Rotates the polygon theta degrees counterclockwise, about the origin.
public static void rotate(double[] x, double[] y, double theta)

// Tests each of the API methods by directly calling them.
public static void main(String[] args) `

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:00
Write a function that draws a pool ball. this function should take as parameters, the color, the number that should go on the pool ball, and the location of the center of the pool ball. the radius of the pool balls should be pool_ball_radius, and the font of the number should be pool_ball_font. the text of the pool ball font should be white. drawpoolball(color.orange, 5, 100, 100); drawpoolball(color.green, 6, 50, 200); drawpoolball(color.red, 3, 150, 350); drawpoolball(color.blue, 2, 250, 140); to center the numbers on the pool ball, you should use the getwidth() and getheight() methods. you are allowed to call these methods on your text object, such as txt.
Answers: 3
question
Computers and Technology, 23.06.2019 16:30
You have read about the beginnings of the internet and how it was created. what was the internet originally created to do? (select all that apply) share research. play games. communicate. share documents. sell toys
Answers: 1
question
Computers and Technology, 23.06.2019 19:40
Use a physical stopwatch to record the length of time it takes to run the program. calculate the difference obtained by calls to the method system.currenttimemillis() just before the start of the algorithm and just after the end of the algorithm. calculate the difference obtained by calls to the method system.currenttimemillis() at the start of the program and at the end of the program so that the elapsed time includes the display of the result. use the value returned by the method system.currenttimemillis() just after the end of the algorithm as the elapsed time.
Answers: 3
question
Computers and Technology, 23.06.2019 20:30
What are some settings you can control when formatting columns?
Answers: 1
You know the right answer?
Write 2 programs and submit on Autolab.

We provide this ZIP FILE containing PolygonTrans...
Questions
question
Computers and Technology, 29.09.2019 02:30
Questions on the website: 13722359