Skip to content

Commit 1e3341b

Browse files
committed
Support alt-az mounts in domes
1 parent 43e9a98 commit 1e3341b

File tree

4 files changed

+57
-10
lines changed

4 files changed

+57
-10
lines changed

NINA.Core/Enum/MountTypeEnum.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,8 @@ public enum MountTypeEnum {
3030

3131
[Description("LblForkOnWedge")]
3232
FORK_ON_WEDGE,
33+
34+
[Description("LblAltitudeAzimuth")]
35+
ALT_AZ,
3336
}
3437
}

NINA.Core/Locale/Locale.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7185,4 +7185,7 @@ Additionally, it is essential that the ASCOM driver used also supports this 32-b
71857185
<data name="LblCivilDawn" xml:space="preserve">
71867186
<value>Civil dawn</value>
71877187
</data>
7188+
<data name="LblAltitudeAzimuth" xml:space="preserve">
7189+
<value>Altitude-Azimuth</value>
7190+
</data>
71887191
</root>

NINA.Equipment/Equipment/MyDome/DomeSynchronization.cs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ This Source Code Form is subject to the terms of the Mozilla Public
2424
namespace 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
}

NINA/View/Options/DomeView.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
<DataTrigger Binding="{Binding ElementName=PART_MountTypeList, Path=SelectedItem}" Value="1">
153153
<Setter Property="Visibility" Value="Collapsed" />
154154
</DataTrigger>
155+
<DataTrigger Binding="{Binding ElementName=PART_MountTypeList, Path=SelectedItem}" Value="2">
156+
<Setter Property="Visibility" Value="Collapsed" />
157+
</DataTrigger>
155158
</Style.Triggers>
156159
</Style>
157160
</UniformGrid.Style>
@@ -182,6 +185,9 @@
182185
<DataTrigger Binding="{Binding ElementName=PART_MountTypeList, Path=SelectedItem}" Value="0">
183186
<Setter Property="Visibility" Value="Collapsed" />
184187
</DataTrigger>
188+
<DataTrigger Binding="{Binding ElementName=PART_MountTypeList, Path=SelectedItem}" Value="2">
189+
<Setter Property="Visibility" Value="Collapsed" />
190+
</DataTrigger>
185191
</Style.Triggers>
186192
</Style>
187193
</UniformGrid.Style>

0 commit comments

Comments
 (0)