-1

I'm currently coding my own raytracer for school and i'm running in a bit of a problem while setting up my camera.

I know where my camera is (cX, cY, cZ) and i know where it is looking at (lX, lY, lZ)

I need to convert those data in : where my camera is (cX, cY, cZ) and its rotationX and rotationZ

I'm not that good in math if some of you could give me a little help at it? Thanks you so much!

  • Have You heard of Euler angles? [This](http://stackoverflow.com/questions/36604734/rotating-a-pinhole-camera-in-3d) may be helpful... – Dori Apr 29 '16 at 05:42
  • Before you do so: I'm pretty sure you don't want Euler Angles. Use direction vectors and matrices formed from these vectors instead. – Nico Schertler Apr 29 '16 at 06:27
  • Specify what are rotationX and rotationZ and how camera orientation is defined – MBo Apr 29 '16 at 10:59

1 Answers1

1

Well i figured it out myself

what i did is : cam_rot.x = RadienToDegree(acos(-(dir.z / sqrt(pow(dir.x, 2) + pow(dir.z, 2))))) - 90; cam_rot.y = RadienToDegree((M_PI / 2 - acos(dir.y)));

assuming dir is the normalized directional vector between where my camera is and where it is looking at.

I'm not completely sure about the -90 for the rotationX but i needed it in my case

working like a charm Screenshot1