STAR WARS
Horizon & Ellipse Measurements



Summary

The projection of a sphere onto a flat screen is an ellipse or related conic curve. This shape depends on the position of the sphere, in units of its radius and relative to the line of sight, and the extent of the angular field of view. If the camera points directly towards the centre of the sphere then the projected outline is exactly a circle. As the camera is tilted further away from the centre of the sphere, the ellipticity and the pixel area of the projected shape both increase.

In some restricted circumstances the elliptical shape of disk image can be measured, and thus the camera's field of view and displacement of the sphere can be inferred. In other cases, when the field of view is narrow or the sphere lies close to the line of sight, the projected disk is approximately circular. These circumstances are only distinguishable when the outline of the globe is measurable around most of its circumference. If only a small arc is visible, or if the horizon looms large and flat, then the global measurements are indecisive and practically uninterpretable as either lower and upper scaling limits.


Outline of an ellipse

Suppose that an ellipse is centred at the origin and its major axis is in the x direction. The semimajor axis length is a and the semiminor axis is b. Points (x,y) on this standard, centred ellipse obey the relation

x² / a² + y² / b² = 1.

Then suppose that we transform the coordinates by rotating the ellipse through an anticlockwise angle φ, and shift the centre of the ellipse to a point (X*,Y*). The coordinates of points on this transformed ellipse (X,Y), are related to the old coordinates via

x = (XX*) cos φ + (YY*) sin φ,
y = -(XX*) sin φ + (YY*) cos φ.

After substituting these expressions into the equation of the ellipse in centred coordinates, it can be shown that the equation of the displaced and rotated ellipse has the following polynomial form,

Cxx X² + Cyy Y² + Cxy XY + Cx X + Cy Y + C0 = 0.

The constant coefficients depend on the parameters of the ellipse, its rotation and displacement as follows,

Cxx = b² cos² φ + a² sin² φ,
Cyy = b² sin² φ + a² cos² φ,
Cxy = 2 cos φ sin φ ( b² − a² ),
Cx = -(2Cxx X* +Cxy Y* ),
Cy = -(2Cyy Y* +Cxy X* ),
C0 = Cxx X*² +Cyy Y*² +Cxy X* Y* − a² b².

Thus, if we know the axes of the ellipse (a, b), its orientation (φ) and location of its centre then we can determine the coefficients of the equation of this ellipse. Conversely, if we measure enough points on the outline of a picture of an ellipse then we can infer the C coefficients, and thereby solve for the parameters (a, b, φ, X*, Y*). We obtain the solution as follows.


measuring ellipse parameters

Firstly, it is convenient to define a set of dimensionless parameters that express the ratios of the C coefficients in the general ellipse equation,
kxxCxx / C0 ,
kyyCyy / C0 ,
kxyCxy / C0 ,
kxCx / C0 and
kyCy / C0.

We measure the screen coordinates of representative points on the ellipse, and substitute them into the polynomial equation of the ellipse. The k and C coefficients are initially unknown, but must be the same for all measurements. If a measurement labelled i has screen coordinates (Xi,Yi), then we can obtain a linear relationship between the k coefficients,

kxx Xi² + kyy Yi² + kxy XiYi + kx Xi + ky Yi = -1.

Measuring five unique points on the ellipse provides five independent linear equations (i=1,2,3,4,5), which we can solve for the all the k values. The parameters of the ellipse and its transformation are, explicitly,

X* = ( kxy ky − 2kx kyy ) / ( 4 kxx kyy - kxy² ) ,
Y* = ( kxy kx − 2ky kxx ) / ( 4 kxx kyy - kxy² ) ,
φ = ½ atan( kxy , kyykxx ) ,
a² = ½ C0 { kxx + kyy + [ (kyykxx)² +kxy² ]½ } ,
b² = ½ C0 { kxx + kyy − [ (kyykxx)² +kxy² ]½ } ,
C0 = 4 ( kxx X*² +kyy Y*² +kxy X* Y* − 1 ) / ( 4 kxx kyykxy² ) .


Projection of a Sphere

Suppose that we have a sphere centred at (x0,y0,z0) relative to the camera, and points measured on the surface of the sphere are labelled as (xi,yi,zi). A ray drawn from this surface point back to the centre of the camera will intersect the image plane at the pixel location (Xi,Yi), where (0,0) represents the centre of the screen. These rays obey the equations

xi / zi = XiF ,
yi / zi = Yi / F.

Here we define the constant F = the effective separation between the image plane and the centre of the camera, measured in pixels. The angular field of view is defined by half-angles tan θx = ΔX/2F and tan θy = ΔY/2F, where ΔX and ΔY are the pixel width and height of the screen.

