Monday, June 27, 2011

Rotating a hyperbola: general case

Just to finish up quickly with the analysis of hyperbolas from the other day (here and here), following Stewart (pdf), we derived the following equations for x and y in terms of a coordinate system based on u and v (orthogonal, rotated through angle θ):

x = u cosθ - v sinθ
y = u sinθ + v cosθ

The general formula for a quadratic is:

Ax2 + Bxy + Cy2 + Dx + Ey + F = 0

When we transform to the new coordinates, we get:

Ax2 = A[u2 cos2θ - 2uv sinθ cosθ + v2 sin2θ]
Bxy = B[u2 cosθ sinθ + uv cos2θ - uv sin2θ - v2 sinθ cosθ
Cy2 = C[u2 sin2θ + 2uv sinθ cosθ + v2 cos2θ

Gathering the terms in uv we obtain the coefficients:

(C-A)(2sinθ cosθ) + B(cos2θ - sin2θ)

Remember the double angle formulas:

sin(s+t) = sin s cos t + cos s sin t
sin(2θ) = 2 sinθ cosθ

cos(s+t = cos s cos t - sin s sin t
cos(2θ) = cos2θ - sin2θ

So we obtain:

(C-A) sin(2θ) + B cos(2θ)

for the coefficients of xy. These must equal zero for all the xy terms to disappear. Thus:

tan(2θ) = B / (C-A)

This approach runs into a problem if C = A, as it does for our example:

xy = 1

But we can just invert the step at the end:

cot(2θ) = (C-A)/B = 0

The cotangent is zero when the cosine is zero, e.g. for

2θ = π/2

Thus, if

θ = π/4

then all the xy terms vanish, as we found before.