# Lightroom / Camera Raw / DNG / XMP: What is the formula for converting crop coordinates when photo gets angled?

• Question
• Updated 6 years ago
For example, lets say an un-rotated and un-flipped landscape photo has crop coordinates:

crs:CropTop=".3"
crs:CropLeft=".4"
crs:CropBottom=".8"
crs:CropRight=".9"
crs:CropAngle="0"

then one angles it by say 10 degrees. the coordinates change to:

crs:CropTop="0.36916"
crs:CropLeft="0.374965"
crs:CropBottom="0.73084"
crs:CropRight="0.925035"
crs:CropAngle="-10"

What is the formula one needs to apply to arrive at the new top, left, bottom, and right values based on the crop angle change? I assume it involves trigonometry, but so far it has eluded me?

Knowing this formula will allow me to solve a nagging problem with my XmpCrop plugin.

Thanks,
Rob
• 4831 Posts

Posted 7 years ago

Dorin Nicolaescu-Musteață, Champion

• 703 Posts
1) Convert from Cartesian to polar system,
2) apply a deltaθ of 10 deg to θ,
3) convert back to Cartesian.

http://en.wikipedia.org/wiki/Polar_co...

Dorin Nicolaescu-Musteață, Champion

• 703 Posts
Don't forget that the origin (0, 0) in crs is the upper left corner, while the origin during the transformation (i.e. user rotating the crop box) is the center of the crop box. So you must shift the corner coordinates before step 1) and back after step 3).

Steve Sprengel, Champion

• 2674 Posts

x' = x * Cos(theta) - y * Sin(theta) + a
y' = x * Sin(theta) + y * Cos(theta) + b

Where (a,b) is the center of the rotation.
• 64 Posts
Rob, I sent you a complete example of such a calculation in email some months ago.

And I know it works, because I use it frequently to change the aspect ratio of crop areas in photos with a crop angle.
• 4831 Posts