First, let assume your image geometry is homogeneous, and has no peculiar distorsion in either direction.
Second, let assume you have the resolution of your image: the number of arcseconds / pixel.
Now, take one 'red-cross' star, call it A. It will be the origin of the triangle we will draw. Name your 'yellow-cross' star B. Now, take a new point, called 'C', that is at the same pixel-y coordinate of A, and the same pixel-x coordinates of B.
Drawing lines between A, B and C gives you a right triangle. You cannot simply apply flat geometry equations, since you are on the celestial sphere.
Hence, one must compute the 'Bearing' angle between A, B and C. See for instance here: (A bearing is an angle, measured clockwise from the north direction).
Here is a little piece of code you should be able to read:
double adjacent = pow(pow(B.x-C.x, 2.0) + pow(B.y-C.y, 2.0), 0.5); // dBC
double opposite = pow(pow(A.x-C.x, 2.0) + pow(A.y-C.y, 2.0), 0.5); // dAC
double theta = atan2(opposite, adjacent) * ONE_RAD_IN_DEGREES;
theta
is the bearing angle, here expressed in degrees, thanks to the conversion constant ONE_RAD_IN_DEGREES
. atan2
is the Arc-Tangent function that takes care of which quadrant you are in (it computes arctangent(opposite / adjacent)
, correcting for the quadrant, see the wikipedia article for instance).
Now, depending on whether you have East to the left or not (astro images have East to the left usually), you need to correct your angle. Again this little piece of code:
BOOL eastLeft = <true or false>
if (B.x < A.x && B.y > A.y) {
theta = (eastLeft) ? theta : 360.0 - theta;
}
else if (B.x < A.x && B.y < A.y) {
theta = (eastLeft) ? 180.0 - theta : theta + 180.;
}
else if (B.x > A.x && B.y < A.y) {
theta = (eastLeft) ? theta + 180. : 180.0 - theta;
}
else if (B.x > A.x && B.y > A.y) {
theta = (eastLeft) ? 360.0 - theta : theta;
}
Now, we have the correct theta
value. Now, compute the distance (below, in degrees) between A and B, and call it delta
.
Assuming the R.A. and Declination of A are called lambda1
and phi1
, you can compute the R.A. and Declination of C, lambda2
and phi2
, using the formulae given in here, under the section "Destination point given distance and bearing from start point".
In my code:
double phi1 = declination_A * ONE_DEG_IN_RADIANS;
double lambda1 = rightAscension_A * ONE_HOUR_IN_RADIANS;
double delta = degrees * ONE_DEG_IN_RADIANS;
double theta = bearing * ONE_DEG_IN_RADIANS;
double phi2 = asin(sin(phi1)*cos(delta) + cos(phi1)*sin(delta)*cos(theta));
double lambda2 = lambda1 + atan2(sin(theta) * sin(delta) * cos(phi1), cos(delta) - sin(phi1) * sin(phi2));
with the usual meaning of trigonometric functions (sin
is sine, asin
is arcsine, etc).
No comments:
Post a Comment