Computers and Technology
Computers and Technology, 14.04.2020 17:26, kate5582

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) `

answer
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 24.06.2019 10:00, ariyanadavid5989
1. which of these is not true about torsion bars? a. they can be used to adjust ride height b. they can be adjusted anytime since they don't affect alignment angles c. they attach between the frame and the lower control arm d. they twist to produce a spring effect
Answers: 1
image
Computers and Technology, 24.06.2019 14:30, tleppek6245
Alison is having a hard time at work because hee inbox is flooded with emails every day. some of these emails are unsolicited. some of other she don’t need. which action should she take to better manager her emails?
Answers: 1
image
Computers and Technology, 24.06.2019 20:00, impura12713
Avirus enters a computer or network as code embedded in other software directly from another computer
Answers: 1
image
Computers and Technology, 25.06.2019 03:30, eamber646
Which task should happen during the planning stage of a project
Answers: 2
Do you know the correct answer?
Write 2 programs and submit on Autolab.

We provide this ZIP FILE containing PolygonTrans...

Questions in other subjects:

Konu
Chemistry, 18.02.2020 04:19
Konu
Mathematics, 18.02.2020 04:19