Need to draw a triangle from A, B, and C. all of which are 2*1 matrices containing
Fantastic news! We've Found the answer you've been seeking!
Question:
Need to draw a triangle from A, B, and C. all of which are 2*1 matrices containing the x and y coordinates created using numpy array function. Struggling to find a way to properly plot the triangle without the gap at the base.
Transcribed Image Text:
pp.py Lo_p².py import numpy as np import matplotlib.pyplot as plt A = np.array( [[0], [0]]) B = np.array([[0], [1]]) C = np.array([[1], [0]]) s_x = float(input('Please enter scale factor in x direction: ')) s_y = float(input('Please enter scale factor in y direction: ')) scale_matrix = np.array([[s_x,0], [0,s_y]]) print (scale_matrix) r = float(input('Please enter angle of rotation in degrees: ')) r = r * (np. pi/180) rotation_matrix = np.array([[np.cos(r), -np.sin(r)], [np.sin(r), np.cos(r)]]) print (rotation_matrix) composite_matrix = rotation_matrix @ scale_matrix print(composite_matrix) Af = composite_matrix @ A Bf = composite_matrix @ B Cf = composite_matrix @ C print(Af, '\n\n', Bf, '\n\n',Cf) plt.axis('equal') plt.grid () plt.plot (A,B,C, color= 'b') plt.show() L [[0.5 0.] [[0.] 10 [0.]] 0.8 0.6 0.4 In [37]: | 0.2 Console 1/A X 0.0 [0. 1.5]] Please enter angle of rotation in degrees:30 [[ 0.8660254 -0.5 [ 0.5 [[ 0.4330127 [ 0.25 [[-0.75 [ 1.29903811]] [[0.4330127] [0.25 ]] -0.2 0.0 0.8660254]] -0.75 ] 1.29903811]] ] 0.2 0.4 0.6 0.8 10 Help Variable Explorer Plots Files IPython Console History Terminal 12 pp.py Lo_p².py import numpy as np import matplotlib.pyplot as plt A = np.array( [[0], [0]]) B = np.array([[0], [1]]) C = np.array([[1], [0]]) s_x = float(input('Please enter scale factor in x direction: ')) s_y = float(input('Please enter scale factor in y direction: ')) scale_matrix = np.array([[s_x,0], [0,s_y]]) print (scale_matrix) r = float(input('Please enter angle of rotation in degrees: ')) r = r * (np. pi/180) rotation_matrix = np.array([[np.cos(r), -np.sin(r)], [np.sin(r), np.cos(r)]]) print (rotation_matrix) composite_matrix = rotation_matrix @ scale_matrix print(composite_matrix) Af = composite_matrix @ A Bf = composite_matrix @ B Cf = composite_matrix @ C print(Af, '\n\n', Bf, '\n\n',Cf) plt.axis('equal') plt.grid () plt.plot (A,B,C, color= 'b') plt.show() L [[0.5 0.] [[0.] 10 [0.]] 0.8 0.6 0.4 In [37]: | 0.2 Console 1/A X 0.0 [0. 1.5]] Please enter angle of rotation in degrees:30 [[ 0.8660254 -0.5 [ 0.5 [[ 0.4330127 [ 0.25 [[-0.75 [ 1.29903811]] [[0.4330127] [0.25 ]] -0.2 0.0 0.8660254]] -0.75 ] 1.29903811]] ] 0.2 0.4 0.6 0.8 10 Help Variable Explorer Plots Files IPython Console History Terminal 12
Expert Answer:
Answer rating: 100% (QA)
To draw a triangle using NumPy arrays in Python without a gap at the base you can use the matpl... View the full answer
Related Book For
Thomas Calculus Early Transcendentals
ISBN: 9780321884077
13th Edition
Authors: Joel R Hass, Christopher E Heil, Maurice D Weir
Posted Date:
Students also viewed these programming questions
-
Eight years ago, Natalia purchased an 8.25% $1,000 bond for 107 1/2 plus brokerage fees totaling $28. Natalia received interest checks semiannually Immediately after receiving her 16th interest...
-
Elias and Susana form a Corporation (E & S Manufacturing, Ltd.) in 2019. Elias contributed a machine with a fair value of $60,000 and a basis to him of $9,000 to the corporation in exchange for 40...
-
The following interviews were conducted prior to the start of the project to explore specific aspects of Z Cheddr business processes. The interviews with employees provide information that is...
-
Consider a portfolio of the following derivatives where the counterparty is an OECD bank. Derivative 8-year interest rate swap 6-month option on an equity 1-year swap on precious metals 9-month...
-
Equity Securities the Financial Accounting Standards Board issued accounting guidance to clarify accounting methods and procedures with respect to certain debt and all equity securities. An important...
-
Suppose that in a single-period model the stock value at time 1 is not random, but known already at the beginning of the period. Suppose also that the interest rate r is fixed. Find the conditions on...
-
Hitting a door with your bare fist hurts more than hitting a sofa cushion. In work terms, explain why this is so. \(\cdot\)
-
Multiple-Choice Questions 1. Which of the following will increase the breakeven quantity? a. A decrease in overall fixed costs b. A decrease in the marginal costs c. A decrease in the price level d....
-
1 Explain briefly about six sigma and capacity maturity models? 2 Explain about the contemporary management practices taking place in Indian business model? 3 4 What is performance management?...
-
create a Marketing 2033; In class Interview /Brand Presentation (15%) Goal : To bring together PMP development in one final verbal and visual presentation. Assignment : In a mock interview (I will be...
-
For an amplitude-modulated signal, the carrier is 10 cos ot and the message signal is Am cos oet. Find the modulation index and sketch the modulated waveform if Am 4, %3D Am = 10, and Am = 20. %3D
-
The California Public Employees Retirement System (CalPERS) is one of the worlds largest pension funds and one of the earliest to divest stocks of firms that did not meet its ESG criteria. For...
-
Suppose the time you wait at a bank is exponentially distributed with mean 1/ = 12 min. What is the probability that you will wait between 10 and 20 min?
-
From past history, a service manager at Honest Abes Auto Dealership knows that 35 % of all customers entering the dealership will have service work done that is under warranty. Suppose 200 people...
-
The incomes of families in a town are assumed to be uniformly distributed between $15,000 and $85,000. What is the probability that a randomly selected family will have an income above $40,000?
-
Suppose the ages of members of a senior citizens bridge club are 63, 71, 82, 60, 84, 75, 77, 65, and 70. (a) Compute the population mean and standard deviation for the age of the bridge club members....
-
Part C Examples of NEAT include physical activities done in conjunction with an MP3 device that allows you to select your own work out music documenting your weight on a weekly basis working out with...
-
Which one of the following anhydrous chloride is not obtained on direct heating of its hydrated chloride? (A) BaCl2 (B) CaClz (C) MgCl2 (D) SrCl2
-
The area of the region in the xy-plane enclosed by the x-axis, the curve y = (x), (x) 0, and the lines x = 1 and x = b is equal to b 2 + 1 - 2 for all b > 1. Find (x).
-
Which of the series converge absolutely, which converge, and which diverge? Give reasons for your answers. n=1 (1)"(n + 1)" (2n)"
-
Give the eccentricities of conic sections with one focus at the origin along with the directrix corresponding to that focus. Find a polar equation for each conic section. e = 1, y = 2
-
From the following trial balance of G. Foot after his first year's trading, you are required to draw up a statement of profit or loss for the year ending 30 June 2016. A statement of financial...
-
What circumstances might lead you to write-off a debt as bad and not close the debtor's account?
-
At the beginning of the financial year on 1 April 2017, a company had a balance on plant account of 372,000 and on provision for depreciation of plant account of 205,400. The company's policy is to...
Study smarter with the SolutionInn App