MelBartels / AstronomyCalculatorsJavaScript

Astronomical calculators for telescope making, telescope observations and telescope control. Browser based.
11 stars 1 forks source link

Help With Alt-Az Tracking Calculations #1

Closed mtnbkr88 closed 1 week ago

mtnbkr88 commented 1 week ago

Hi Mel,

I haven't found any email address for you so I'm trying to reach you through here.

I have a 12" Dobsonian I'm trying to motorize using stepper motors and a Raspberry Pi Zero W. I start by positioning my telescope at a specific Alt-Az, then based on my Lat/Lon, I want to track the object. So I need to know what rates to use to for Alt-Az changes to track the object. I found your page https://www.bbastrodesigns.com/altazCalc.html which generates the info so I know it's possible, but at this time the math is beyond me. I'm hoping you are willing to share the formulas you use to generate the information in altaxCalc.html so I might be able to code them into my Telescope Motor Control Python script on my Raspberry Pi. If not, maybe you can tell me where to find them?

Given the huge number of Dobsonian telescopes out there, I'm surprised these formula aren't readily available on the internet. At least I can't find them.

Any help will be greatly appreciated.

Thank you, Ed Williams Big Bear City, CA

MelBartels commented 1 week ago

Ed, you can reach me at melvinbartels@gmail.com

My scope to sky calculator is my best code and shows a couple of ways of calculating the equat to altaz coordinate transformation. One way is spherical trig and the other is matrix. The modern way which I haven't coded up is to use quaternions. I am sure Python has a quaternion library so it is like one line of code to call.

Anyhow, back to my code. Look at https://bbastrodesigns.com/scopeToSky.html The relevant code/formula is in https://bbastrodesigns.com/lib/coordLib.js and its unit test https://bbastrodesigns.com/lib/calcLib%20unitTests.htm

Start with the calcLib.js file, lines 2890-

// bridge trig and matrix conversion routines into a single interface MLB.coordLib.XForm = function (convertStyle, latitude) { ...

then go to lines 1737-

/ set latitude, position alt, az, and SidT (all in radians) before calling; if southern hemisphere, then flip az bef. calc, followed by flip dec after: necessary to conform to coordinate scheme for southern hemisphere / MLB.coordLib.getEquatTrig = function (position, meridianFlip, latitude) { ...

the core routine calls being lines 1678-

position.Dec = convertSecAxis(absLatitude, az, position.alt);
// depends on Dec
position.HA = convertPriAxis(absLatitude, position.Dec, az, position.alt);

...

So then the fundamental coordinate transformation is lines 1662-

MLB.coordLib.convertPriAxis = function (lat, toSec, fromPri, fromSec) { var cosToPri, toPri, uom = MLB.sharedLib.uom, validRev = MLB.coordLib.validRev, reverseRev = MLB.coordLib.reverseRev;

// avoid dividing by zero (Math.cos(lat)) when lat = 90 or -90
if (lat === uom.qtrRev) {
    return validRev(fromPri + uom.halfRev);
}

cosToPri = (Math.sin(fromSec) - Math.sin(lat) * Math.sin(toSec)) / (Math.cos(lat) * Math.cos(toSec));
if (cosToPri < -1) {
    cosToPri = -1;
} else if (cosToPri > 1) {
    cosToPri = 1;
}
toPri = Math.acos(cosToPri);
// heading east or west of 0 pt?
if (Math.sin(fromPri) > 0) {
    toPri = reverseRev(toPri);
}
return toPri;

};

MLB.coordLib.convertSecAxis = function (lat, fromPri, fromSec) { var sinToSec = Math.sin(fromSec) Math.sin(lat) + Math.cos(fromSec) Math.cos(lat) * Math.cos(fromPri);

return Math.asin(sinToSec);

}; ...

A key to understand is that equat coordinates are really hour angle and declination, hour angle comes from RA and local sidereal time.

The JS to Python should be easy to manage since you will want to use Python on the Pi.

Let me know - Mel