Multiplying Matrices

What is the difference between the two parts of the pseudocode?

// Multiplying a matrix by the difference between each frame
float difference = current - previous; // Time since previous frame
float angle = difference / 500;
matrix rotation;
rotation.RotateX(angle);
rotation.RotateY(angle);
worldMatrix *= rotation; // Note multiply

// Multiplying a matrix by the difference between current and start
float difference = current - start; // Time since first frame
float angle = difference / 500;
matrix rotation;
rotation.RotateX(angle);
rotation.RotateY(angle);
worldMatrix = rotation; // Note assignment

There are only very minor differences between each part of the code, but lead to large visual differences. The input is as follows:

Box 1: Rotation = 1
rad worldMatrix * = rotation;
Box 2: Rotation = 1
rad worldMatrix * = rotation;
etc.

Box 1: Rotation = 1
rad worldMatrix = rotation;
Box 2: Rotation = 2 radians
worldMatrix = rotation;
etc.

+3
source share
2 answers

, ( , ). , : X, Y, Y, X.

( ) :

let angle = (end - start)/500
  Rx = rotate.RotateX(angle)
  Ry = rotate.RotateY(angle)

then, foreach frame in (0..500):
cumulative: Rc = Rx * Ry * Rx * Ry * ... * Rx * Ry
               = (Rx * Ry)^frame
assignment: Ra = Rx * Rx * ... * Ry * Ry * ....
               = (Rx)^frame * (Ry)^frame

: , ( , ). , , , (matrix)^N : N (matrix) .

OQ , Rx Ry ; rotation (Rx*Ry). worldMatrix ; , worldMatrix= initial_worldMatrix * (Rx*Ry)^frame.

frame * total_angle/total_frames. total_angle/total_frames frame , , , , . , (Rx)^frame * (Ry)^frame worldMatrix .


, ; , -.

, , . X Y; .

, , 500 ( , - ). , 45 Z, /500 X, -45 Z, .


:

X, Y, . , ( , , - ). , , , , .

X, Y. , . , : X Y , Y -.

, : , . , ( , Rx * Ry Ry * Rx - 4 ), - , , . (Rx * RyRy * Rx) , N Rx - , , : O (N ^ 2) ....

+8

, . . , , - , .

, , ? , - .

+2

Source: https://habr.com/ru/post/1773965/


All Articles