# How to translate the center of an equirectangular projection?

Computer Graphics Asked by Lucio Coire Galibone on March 3, 2021

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.

An 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;
}


Answered by user1118321 on March 3, 2021

## Related Questions

### Why does opengl use 4d matrices for everything?

3  Asked on August 27, 2021 by yoris

### How can i wrap the earth image around a 3D Sphere using OpenGL, GLFW, GLAD, GLM?

2  Asked on August 27, 2021 by b_cass_

### Defining “inside” and “outside” of a 3D space

2  Asked on August 27, 2021 by avatrin

### Using Bresenham’s circle algorithm (or another alternative algorithm) to draw an arc

1  Asked on August 27, 2021 by gusman

### Performance of Compute Shaders vs. Fragment Shaders for Deferred Rendering

1  Asked on August 27, 2021 by imallett

### Which perspective projection matrix to use

1  Asked on August 27, 2021 by nixcc

### Perspective correct interpolation z-buffer

1  Asked on August 27, 2021 by lightxbulb

### How is orthographic projection used in computer graphics technically classified as a projection?

1  Asked on August 27, 2021

### Why negate z when constructing projection matrix OpenGL

2  Asked on August 27, 2021

### UV partial derivatives of a cylinder shape primitive

1  Asked on August 27, 2021 by wdc

### OpenGL Framebuffer with multiple Depthbuffers inside

1  Asked on August 27, 2021

### Efficiently generating mesh for self-generated voxel grid

1  Asked on August 27, 2021 by andygeers

### How do you apply a normal map to a 3d mesh?

1  Asked on August 27, 2021 by calvin-godfrey

### What’s a good research topic in Computer Graphics?

0  Asked on August 27, 2021

### When unsetting a VAO, should you also unbind the associated VBOs?

1  Asked on August 27, 2021 by natew

### Reading from buffer versus calculating on the fly performance

1  Asked on August 27, 2021 by wduk

### How are textures projected onto 3d models in texture painting applications

1  Asked on August 27, 2021 by lenny-white

### Conditionals and branching in shaders

0  Asked on August 27, 2021

### Does atomic functions on same memory location cause an performance issue?

1  Asked on August 27, 2021

### Phong model: why no multiplication by N dot L in specular term?

1  Asked on August 27, 2021 by kuba

### Ask a Question

Get help from others!