Precise rotation of equirectangular image around a point

518 views
Skip to first unread message

JF Ménard

unread,
Dec 19, 2021, 5:12:45 PM12/19/21
to PTGui Support
Hello,

I have an equirectangular image in PTGui that I want to rotate precisely around a specific pixel.  Can someone help me with the math please?

Given:
- w, h: the width and height of equirectangular image. ex: 4000x2000px
- x, y: the coordinates of the center of rotation.  ex: 700, 300 px
- a: the angle of rotation. ex: 45 degrees.
How can I calculate 
- Yaw
- Pitch
- Roll
to put in the Image Parameters section of PTGui and achieve this precise rotation?
equirectangular rotation.png
Thanks

Erik Krause

unread,
Dec 20, 2021, 9:07:59 AM12/20/21
to pt...@googlegroups.com
Am 19.12.21 um 23:12 schrieb JF Ménard:
> Given:
> - w, h: the width and height of equirectangular image. ex: 4000x2000px
> - x, y: the coordinates of the center of rotation. ex: 700, 300 px
> - a: the angle of rotation. ex: 45 degrees.
> How can I calculate
> - Yaw
> - Pitch
> - Roll
> to put in the Image Parameters section of PTGui and achieve this precise
> rotation?

You would need to deal with Euler angles to do that mathematically (with
the special case of Tait-Bryan angles):
https://en.wikipedia.org/wiki/Euler_angles#Tait%E2%80%93Bryan_angles

I currently can't wrap my head around (;-), but may be it is sufficient
to calculate Yaw and Pitch from your x, y values. First you would need
to calculate the pixel distances from the image center (x', y') then
translate to angular values as follows: Yaw = 360 / w * x', Pitch = 180
/ h * y', Roll = a
Currently don't know whether you need to use this values in "Numerical
Transform" or on Image Parameters tab, you have to try.

However, if you want to simply rotate the panorama, it might be easier
to do this in two steps: Center the panorama on the respective pixel,
using the "Set center point" function from the Mode menu in Pano Editor,
then enter the angle as Roll value in "Numerical transform".

But it can be both solutions are wrong. Euler angles are weird...

--
Erik Krause

PTGui Support

unread,
Dec 20, 2021, 10:18:18 AM12/20/21
to pt...@googlegroups.com
It's not trivial. One way to tackle this would be:

- find Tait-Bryan angles (only pitch and roll) for your center of
rotation, as Erik says:
Yaw = 2pi / w * x' - pi, Pitch = 1/4pi - pi / h * y'

- convert these to a 3d unit vector:
https://stackoverflow.com/questions/1568568/how-to-convert-euler-angles-to-directional-vector/1568687

- given this unit vector [ax, ay, az] and your angle of rotation a,
construct a quaternion:
https://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm
This quaternion represents your desired 3d rotation.

- deconstruct the quaternion into Tait-Bryan angles:
https://math.stackexchange.com/questions/687964/getting-euler-tait-bryan-angles-from-quaternion-representation

As always the tricky thing is to get the sign and ordering of all
rotations right.

Kind regards,

Joost Nieuwenhuijse
www.ptgui.com

JF Ménard

unread,
Dec 21, 2021, 10:40:19 AM12/21/21
to PTGui Support
Thanks.  I will dig into this.  Best,

Kelly

unread,
Dec 22, 2021, 7:51:59 AM12/22/21
to PTGui Support
Why must it be rotated in PTGui?
If you you have the precise 2d coordinates of the point of rotation and know the co-planar angle of rotation, use Photoshop or any raster editor; e.g.,
any image rotation.png

Erik Krause

unread,
Dec 22, 2021, 9:12:00 AM12/22/21
to pt...@googlegroups.com
Am 22.12.21 um 13:51 schrieb Kelly:
> Why must it be rotated in PTGui?
> If you you have the precise 2d coordinates of the point of rotation and
> know the co-planar angle of rotation, use Photoshop or any raster editor;

And this will correctly wrap around the borders? It's a sphere after all...

--
Erik Krause

Kelly

unread,
Dec 22, 2021, 10:09:28 AM12/22/21
to PTGui Support
Erik - Excellent point; sorry JF, I wasn't thinking :(

JF Ménard

unread,
Dec 22, 2021, 10:15:49 AM12/22/21
to pt...@googlegroups.com
Hi Kelly, no because I don't want a flat 2D rotation.  I need a rotation within the Equirectangular projection, which is a flat view of a sphere. So while rotating, each pixel must follow some strange curves (and not simply a circular arc). That is why I rely on PTGui for the image rotation. And by following the steps above it seems to work! Thanks,

--
You received this message because you are subscribed to a topic in the Google Groups "PTGui Support" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ptgui/jpHCopOqBro/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ptgui+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ptgui/c3f58332-143b-4bab-b874-6d6e26ff7cfdn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages