PDA

View Full Version : glm::rotate a normal vector



alexxi
10-26-2015, 06:04 PM
I want to rotate normal vector (0,0,1) by 90 degrees about the y-axis. I am using glm::rotate as follows:

vec4 normal = normalize(rotate(mat4(),90.0f,vec3(0,1.0f,0))*vec4 (0,0,1,0));


but the result it gives me is normal = (0.893997, 0, -0.448074, 0). Why is it giving me this error when the expected result is (1,0,0,0)?

alexxi
10-26-2015, 07:15 PM
Nevermind, the angle should be in radians and not degrees.


I want to rotate normal vector (0,0,1) by 90 degrees about the y-axis. I am using glm::rotate as follows:

vec4 normal = normalize(rotate(mat4(),90.0f,vec3(0,1.0f,0))*vec4 (0,0,1,0));


but the result it gives me is normal = (0.893997, 0, -0.448074, 0). Why is it giving me this error when the expected result is (1,0,0,0)?