Open zloywolk opened 9 years ago
Hi,
There is incorrect main diagonal in rotate matrix. You matrix
float r = toRadians(angle); float c = cos(r); float s = sin(r); float omc = 1.0f - c; float x = axis.x; float y = axis.y; float z = axis.z; result.elements[0 + 0 * 4] = x * omc + c; result.elements[1 + 0 * 4] = y * x * omc + z * s; result.elements[2 + 0 * 4] = x * z * omc - y * s; result.elements[0 + 1 * 4] = x * y * omc - z * s; result.elements[1 + 1 * 4] = y * omc + c; result.elements[2 + 1 * 4] = y * z * omc + x * s; result.elements[0 + 2 * 4] = x * z * omc + y * s; result.elements[1 + 2 * 4] = y * z * omc - x * s; result.elements[2 + 2 * 4] = z * omc + c;
And could be implemented as marix (see below)
So in main diagonal you should multiply (1 - cos a) on sqaure of the coordinate of the vector.. See below pic.
Probably fix it (w/o optimization and etc.)
result.elements[0 + 0 * 4] = x * x * omc + c; // fixed result.elements[1 + 0 * 4] = y * x * omc + z * s; result.elements[2 + 0 * 4] = x * z * omc - y * s; result.elements[0 + 1 * 4] = x * y * omc - z * s; result.elements[1 + 1 * 4] = y * y * omc + c; // fixed result.elements[2 + 1 * 4] = y * z * omc + x * s; result.elements[0 + 2 * 4] = x * z * omc + y * s; result.elements[1 + 2 * 4] = y * z * omc - x * s; result.elements[2 + 2 * 4] = z * z * omc + c; // fixed
Hi,
There is incorrect main diagonal in rotate matrix. You matrix
And could be implemented as marix (see below)
So in main diagonal you should multiply (1 - cos a) on sqaure of the coordinate of the vector.. See below pic.
Probably fix it (w/o optimization and etc.)