0

I have a 4x4 projection matrix

(SCNMatrix4) 
   s = (m11 = 1.83226573, 
   m12 = 0, 
   m13 = 0, 
   m14 = 0,
   m21 = 0,
   m22 = 2.44078445,
   m23 = 0,
   m24 = 0,
   m31 = -0.00576340035, 
   m32 = -0.0016724075, 
   m33 = -1.00019991, 
   m34 = -1, 
   m41 = 0, 
   m42 = 0, 
   m43 = -0.20002, 
   m44 = 0)

I would like to get the focal point and the focal length out of this matrix.

Patrick
  • 4,981
  • 9
  • 60
  • 93
andre
  • 51
  • 2
  • 7

1 Answers1

3

From slides 4 and 5 on this GDC presentation:

enter image description here

The focal length is merely the first element in the matrix (m11).

The focal point, however, cannot be extracted from this matrix alone - you need the camera direction D and position P. Once you have them, simply do P + D * m11 to obtain the focal point.

  • The position of the Camera is a 3D Point, and the focal point is a 2D point.I'm confused about the position of the camera – andre Sep 06 '17 at 20:15
  • @andre why do you think that the focal point is 2D? It is a 3D point too. – willywonkadailyblah Sep 06 '17 at 20:21
  • 2
    Revive of an old post, but this got me : what this doesn't say is that this 1 in the numerator for e is supposed to be half the width of the viewport. If you're doing OpenGL, this works because the viewport is [-1, 1] x [-1, 1] so half the width is indeed 1, but if you're trying to deduce the focal length for a real-world camera, the formula is indeed `m11 = 1 / tan(FOV / 2)`, but `FOV = 2 * arctan(sensor_half_width / focal_length)`, so in the end `focal_length = m11 * sensor_half_width`. Be careful that the sensor width and the focal length have the same units. – Matrefeytontias Jun 13 '19 at 17:13