We define units of measurement of the sphere (not its projected image) in terms of the spherical radius, r=1. It follows that

( xi - x0 )² + ( yi - y0 )² + ( zi - z0 )² = 1.

The horizon of the sphere consists of points where the line-of-sight ray meets the sphere at right angles. In terms of a vector product, the LOS ray and the radius line are perpendicular,

(xi, yi, zi) • (xi - x0, yi - y0, zi - z0) = 0.

Furthermore, for a particular image the distance from the camera to a horizon point is the same for all horizon points. Call this distance l, and then we can recast the equations of the ray passing to horizon point i,

xi = Xi l / ( Xi² + Yi² + F² )½ ,
yi = Yi l / ( Xi² + Yi² + F² )½ ,
zi = F l / ( Xi² + Yi² + F² )½ .

Substituting these expressions into the perpendicular ray equation provides the value of

l = ( x0 Xi + y0 Yi + z0 F² ) / ( Xi² + Yi² + F² )½.

The camera, the centre of the sphere and each horizon point form the vertices of a right angled triangle, with l0² ≡ x0² + y0² + z0² = l² + 1. After substitution of the ray equations and some rearrangement of the radius equation, we obtain the equation describing the projection of the horizon in pixel terms, (Xi,Yi). This turns out to be a general description of a conic section,

Dxx X² + Dyy Y² + Dxy XY + Dx X + Dy Y + D0 = 0 ,

where the coefficients are

Dxx = (x0² − l²) F² ,
Dyy = (y0² − l²) F² ,
Dxy = 2 x0 y0 F² ,
Dx = 2 x0 z0 F³ ,
Dy = 2 y0 z0 F³ ,
D0 = ( z0² − l² ) F4 .

If this horizon curve is closed then it is an ellipse or circle. If the horizon curve is open then it is a parabola or hyperbola, in which case it extends infinitely off the edges of the screen and its parameters may be difficult to measure precisely. For the sake of simplicity we will assume that it is an ellipse, but the same formal mathematical derivations apply to the parabolic or hyperbolic cases.

diagram of global and screen parameters
Top view illustration of the parameters defined for the globe and the screen where its image is projected. Rays from the camera to the outline of the sphere (horizon) are shown in yellow; they meet the 3D surface of the sphere at right angles. The 3D position of the globe is (x0,y0,z0), measured in units where the radius is 1. Each point on its horizon can be described with 3D coordinates (xi,yi,zi), and the corresponding 2D point on the image outline is (Xi,Yi). The ideal distance between the screen and the observer, measured in pixels, is F. The half angle of the horizontal field of view is θx. The distance from the observer to every horizon point on the sphere is l.


Effect of Tilting the Field of View

Let us assume the model of a sphere projected onto the movie screen as described above, and then take the normalised coefficients to be those of a projected ellipse. Explicitly,

kxx=Cxx/C0 =Dxx/D0 ,
kyy=Cyy/C0 =Dyy/D0 ,
kxy=Cxy/C0 =Dxy/D0 ,
kx=Cx/C0 =Dx/D0 ,
ky=Cy/C0 =Dy/D0 .

By a process of algebraic substitutions and eliminations, it can then be shown that

X* = F x0 z0 / ( z0² − 1 ) ,
Y* = F y0 z0 / ( z0² − 1 ) ,
C0 = F4 ( l² − z0 ) / ( z0² − 1 )4 ,
a² = F² l² / ( z0² − 1 )4 ,
b² = F² / ( z0² − 1 )³ ,

From these results we can calculate the area of the image ellipse on the movie screen. For an ellipse in general, Aab. For the image projected from a sphere,

A = π F² l / ( z0² − 1 )7/2 .

The eccentricity, e, of an ellipse is generally given by the implicit equation b² = a² ( 1 − e² ). Thus the eccentricity of the elliptical image of a sphere is given by

e² = ( l0² − z0² ) / ( l0² − 1 ) .

Let us consider how the shape and size of the image ellipse vary as the camera pans. The range to the sphere, l0, remains constant. The displacement of the sphere in the camera direction depends on the angle (τ) at which the camera is tilted away from the centre of the sphere,

z0l0 cos τ .

It is then found that

A = π F² l / ( l0² cos² τ − 1 )7/2 ,
e² = l0² sin² τ / ( l0² − 1 ) .

