I have a cube and I need to find its center after the rotation has been applied. So as you can see, my idea is to find the center point of that figure, and rotate that point, and get then its coordinates. But the results are incorrect. Where is my mistake / misunderstanding? Thanks,
1 2 3 4 5 6 7 8 9 10 11 12 13
void
Cube::position_center(float& cx, float& cy, float& cz) const
{
// finding the center of the stationary cube
cx = _origin_x + 0.5 * _cube.length();
cy = _origin_y + 0.5 * _cube.width();
cz = _origin_z + 0.5 * _cube.height();
//applying rotation to that point
glm::mat4 rot_mat = glm::rotate(glm::mat4(1.0f), 1.0f, glm::vec3 (1.0f, 1.0f, 0.0f));
glm::vec3 point = glm::vec3(glm::vec4(glm::vec3 (cx, cy, cz), 0.0f) * rot_mat);
cx = point.x;
cy = point.y;
cz = point.z;}
> But the results are incorrect.
provide a testcase: input, current output, expected output.
¿what's your cube representation? ¿one point and a length? ¿eight points? ¿four?
> I have a cube and I need to find its center after the rotation has been applied.
you are trying to do too many things at once
¿why does `postion_center()' rotate a point?
apart, ¿how do you choose the rotation angle/axis? ¿does it pass by {0,0,0} or do you also translate it?