Astronomy: Distance and Midpoint Between Two Celestial Objects
Stars and celestial objects have the equatorial coordinates ( α, δ, R ) where:
α = right ascension in hours, minutes, and seconds
δ = declination in degrees, minutes, and seconds
R = distance to the celestial about (in light years, astronomical units, etc)
Convert α and δ to decimal degrees:
α = (hours + minutes/60 + seconds/3600) * 15
δ = sign(δ) * ( |degrees| + |minutes/60| + |seconds/3600| )
However, calculating distance between two points in space requires that we have cartesian coordinates (x, y, z). The conversion formulas to go from equatorial to cartesian coordinates are:
x = R * cos δ * sin α
y = R * cos δ * cos α
z = R * sin δ
For completeness, here are the conversion formulas to from cartesian to equatorial coordinates:
R = √(x^2 + y^2 + z^2)
δ = asin(z/R)
α = atan(y/x) (pay attention to the quadrant!). Alternatively: α = arg(x + i*y)
The distance formula between two points in space is:
D = √( (x2 - x1)^2 + (y2 - y1)^2 + (z2 - z1)^2 )
Source: http://en.m.wikipedia.org/wiki/Equatorial_coordinate_system
Example
Find the distance between Sagittarius A* (center of the Milky Way Galaxy) and the Andromeda Galaxy (M31).
Equatorial Coordinates:
From Wolfram Alpha: ( http://m.wolframalpha.com )
Sagittarius A*:
R = 24,824 light years
α = 17h45m40s = 266.42°
δ = -29°0'28" = -29.008°
Andromeda Galaxy:
R = 2,571,000 light years
α = 42m40s = 10.68°
δ = 41°16'8" = 41.269°
Converting to the cartesian system:
Sagittarius A*:
x = -21,667.514038
y = -1,355.611275
z = -12,037.945401
Andromeda Galaxy:
x = 358,122.65578
y = 1,898,943.67736
z = 1,695,818.99789
Calculation:
D = √( (-21,667.514038 - 358,122.65578)^2 + (-1,355.611275 - 1,898,943.67736)^2
+ (-12,037.945401 - 1,695,818.99789)^2 ) ≈ 2,583,051.16059
The distance between Sagittarius A* and the Andromeda Galaxy is about 2.583 million light years.
Happy Thanksgiving, or Day of Thanks, wherever you are. Please be safe and use good judgement. We need all the positive we can get on Earth, and in the cosmos. Cheers!
Eddie
This blog is property of Edward Shore. 2014
Wednesday, November 26, 2014
Astronomy: Distance and Midpoint Between Two Celestial Objects
Thursday, September 13, 2012
Cartesian Coordinates to Pixel (Screen) Coordinates
Converting Cartesian Coordinates to Screen Coordinates
When working with computer or calculator graphics, sometimes we have to work with screen coordinates. The screen coordinate system has the following:
1. The upper corner pixel (point) is (0,0).
2. The lower corner pixel is (A, B).
3. The x axis increases in the right direction.
4. The y axis increases in the down direction, the opposite direction of the Cartesian plane.
In order to to convert a point (x, y) in the Cartesian coordinates to point (xp, yp) in Screen coordinates, first observe the following:
1. Picture the plane you are working with as a screen. If you are working with a calculator or computer, this is fairly easy.
2. Let Xmin be the least-valued x of the screen (left edge) and Xmax be the most-valued x (right edge). Similarly, let Ymin be the least-valued y of the screen (bottom) and Ymax be the most-valued y of the screen (top).
You can check with the window settings on a graphing calculator to verify Xmax, Xmin, Ymax, and Ymin.
For the Hewlett Packard 28 series, 48 series and 50g, the variables XRNG and YRNG list the screen's dimensions, {Xmin, Xmax} for XRNG and {Ymin, Ymax} for YRNG.
To transform Cartesian coordinates to screen coordinates, we can use transformation matrices for scaling and translation. The general form
show the transformation from coordinates (x, y) to (x', y') where:
s_x = scale of the new x axis. If s_x < 0, the x point is reflected with respective to the x axis.
s_y = scale of the new y axis. If s_y < 0, the y point is reflected with respected to the y axis. In going from Cartesian coordinates to screen coordinates, s_y < 0.
x_s = Is the translation (shift to the new center) in the x-direction. If x_s > 0, the new center is to the right of the original center. Similarly, if x_s < 0, the new center is to the left of the original center.
y_s = Is the translation (shift to the new center) in the y-direction. If y_s > 0, the new center is to the above the original center. Similarly, if y_s < 0, the new center is to the below the original center.
For the transformation from Cartesian coordinates to screen coordinates:
s_x = A / (Xmax - Xmin)
s_y = -B / (Ymax - Ymin)
Since the new center will be at (Xmin, Ymax):
x_s = -Xmin
y_s = -Ymax
Therefore by matrix multiplication, with x' = xp and y' = yp:
xp = (x - Xmin) * A / (Xmax - Xmin)
yp = (y - Ymax) * -B / (Ymax - Ymin)
On the HP 48 series and 50g, the translation from Cartesian to screen coordinates can be accomplished with the C→PX function.
Example:
Using the following window with settings Xmin = -5, Xmax = 5, Ymin = -4, and Ymax = 4, transform the Cartesian coordinate (1, 0) to screen coordinates. The screen has pixel size 130 × 79.
In this case, A = 130 and B = 79.
Then:
xp = 130 / (5 - (-5)) * (1 - (-5)) = 78
yp = -79 / (4 - (-4)) * (0 - 4) = 39.5
The screen coordinate of (1, 0) is {78, 39.5}.
HP 50g Programs
DPIX
This program figures the distance in pixels between two points stated in Cartesian coordinates.
Input:
2: coord-y
1: coord-x
Output:
1: Distance
Program:
<< C→PX SWAP C→PX - DUP * ΣLIST B→R √ R→B >>
Example:
Using the following window with settings Xmin = -5, Xmax = 5, Ymin = -4, and Ymax = 4, find the pixel distance between (0,1) and (-1,-2)? (HP 50g pixel dimension 130 × 79)
2: (0,1)
1: (-1,-2)
DPIX
Answer in Decimal mode: #32d. (Approxmiately 32)
ARCEZ
This draws the arc using Cartesian coordinates and the radius in Cartesian scale (the way one would think if drawing on a Cartesian plane). This program does all the necessary transformation for you. You can use it in a program (requiring a PICTURE command later in a program) or alone (press the left arrow button to show the graph screen).
Input:
4: Cartesian Coordinates (x,y)
3: Radius in Cartesian form (the way you think)
2: Beginning Angle
1: Ending Angle
<< → P R A B
<< P DUP R +
C→PX SWAP C→PX - DUP * ΣLIST B→R √ R→B
P C→PX SWAP A →NUM B →NUM ARC >> >>
Example:
Using the following window with settings Xmin = -5, Xmax = 5, Ymin = -4, and Ymax = 4, draw a circle with radius 1.5 and center (1,0). (HP 50g pixel dimension 130 × 79)
In Radians Mode:
4: (1,0)
3: 1.5
2: 0
1: 2 * π
ARCEZ
Pressing the left arrow button will show the picture below (with no functions selected and additional drawing):
This concludes today's blog entry. As always, thank you for all your comments and support. Have a great day!
This blog is property of Edward Shore. © 2012
Symmetric Quartic Equation - Python
Symmetric Quartic Equation - Python Note: The code is programmed with a TI-84 Evo. No modules are used, so the scripts should be adopt...