We can distinguish a few qualitative cases depending on the angle of tilt:

  1. When the camera points directly towards the sphere, τ=0, the image area is a minimum (AF²/l³) and the shape is perfectly circular (e=0).
  2. As the tilt angle τ increases from zero up to the half-angle of the sphere (γ), both the area and eccentricity of the image ellipse increase. One axis of the ellipse is parallel to the tilt direction (X*,Y*).
  3. At a maximum angle of τ = γ the eccentricity reaches e=1, and thus the image has become a parabola, not an ellipse. A parabola is an open shape, and the horizon curve invariably exceeds the borders of the movie frame, regardless of the field of view. In the parabolic condition, z0=1, which means that some part of the sphere (with radius = 1) extends behind the position of the camera. The expressions above show that X*, Y* and A become undefined in this case.
  4. Beyond this limit, z0>1, the horizon is hyperbolic. Qualitatively this is an open curve like in the parabolic condition, but flatter as more of the globe is behind the camera. Measuring the curvature on any local part of the hyperbola doesn't directly indicate the equivalent apparent radius of the sphere if it were projected at the centre of the frame.


Measuring the Location and Scale of the Sphere

If we measure the projected ellipse from an image, as described in the sections above, then the equations of the C coefficients can be solved to obtain the relative position of the sphere and the angular field of view (expressed in terms of F).

For convenience, define the ratio λ = l / z0, which is a constant for each image. It can be related to the measurable parameters of the onscreen ellipse,

λ² =  1 − 4 (kxx − kyy) / ( kx² − ky² ) .

If the field of view of the image is unknown, then it can be calculated from

F² =  [ λ² / (1 − λ² ) ] [ ( kx² − ky² ) / ( kxxky² − kyykx² ) ]

The positive solution of F can be substituted to obtain expressions for the coordinates of the sphere's centre:

x0 / l = ½kxF (1−λ²) / λ,
y0 / l = ½kxF (1−λ²) / λ,
z0 / l = 1 / λ     as defined above.

From these three expressions, we can relate the range to the centre of the sphere, the range to the horizon, and the angle γ, which is half the total angle that the sphere subtends on the sky.

l0² / l² = [¼F²(1−λ²)² (kx²−ky²) + 1 ] / λ² ≡ 1 / cos² γ .

As we have defined the measurement units in terms of the radius of the sphere, r=1, the ranges to the centre and to the horizon are thus given by

l0 = 1 / sin γ ,
l = 1 / tan γ .

Limits of Precision

A spherical object appears as an elliptical, parabolic or hyperbolic outline on a movie frame. In theory it is straightforward to measure five different points on that outline, calculate the coefficients of the conic section, and infer the field of view and the 3D position of the sphere in units of its radius.

In practice there are several possible sources of difficulty, imprecision and ambiguity in the measurements or in the inference.

Firstly, the image does not contain spatial information finer than a pixel. Therefore it is impossible to pick sample points more precisely than within one pixel inside or outside the ideal horizon curve. Uncertainties will propagate into the inferred conic coefficients and thence to the derived parameters of the sphere.

Secondly, the horizon may not be completely measurable. In the best possible scenario, we can pick measurement points that are roughly evenly spaced on all sides of an ellipse. Both the semimajor and semiminor axes are well constrained from both the left and right (top and bottom) sides. However if one side of the globe falls off the edge of the image, or is invisible because of obstruction or shadow, then that side is poorly constrained. The inferred ellipse has a lot of scope for variation in the direction of the unmeasured side, for very tiny deviations on the choices of reference points in the measurable sides.

In the worst possible cases, the majority of the horizon is off the edge of the screen and we can only measure a tiny angular arc, which appears almost straight. The axes of the curve become practically unmeasurable, and even the type of conic section may be indeterminate. Attempts to read the local radius of curvature are misleading and provide neither upper nor lower limits, because the field of view is unknown and the aspect ratio of the ellipse/hyperbola is unknowable. As the camera tilts away from a sphere, the area and eccentricity of the onscreen ellipse both increase. An image that is tilted far offscreen is thus magnified and distorted compared to the appearance it would have when centred in the field. When only a small, flat arc is visible and the field of view is unknown then the distortion and magnificiation are inestimable.

Circular approximations are only useful when the disk is entirely within the field of view and close to the centre of frame. If the disk is measurably indistinguishable from a circle then we automatically know that the sphere is close to the line of sight and the field of view is narrow.

Demonstrations:


References


Return to STAR WARS Technical Commentaries.
Return to Curtis Saxton home page.
Online since 24 July 2004.
Last updated 31 July 2004

This page was constructed and is maintained by Curtis Saxton.
Original content is © copyright Dr Curtis Saxton 2004.
Other images included in or linked from these commentaries are copyright Lucasfilm Ltd. and used here under Fair Usage terms of copyright law.
This page is neither affiliated with nor endorsed by Lucasfilm Ltd.
This site is kindly hosted by TheForce.net.