@@ -24,8 +24,8 @@ This Source Code Form is subject to the terms of the Mozilla Public
2424namespace NINA . Equipment . Equipment . MyDome {
2525
2626 public class DomeSynchronization : IDomeSynchronization {
27- private static double TWO_PI = 2.0 * Math . PI ;
28- private static double HALF_PI = Math . PI / 2.0 ;
27+ private const double TWO_PI = 2.0 * Math . PI ;
28+ private const double HALF_PI = Math . PI / 2.0 ;
2929
3030 private readonly IProfileService profileService ;
3131
@@ -43,7 +43,6 @@ public TopocentricCoordinates TargetDomeCoordinates(
4343 return TargetDomeCoordinates ( scopeCoordinates : scopeCoordinates , localSiderealTime : localSiderealTime , siteLatitude : siteLatitude , siteLongitude : siteLongitude , siteElevation : 0 , sideOfPier : sideOfPier ) ;
4444 }
4545
46-
4746 /// <summary>
4847 /// Gets the dome coordinates required so the scope points directly out of the shutter. This works for Alt-Az, EQ mounts, and fork mounts on a wedge
4948 /// and depends on careful user measurements including:
@@ -77,16 +76,17 @@ public TopocentricCoordinates TargetDomeCoordinates(
7776 PierSide sideOfPier ) {
7877 scopeCoordinates = scopeCoordinates . Transform ( Epoch . JNOW ) ;
7978 var domeSettings = profileService . ActiveProfile . DomeSettings ;
79+
8080 // To calculate the effect of rotations in the southern hemisphere we augment a few of the rotations to pretend as if it were the northern hemisphere,
8181 // and then add 180 degrees to the final result
82-
8382 var origin = new Vector4 ( 0 , 0 , 0 , 1 ) ;
84- Matrix4x4 scopeOriginTranslation ;
85- if ( domeSettings . MountType == MountTypeEnum . EQUATORIAL ) {
86- scopeOriginTranslation = CalculateGEM ( scopeCoordinates , localSiderealTime , siteLatitude , sideOfPier ) ;
87- } else {
88- scopeOriginTranslation = CalculateForkOnWedge ( scopeCoordinates , localSiderealTime , siteLatitude ) ;
89- }
83+
84+ var scopeOriginTranslation = domeSettings . MountType switch {
85+ MountTypeEnum . EQUATORIAL => CalculateGEM ( scopeCoordinates , localSiderealTime , siteLatitude , sideOfPier ) ,
86+ MountTypeEnum . FORK_ON_WEDGE => CalculateForkOnWedge ( scopeCoordinates , localSiderealTime , siteLatitude ) ,
87+ MountTypeEnum . ALT_AZ => CalculateAltAz ( scopeCoordinates , siteLatitude , siteLongitude ) ,
88+ _ => throw new NotSupportedException ( $ "Unsupported mount type: { domeSettings . MountType } ") ,
89+ } ;
9090
9191 var scopeApertureOrigin = scopeOriginTranslation * origin ;
9292
@@ -207,5 +207,40 @@ private Matrix4x4 CalculateGEM(
207207
208208 return mountOffset * latitudeAdjustment * raRotationAdjustment * decRotationAdjustment * gemAdjustment ;
209209 }
210+
211+ private Matrix4x4 CalculateAltAz (
212+ Coordinates scopeCoordinates ,
213+ Angle siteLatitude ,
214+ Angle siteLongitude ) {
215+ var domeSettings = profileService . ActiveProfile . DomeSettings ;
216+
217+ // Alt-Az mounts rotate in altitude (around the y-axis) and azimuth (around the z-axis)
218+ // Altitude is Dec, Azimuth is Azimuth derived from RA/Dec + LST
219+
220+ // Convert scope RA/Dec to horizontal coordinates (Alt/Az)
221+ var topocentric = scopeCoordinates . Transform ( siteLatitude , siteLongitude , 0d ) ; // elevation not critical here
222+
223+ // Altitude rotation: scope tilts up from horizontal
224+ var altitudeRotation = Matrix4x4 . CreateRotationY ( ( float ) ( - topocentric . Altitude . Radians ) ) ;
225+
226+ // Azimuth rotation: scope rotates around the dome’s vertical axis (z-axis)
227+ var azimuthRotation = Matrix4x4 . CreateRotationZ ( ( float ) ( - topocentric . Azimuth . Radians ) ) ;
228+
229+ // Mount offset from dome center
230+ var mountOffset = Matrix4x4 . CreateTranslation ( new Vector3 (
231+ ( float ) domeSettings . ScopePositionNorthSouth_mm ,
232+ ( float ) domeSettings . ScopePositionEastWest_mm ,
233+ ( float ) domeSettings . ScopePositionUpDown_mm
234+ ) ) ;
235+
236+ // Lateral axis offset (side-by-side)
237+ var lateralOffset = Matrix4x4 . CreateTranslation ( new Vector3 (
238+ 0.0f ,
239+ 0.0f ,
240+ - ( float ) domeSettings . LateralAxis_mm
241+ ) ) ;
242+
243+ return mountOffset * azimuthRotation * altitudeRotation * lateralOffset ;
244+ }
210245 }
211246}
0 commit comments