Does anyone could help me or give me a tip about the folowiing code?
I am having dificult to create a π((π₯,π¦))=(π₯+ππ¦,π¦).
GRADED FUNCTION: T_hshear
def T_hshear(m, v):
ββ"
Performs a 2D horizontal shearing transformation on an array v using a shearing factor m.
Args:
m (float): The shearing factor.
v (np.array): The array to be sheared.
Returns:
np.array: The sheared array.
"""
### START CODE HERE ###
# Define the transformation matrix
T = np.array([[None,None], [None,None]])
# π((π₯,π¦))=(π₯+ππ¦,π¦)
# Compute the transformation
w = None @ None
### END CODE HERE ###
return w
To create the horizontal shearing transformation T((x,y)) = (x + my, y) , you need to define the transformation matrix T and apply it to the input vector v . The transformation matrix for this shearing operation is:
T = \begin{bmatrix} 1 & m \\ 0 & 1 \end{bmatrix}
Hope it helps! Feel free to ask if you need further assistance.
thank you so much for this post, I had been confused for a while !
Iβm still a bit confused though, how are we translating the equation onto the matrix?
Hi there - I am doing this course on Coursera and it seems like the test for this function is trying to test two different values for m simultaneously. I can pass one of the tests when I add that m value but then I fail the other one. Is there a way to set up the function so that it has multiple m values?
The m value is a parameter passed to your function, right? There is no need to βhard-codeβ it to any specific value: just use the value that is passed to you. That is the point of having functions take parameters: you can write general code that works for any input value.