3

I have a bunch of 360 equirectangular images an on each image i want to place a point of interest. To make this easy i just want to have to determine the 2d location of this point on the image. See image below for clarification:

enter image description here

Lets say that the blue point has a pixel location of X: 3000 and Y: 1300. And that the total dimensions of the image are 4096x2048.

Now i want to convert this point to a spherical location and then to a 3d location. I try to do this in the following way:

Vector3 PlaceMenu(Vector2 loc2d)
{
    var phi = 2 * Mathf.PI * (loc2d.x / imageDimensions.x);
    var theta = ( loc2d.y / imageDimensions.y) * Mathf.PI;
    var pos = new Vector3(Mathf.Cos(phi) * Mathf.Sin(theta), Mathf.Sin(phi) * Mathf.Sin(theta), Mathf.Cos(theta));
    pos *= offsetRadius;

    return pos;
}

in this case offsetRadius is the radius of the sphere.

But the results i am getting with this code are weird. because the blue points appear on weird other locations then specified by the 2d location.

What am i doing wrong here?

If any more explaination is needed i am happy to provide!

FutureCake
  • 2,614
  • 3
  • 27
  • 70
  • What exactly do you mean by "weird"? Can you provide an example of what result you are expecting, and what you are getting instead? Also is the returned value of `pos` incorrect, or is it just the position of your blue point that is off? if it is the latter it might be a case of setting `transform.position` where `transform.localposition` is needed, or vice versa. – Remy Nov 28 '19 at 13:22
  • the position of the blue dot in 3d doesnt match up with the same location as on the 2d image. Everything is calculated with vector.zero as the origin of the cicle and there is no nesting of gameobjects. – FutureCake Nov 28 '19 at 13:27

0 Answers0