Question

Instructions: Solve using Python programming language. Submit a single script file 6) Using composition of functions,...

Instructions: Solve using Python programming language. Submit a single script file

6) Using composition of functions, show how rotation and translation are not commutative transformations.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have pasted the code and screenshot of sample run of code below. We have mainly 2 functions rotate2d and translate2d. We compute new point n1 by first applying translation and then rotatation and n2 by first applying rotation and then translation. We can see the picture below that the points n1 and n2 are not same so we can say that, rotation and translation are not commutative transformations.

------------------------Screenshot-----------------------

------------------------Script-----------------------

import numpy as np

sin = np.sin
cos = np.cos

def rotate2d(point,theta):
   # convert angle form degree to radians
   theta = theta/180*np.pi
   x,y = point
   new_point = [x*cos(theta) - y*sin(theta), x*sin(theta) + y*cos(theta)]
   return new_point

def translate2d(point,t):
   new_point = [point[0]+t[0], point[1]+t[1]]
   return new_point

thetas = [30,45,90]
translations = [[1,2],[2,2],[1,0]]
point = [1,1]

for theta,t in zip(thetas,translations):
   n1 = rotate2d(translate2d(point,t),theta)
   n2 = translate2d(rotate2d(point,theta),t)
   print("%s %s"%(str(n1),str(n2)))

Add a comment
Know the answer?
Add Answer to:
Instructions: Solve using Python programming language. Submit a single script file 6) Using composition of functions,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • USING PYTHON PROGRAMMING LANGUAGE 15. Write code to open a file named data.txt, which contains 3...

    USING PYTHON PROGRAMMING LANGUAGE 15. Write code to open a file named data.txt, which contains 3 numbers, and print the sum of those numbers to the console 16. Write code that opens a file named words.txt containing an essay, and the prints out the SECOND word in the file to the console

  • PYTHON PROGRAMMING LANGUAGE Task 5 Open a csv file for writing create 3 rows that store...

    PYTHON PROGRAMMING LANGUAGE Task 5 Open a csv file for writing create 3 rows that store username, first name, last name and age data (four columns) write the data to the csv file under the correct column Task 6 Open the file in task 5) and read its contents Output the content in a tabular format of columns and values

  • python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used...

    python Programming Exercise 4.7 Write a script that decrypts a message coded by the method used in Project 6. Method used in project 6: Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypted string separates the resulting bit strings. An example of the program input and output is shown below: Enter the coded text: 0010011 1001101 1011011 1011011...

  • I need help with this python programming exercise, please! thanks in advance Create a Python script...

    I need help with this python programming exercise, please! thanks in advance Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...

  • Please Solve this problem using Visual Basic Programming Language (show design Interface and programming codes): Q....

    Please Solve this problem using Visual Basic Programming Language (show design Interface and programming codes): Q. The Interface provides a text box, for the user to enter his or her current salary. The Calculate Button's Click Event Procedure should calculate the new salary amounts using rates of 2% through 6% in increment's of 0.5%. The procedure should display the rates and salary amounts in the lblNewSalary control. Code the procedure using the For....Next statement. Save the work.

  • Answer the following questions using linux 1) Write a Python script so that a file whoComesForDinner.txt...

    Answer the following questions using linux 1) Write a Python script so that a file whoComesForDinner.txt formatted like this:      Tuesday we have Joe McHungry and Paul McHungry Wednesday we have Cindy Johnston and Paul Paulsen Thursday we have Amin Mirzaei and Atefeh Mirzaei gets turned into that: The McHungry on Tuesday Cindy and Paul on Wednesday The Mirzaei on Thursday 2)Write a script that takes as argument a port number. It returns the next port that is not assigned to...

  • This problem demonstrates the use of import module. The Python programming language has many strengths, but...

    This problem demonstrates the use of import module. The Python programming language has many strengths, but one of its best is the availability to use many existing modules for various tasks, and you do not need to be an experienced computer programmer to start using these modules. We have given you some incomplete code; note that the very first line of that code contains an import statement as follows: import math This statement enables your program to use a math...

  • Using mat lab to do it Create a single script file named yourname_While.m to answer the...

    Using mat lab to do it Create a single script file named yourname_While.m to answer the following problems. The file must be in cell mode to distinguish each problem. Make sure your script is nicely commented for each problem. Consider the following matrix of values: x =[345, 23, 17, 34, 85, 334, 111, 1067] Use a for loop and if statement to determine how many values greater than 30? Use fprintf to display the result. Repeat Problem 1., but use...

  • Please solve the following problem with programming using proper data structures. (Programming Language: Python) A similar...

    Please solve the following problem with programming using proper data structures. (Programming Language: Python) A similar application to the parentheses matching problem comes from hypertext markup language (HTML). In HTML, tags exist in both opening and closing forms and must be balanced to properly describe a web document. This very simple HTML document: Example> Hello, world is intended only to show the matching and nesting structure for tags in the language. Write a program that can check an HTML document...

  • Using Python programming language to solve this thanks!!! An engineer has derived a relationship between the...

    Using Python programming language to solve this thanks!!! An engineer has derived a relationship between the force applied to a material and the extension in length that the force would cause. The relationship between force f and extension e is given by: e = { 5.5f if 0 < f < 10 f2 – 10f + 55 if 10 < f < 20 The aim of this task is to specify a list of values which are the values of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT