Lets say I have a camera struct given by
typedef struct cam_type{
vec3_t pos;
vec3_t orig_pos;
} cam_t;
typedef struct vec3_type{
float x, y, z;
} vec3_t;
The position of the cam is relative to the world''s origin. If I was to rotate this camera around the world''s y-axis, would its distance from the origin always be the same? Also, isn''t the length of this vector then its distance from the origin?
I am doing the rotation by the following code and this doesn''t seem to be happening. Its position is (2.0,3.0,4.0).
cam_t *cam = Cam_Init(2.0,3.0,4.0); /* pos and orig_pos setup */
mat4x4_t *rot;
float a;
float rot_step = PI / 36.0;
for(a = 0.0; a <= (PI * 2); a += rot_step){
rot = Mat4x4_YRotation(a);
Vec3_Transform(&(cam->pos), rot); /* transforms the vec3_t by rot */
printf("length = %f\n", Vec3_Length(&(cam->pos));
Vec3_Copy(&(cam->orig_pos), &(cam->pos)); /* copy original position back */
}
Every 2PI it is back to its original position and length but in between it isn''t working.
Thanks.