<p>An <a href="https://en.wikipedia.org/wiki/Equirectangular_projection" rel="nofollow noreferrer">equirectangular projection</a> treats the x coordinate as the angle theta around the vertical axis going from 0 to 360 degrees. These angles match the longitudinal angles of a globe. The y coordinate is treated as the angle phi that represents the latitudes of a globe. They typically go from +90° at the zenith (or north pole) to -90° at the nadir (or south pole).</p>

<p>So to translate the center of projection of an image by some amount (x0, y0), you  can simply add x0 to the x value of every coordinate (wrapping around to the other side at the edges). The y coordinate is similar - add y0 to every coordinate.  However, instead of wrapping around, you need to reflect the value. So if your new coordinate is less than 0, simply take the absolute value. If it's greater than the height, take the difference between the new value and the height of the image and subtract that from the height of the image. If it was less than 0 or greater than height then you need to also add half the width to the x coordinate.</p>

<p>So putting it in pseudocode:</p>

<pre><code>newY = oldY + translateY;
if (newY &lt; 0)
{
    newY = fabs(newY);
    translateX = fmod((translateX + (width / 2.0)), width);
}
else if (newY &gt;= height)
{
    newY = height - (newY - height);
    translateX = fmod((translateX + (width / 2.0)), width);
}
newX = oldX + translateX;
if (newX &lt; 0)
{
    newX = width + newX;
}
else if (newX &gt;= width)
{
    newX = newX - width;
}
</code></pre>

CC BY-SA 4.0
2019-04-04T05:10:28.810Z
2019-04-04T05:10:28.810Z
user1118321
<p>I'm trying to perfectly align two or more equirectangular photos of the same place taken from slightly different positions. 
Using an example provided by openMVG I managed to get the relative position between the two shots, but I can't figure out how to translate the center of the projection according to the data obtained. 
I tried with Hugin without success, editing the camera position information (it doesn't seem to be able to export the entire equirectangular photo) and I didn't found any useful panotools. I found some literature about the problem but not any real implementation to adapt.</p>

<p>Could you advise me of a possible path to follow?</p>

<p>My requirement is to do it programmatically because I will have to apply it to thousands of photos.</p>

<p>Thanks a lot.</p>

CC BY-SA 4.0
2019-04-03T03:22:19.927Z
Are you looking for an existing application to do it or do you want to understand the algorithm so you can write the code yourself?
user1118321
CC BY-SA 4.0
2019-04-03T16:26:16.013Z
Sorry probably it is not clear from the question. I don't think there is any existing application to do it, so I'm interested in understanding a possible algorithm approach to code myself.
Lucio Coire Galibone
CC BY-SA 4.0
2019-04-22T16:24:16.727Z
Is this what you mean by equirectangular projection: https://en.wikipedia.org/wiki/Equirectangular_projection ? Are you looking for the transformation from  the points on one of the pictures to the points on the other picture, knowing the change in 3D position of the camera (center of projection)? Or is it that you know where the second center of projection is in 3D relative to the coordinate system of the first one? I honestly do not understand what geometric information you have and what you are trying to obtain.
Futurologist
<rendering><image-processing><projections>
How to translate the center of an equirectangular projection?
Lucio Coire Galibone
# How to translate the center of an equirectangular projection?

(Asked by: username_0 on 2019-04-02)

I'm trying to perfectly align two or more equirectangular photos of the same place taken from slightly different positions.
Using an example provided by openMVG I managed to get the relative position between the two shots, but I can't figure out how to translate the center of the projection according to the data obtained.
I tried with Hugin without success, editing the camera position information (it doesn't seem to be able to export the entire equirectangular photo) and I didn't found any useful panotools. I found some literature about the problem but not any real implementation to adapt.

Could you advise me of a possible path to follow?

My requirement is to do it programmatically because I will have to apply it to thousands of photos.

Thanks a lot.

**Tags:** rendering, image-processing, projections

> **Comments:**
> **username_1**: Are you looking for an existing application to do it or do you want to understand the algorithm so you can write the code yourself?  
> **username_0**: Sorry probably it is not clear from the question. I don't think there is any existing application to do it, so I'm interested in understanding a possible algorithm approach to code myself.  
> **username_2**: Is this what you mean by equirectangular projection: https://en.wikipedia.org/wiki/Equirectangular_projection ? Are you looking for the transformation from  the points on one of the pictures to the points on the other picture, knowing the change in 3D position of the camera (center of projection)? Or is it that you know where the second center of projection is in 3D relative to the coordinate system of the first one? I honestly do not understand what geometric information you have and what you are trying to obtain.  

---

## 1 answers

### Answer by username_1 on 2019-04-04. Score: 2

An [equirectangular projection](https://en.wikipedia.org/wiki/Equirectangular_projection) treats the x coordinate as the angle theta around the vertical axis going from 0 to 360 degrees. These angles match the longitudinal angles of a globe. The y coordinate is treated as the angle phi that represents the latitudes of a globe. They typically go from +90° at the zenith (or north pole) to -90° at the nadir (or south pole).

So to translate the center of projection of an image by some amount (x0, y0), you can simply add x0 to the x value of every coordinate (wrapping around to the other side at the edges). The y coordinate is similar - add y0 to every coordinate. However, instead of wrapping around, you need to reflect the value. So if your new coordinate is less than 0, simply take the absolute value. If it's greater than the height, take the difference between the new value and the height of the image and subtract that from the height of the image. If it was less than 0 or greater than height then you need to also add half the width to the x coordinate.

So putting it in pseudocode:

```
newY = oldY + translateY;
if (newY < 0)
{
    newY = fabs(newY);
    translateX = fmod((translateX + (width / 2.0)), width);
}
else if (newY >= height)
{
    newY = height - (newY - height);
    translateX = fmod((translateX + (width / 2.0)), width);
}
newX = oldX + translateX;
if (newX < 0)
{
    newX = width + newX;
}
else if (newX >= width)
{
    newX = newX - width;
}

```


---

