How can I change my viewpoint within a celestial sphere in planetarium software?

  • Thread starter djbog
  • Start date
  • Tags
    Astronomy
In summary, the conversation discusses a problem with changing the Alt/Az position of a viewpoint in a planetarium software. The solution was to convert everything into Cartesian coordinates and apply rotations around the x, y and z-axis. The formula for these rotations can be found in a games programming book.
  • #1
djbog
2
0
Hi, I couldn't decide whether this was more maths or more astronomy, but I settled for maths. Sorry for the long description, I think the answer is quite simple, and I'm making a meal of it!

I am currently writing some planetarium software for use on my website. I have calculated the Alt/Az of lots of objects, and used the conversion to spherical polars to plot them onto a cartesian xy plane (the screen!) with r=1. For those of you who are not sure, Alt is the altitude of the object above the horizon (0-90 deg) and Az is the azimuth (0-360 deg) measured East from North. The zenith (directly up) is at (0,0).

This all works fine. My problem is that I want to move my viewpoint around within the 'celestial sphere'. I can zoom in and out with no problem, and I can add small amounts to the the Azimuth of each object in order to rotate the 'sky'. What I cannot do is change the Alt of the point at which I am looking, the default is to look straight up at the zenith.

I assume to accomplish this, I need to add or subtract a certain value from the Alt and Az of each object. I cannot get my head around how to do this.

I have attached an image as an example. The circle shows a bottom-up view of a hemisphere. Firstly my viewpoint is centered on the zenith (0 deg, 0 deg). Here, A is at (20 deg, 0 deg) B is at (20 deg, 90 deg) C is at (20 deg, 180 deg) and D is at (20 deg, 270 deg). If I was to move my viewpoint to X (10 deg, 0 deg), then clearly A would become(10 deg, 0 deg) and C would be (30 deg, 180 deg). How would I find the apparent Alt/Az of B and D, and is there a generalised form of this that I could use using any offset to any initial position?

I might be making this much harder than it actually is, so if you can help or you have any questions, please give me a shout.
 

Attachments

  • mths help.jpg
    mths help.jpg
    16.3 KB · Views: 347
Mathematics news on Phys.org
  • #2
djbog said:
I assume to accomplish this, I need to add or subtract a certain value from the Alt and Az of each object. I cannot get my head around how to do this.

If your initial position is the zenith (your line of sight?), you would have to subtract some value. You would also have to specify an azimuth direction in accordance, so that you know which of the infinitely many directions that you desire for your new line of sight. It's like standing exactly on the north pole of the earth.

djbog said:
I have attached an image as an example. The circle shows a bottom-up view of a hemisphere. Firstly my viewpoint is centered on the zenith (0 deg, 0 deg). Here, A is at (20 deg, 0 deg) B is at (20 deg, 90 deg) C is at (20 deg, 180 deg) and D is at (20 deg, 270 deg). If I was to move my viewpoint to X (10 deg, 0 deg), then clearly A would become(10 deg, 0 deg) and C would be (30 deg, 180 deg). How would I find the apparent Alt/Az of B and D, and is there a generalised form of this that I could use using any offset to any initial position?

When you change coordinates to A and say that the other coordinates are changing, you are talking about the "relative" coordinates to your line of sight; the Alt/Az coordinates should not change value at all unless you have moved to a new location on Earth or a significant time interval has passed.

It's really difficult for me to say anything else. I'm not familiar with your program. Do you have a workable version currently online? What portion of the sky is visible in your program, a small-portion or the whole local sky? Does your program permit the user to change locations on Earth or viewing time?
 
Last edited:
  • #3
Hi, just a note to say that I solved (well got around!) this problem, by converting everything into Cartesian (xyz) coordinates, then applying the transformations that can be seen in the attached image. I found these formula in an old games programming book, and I even though this clearly isn't the native coordinate system of astronomy, I actually understand it, so it makes it a great deal easier for me to work with.

Alpha, beta and gamma refer to rotations around the z, x and y-axis respectively. Remember that the order that you do them in makes a huge difference to the outcome!

Thank you for your response, If I hadn't have done it this way I may well have been working with you to figure it out.
 

Attachments

  • equation.jpg
    equation.jpg
    7 KB · Views: 349

Related to How can I change my viewpoint within a celestial sphere in planetarium software?

1. What is the formula for calculating the distance between two celestial objects?

The formula for calculating the distance between two celestial objects is the distance formula, which is d = √((x2 - x1)2 + (y2 - y1)2 + (z2 - z1)2), where (x1, y1, z1) and (x2, y2, z2) are the coordinates of the two objects.

2. How do you convert between different units of measurement in astronomy?

In astronomy, different units of measurement are commonly used to describe distances, masses, and other quantities. To convert between these units, you can use conversion factors. For example, to convert from kilometers to miles, you can use the conversion factor 1 km = 0.6214 miles.

3. What is the equation for calculating the size of a celestial object?

The equation for calculating the size of a celestial object is r = √((3V)/(4π)), where r is the radius and V is the volume of the object. This equation assumes that the object is approximately spherical in shape.

4. How do you calculate the orbital period of a planet?

The orbital period of a planet can be calculated using Kepler's third law, which states that the square of the orbital period is proportional to the cube of the semi-major axis of the planet's orbit. The equation for this is T2 = (4π2)/(G(M1+ M2))a3, where T is the orbital period, G is the gravitational constant, M1 and M2 are the masses of the planet and the star it orbits, and a is the semi-major axis of the planet's orbit.

5. How do you use trigonometry in astronomy calculations?

Trigonometry is used in astronomy to calculate distances and angles between celestial objects. The most commonly used trigonometric functions in astronomy are sine, cosine, and tangent. These functions can be used to calculate the angular distance between two objects, the altitude and azimuth of an object, and the size and shape of an object's orbit.

Similar threads

Replies
6
Views
2K
Replies
1
Views
2K
  • Astronomy and Astrophysics
Replies
15
Views
4K
Replies
86
Views
4K
  • Beyond the Standard Models
Replies
14
Views
3K
  • Astronomy and Astrophysics
Replies
2
Views
4K
  • Introductory Physics Homework Help
Replies
1
Views
2K
Replies
3
Views
943
Replies
10
Views
1K
Back
Top