If the x and y axes of the Cartesian coordinate system are rotated counterclockwise through an angle of θ, with the new rotated axes denoted x' and y', then a point whose coordinates are (x,y) in the unrotated system will have coordinates (x',y') in the rotated system, where
x' = x cosθ + y sinθ,
y' = y cosθ - x sinθ
Alternatively, one can view the x and y coordinates as the rotation through an angle of -θ of the x' and y' coordinates, so
x = x' cosθ - y' sinθ,
y = y' cosθ + x' sinθ
An ideal application of rotation of axes is elimination of the "xy" term in the general form of a conic section. This is helpful, because aligning the axes parallel to the axes of the conic section renders their formulae much more simply.
If x' and y' are the axes that have been rotated counterclockwise through an angle of θ, then we can begin with the general form of the conic, and then substitute (x' cosθ - y' sinθ) in place of x, and (y' cos θ + x' sinθ) in place of y, giving us
a(x'cos θ-y'sinθ)² + 2h(x'cosθ-y'sinθ)(y'cosθ+x'sinθ) + b(y'cos θ+x'sinθ)² + 2g(x'cosθ-y'sinθ) + 2f(y'cosθ+x' sinθ) + c = 0
Expanding this, and then collecting like terms,
(a cos²θ + 2h cosθ sinθ + b sin² θ)x'² + 2(h(cos²θ-sin²θ) - (a-b)(sinθ cosθ))x'y' + (a sin²θ - 2h cosθ sinθ + b cos² θ)y'² + 2(g cosθ+f sinθ)x' + 2(f cosθ-g sinθ)y' + c = 0
To find the value of θ (0≤θ<π/2) that eliminates the x'y' term, we will set the x'y' coefficient to zero:
2(h(cos²θ-sin²θ) - (a-b)(sin θ cos θ)) = 0
2h cos(2θ) - (a-b)sin(2θ) = 0
sin(2θ)/cos(2θ) = 2h/(a-b)
θ = ½ arctan(2h/(a-b))
Note: we take the value of arctan to be between 0 and π in order that θ is in the first quadrant.
In the remainder of these steps, we will assume that h is nonnegative. If not, simply flip the signs of all the coefficients of the original equation. Now, using the value of θ given above, we can calculate
cos²θ = (1+cos(2θ))/2 = (1+cos(arctan(2h/(a-b))))/2 = (1+(a-b)/sqrt((a-b)²+4h²))/2 = (1+(a-b)/w)/2
sin²θ = (1-cos(2 θ))/2 = (1-cos(arctan(2h/(a-b))))/2 = (1-(a-b)/sqrt((a-b)²+4h²))/2 = (1-(a-b)/w)/2
2 cosθ sinθ = sin(2θ) = sin(arctan(2h/(a-b))) = 2h/sqrt((a-b)²+4h²) = 2h/w,
where w = sqrt((a-b)²+4h²)
a' = a((1+(a-b)/w)/2)+2h((1-(a-b)/w)/2)+b(2h/w) = a/2+h+(a²-ab-2ah+6bh)/(2w)
. . . . . . more work to be done on this web page: continue to check this, and calculate the remaining rotated parameters.
Wikipedia: Rotation of Axes
The webmaster and author of this Math Help site is Graeme McRae.