distortion to virtually rotate an orthographic sphere image

70 Views Asked by At

How, exactly do I produce a 2D distortion that takes an orthographic image of a sphere and make it look like it's rotating?

I have this image of an eyeball What I'd like to do is come up with a way to distort the image so that it looks as if the eyeball is looking around (rotating). So, as the iris gets closer to the edge it becomes more compressed and warped to the curve of the sphere.

I've tried all sorts of stuff having to do with polar and Cartesian coordinates and I can get it close but nothing quite gives the effect that an actual sphere is rotating.

1

There are 1 best solutions below

0
On

There are two distinct parts in your question 1) and 2).

Let us consider a rotation with angle $R$ to the right for the owner of the eye, therefore to the left for the observer. let us call $A$ the Azimuth and $E$ the Elevation.

enter image description here

Fig. 1: A small feature and its image by a rotation with $R=5 \pi/12$ using formulas (1).

  1. We have to make first a mathematical computation from cartesian coordinates $(x,y) \to (x',y')=(x',y)$. $$\begin{cases}x&=&\cos(A)\cos(E)\\y&=&\sin(E)\end{cases} \ \ \to \ \ \begin{cases}x'&=&\cos(A')\cos(E)\\y'&=&y\end{cases}\tag{1}$$

where $A$ and $A'$ are the old and new azimuth, $E$ the common elevation, and $A'=A+R$ where $R$ is the rotation angle. (1) can be done by using the following computations:

$$A=\arccos\left(\dfrac{x}{\sqrt{1-y^2}}\right) \ \ \to \ \ x'=\cos(A+R)\sqrt{1-y^2}\tag{2}$$

Please note that we have taken a radius equal to $1$.

  1. But this is enough for the contour of shapes only. If one wants to take into account the image itself, with its pixels and their colors, it is not sufficient. We have to use the fact that the image of a group of $N$ horizontal pixels undergoing a rotation will give a group of $N'$ horizontal pixels with, in general, $N \ne N'$. The idea is to work backwards. Let us take the example of pixels in the iris ; all of them will be more or less compressed by a $75°$ rotation. The pixel which is for example right in the center of the iris in its rotated position will correspond to, say, $5$ pixels in the initial position of the center. Therefore you will have to find them, make an average color and attribute this color to the new pixel. Saying that for $75°$, we must take a ratio $1:5$, that for $45°$ the ratio is $2:3$ depends in general from the initial position. The precise rule of compression (or dilatation according to the case at hand) can be established as $N'/N = $

$$\text{relative distorsion coefficient: } \ \ \dfrac{\sin(A)}{\sin(A')}\tag{3}$$

Please note that (3) is independent from Elevation.