If you were rotating on only one axis, you’d only change he other two rows. The rotation matrix part encodes the 3 base coordinate axes for the transform of the matrix: In an unrotated matrix they are not rotated and they line up with the world: 1 0 0 = xĪt any given point these numbers change to be the local X, Y and Z vectors (technically, they also encode scale if they are not normalized… lets ignore that for now) So, how Maya calculates this values? What happens when third axis enters in the game? I guess it is due to rotate order but how?Ī 4x4 matrix encodes a 3x3 rotation matrix, a position, and an extra column of values that used to distinguish between the position and rotation parts (you can think of that fourth column as a binary “am I a translation row” value) recap Which matches with cubes “sides” in all 3 Axis. Note: my rotate order is default = XYZ and scale is 1.Īnd again if use this 3 vectors as translate.xyz of the locator we will get 3 points in 3D space Now, my confusion starts when I rotate the locator in second axis, let’s say in Y by 45 degrees. Translate channels we will get 2 points in 3D space matching with locator’s X and Y vectors. If we create 2 transform nodes and assign this values to X and Y This values represents the 2 dimensional vectors for each axis. Which in this case will be for X axis and for Y axis. To calculate this values I must use cos(45) and sin(45) And I will rotate it in Z axis by 45 degrees. **After the update, all the previous rotation operations have to be applied to the *updated initial matrix*.I have a question about how Maya stores rotate results in 4x4 matrix. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z. Print("Error: unexpected command '" + line + "'") Matrix = RotateMatrix(orig_matrix, rotation) If you want to watch the play-by-play to verify what is going on, I suggest adding a little print statement to the end of your loop that you can comment out when satisfied that all is good. Then you can update that as needed and pass in that updated matrix into your re-rotation operation. Python has a built in copy() command which will work fine in this case because the thing you are copying are lists of integer types (not reference variables).Ĭonsider capturing your original matrix like this: matrix = ReadMatrix() How do we fix? We need to maintain a copy of the original matrix for such purposes and then use that as the basis of our Update command. You are applying the update to the already rotated matrix and then re-rotating it. It says you should apply the update to the original matrix and then re-rotate it. The problem you are having is that you are not explicitly following the instruction for the Update action. The output I am getting for the second input is 5 8 5 but the correct output is 5 8 8. I am getting correct output for this input: 2īut I am not getting correct output for this input 2 Here is what I have done so far: def ReadMatrix(): You need to print the value at row index K and column index L of the matrix A. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.Īfter the update, all the previous rotation operations have to be applied to the updated initial matrix. The angle of rotation(S) will always be in multiples of 90 degrees. You need to rotate matrix A by angle S in the clockwise direction. Rotation: It is represented as R S where S is an integer in which denotes the number of degrees to rotate. You need to apply the below given 3 operations on matrix A. You are given a square matrix A of dimensions NxN.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |