
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%
![Write a library of static methods that performs various geometric transforms on polygons.
Mathematically, a polygon is defined by its sequence of vertices (xo, y o), (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.
o Scale the coordinates of each vertex (x, y ) by a factor a.
o X;= a Xi
o y;=ay
o Translate each vertex (x , y ) by a given offset (dx, dy).
o X; = X; + dx
o yj=y+ dy
o Rotate each vertex (x , y) by 0 degrees counterclockwise, around the origin.
O X; = X; Cos 0 – y sin e
o y;= y cos 0 + x; sin e
Write a two-dimensional transformation library by implementing the following API:](https://content.bartleby.com/qna-images/question/74421972-28ed-49d6-8e87-16c50a75fe8c/e9bfa7f2-c38e-4174-8763-ab1c21aad75c/t49914c_thumbnail.png)
Transcribed Image Text:Write a library of static methods that performs various geometric transforms on polygons.
Mathematically, a polygon is defined by its sequence of vertices (xo, y o), (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.
o Scale the coordinates of each vertex (x, y ) by a factor a.
o X;= a Xi
o y;=ay
o Translate each vertex (x , y ) by a given offset (dx, dy).
o X; = X; + dx
o yj=y+ dy
o Rotate each vertex (x , y) by 0 degrees counterclockwise, around the origin.
O X; = X; Cos 0 – y sin e
o y;= y cos 0 + x; sin e
Write a two-dimensional transformation library by implementing the following API:
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 3 images

Knowledge Booster
Similar questions
- Make A Dice Simulator in Python. First, we import the library that allows us to choose random numbers. import random Now, we can generate a random number and save it in a variable, We will call it rolled Python library random has a function called randint (). The randint (min number, max number) requires 2 parameters (the lowest number and the highest number between we will pick our number randomly). In this case, our dice goes between 1-6. rolled = random.randint (1,6) If we want to show our selected number, we can use print (). Your code should look like this: import random rolled - random.randint(1,6) print(rolled) Nice, we already have our main engine working, now it's time to make it look more appealing. To do that we will add some improvements (we will use a new variable to store random generated numbers - rolled_num) import random rolled num - random.randint(1,6) print("You rolled: ", rolled num) If we run the code again, we should see a little message and the random number. Our…arrow_forwardWrite a Java method that receives a two-dimensional array of primitive ints ( int [] [] ). The array can have any number of rows and any number of items per row. Also, the array can be “ragged” (not all rows have the same number of items). Have the method return the average of all of the items in the array as a primitive double.arrow_forwardWrite a Java method named addArray which takes two arrays of same size as parameters. The method should return a third array that is the element-wise sum of the two arrays. For example, if the two input arrays are [1,2,3] and [4,5,6], then the returned array should be [5, 7, 9]. [ 1, 2, 3] + [ 4, 5, 6] = [1+4, 2+5, 3+6] = [5,7,9] Call addArray in main method to test the above example. Print the returned array in the main method. Write a JAVA code pleasearrow_forward
- write a java class definition 4. Give the class definition of ArrayChecker which has an integer array variable arr. This has 2 methods a. Constructor which take an integer parameter numElements and reads all the numElements from the user using Scanner class into arr. b. public boolean checkConsecutiveValues (int n), which checks whether arr has atleast n consecutive elements with the same values. (it is enough if it returns the first occurrence of n consecutive elements) (Write only the class definition of ArrayChecker) Eg. 12345555 10, if n = 4, this has four consecutive 5s, return true 10 12 111 11456666. If n = 3, this has 3 consecutive 1s, return true. 10 12 111 11456666. If n = 7, then return falsearrow_forwardWrite a Java program that expands a given binomial (x + y)^n, where integer n is user input. To do the work of the binomial expression, first create a method that accepts n as a parameter and then returns an array holding the coefficients needed for the binomial expansion using the Pascal’s Triangle method. Create a 2nd method which takes the array holding the coefficients as a parameter and prints the appropriate binomial expansion. For example, if n = 5 is entered by the user, the method calculating the coefficients should return {1,5,10,10,5,1} and the method that prints the expansion should print the following: (x + y)^5 = x^5 + 5x^4y + 10x^3y^2 + 10x^2y^3 + 5xy^4 + y^5 Your main method should use an appropriate loop for repeated inputs and automatically call the methods to calculate the coefficients and print the binomial expansion. There isn’t a need for a menu although you should ask the user if they want to quit or continue after their binomial expansion is printed each time.…arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY