# Nearest Math Plugin for INDI::Alignment Subsystem

**URL:** <https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744>\
**Category:** Mounts\
**Created:** [July 31, 2021, 9:24pm UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744 "2021-07-31T21:24:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![knro](https://forum.indilib.org/user_avatar/forum.indilib.org/knro/32/64_2.png) [@knro](https://forum.indilib.org/u/knro)\
**Post date:** [July 31, 2021, 9:24pm UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744/1 "2021-07-31T21:24:59Z")

</div>

I just finished adding Nearest Math Plugin to INDI::Alignment Subsystem. It was tested with EQMod using the alignment system instead of its own built-in alignment system developed by Jean-Luc. The Nearest Math plugin was adapted from the nearest algorithm used in EQMod, and I have to say it performs a lot better for those who want a quick Capture & Solve experience.

The Built in Math & SVD plugins do a much better job at N-Star alignment modeling. So they are worth investigating for those who are interested in this. For the time being, I invite all users to try out this new math plugin, and you can switch to it in the Alignment tab of the driver. It is available for drivers that use the INDI Alignment Subsystem:

- AstroTrac
- Celestron AUX
- EQMod (but you must explicitly switch to INDI Alignment in Options)
- Temma
- SkyWatcher driver.

I haven’t tested this for Alt-Az mounts so it would be good to report back for such mounts. Recently, the alignment system in INDI received an overhaul. This is the first time I take a stab at it in years since it’s probably one of the most complex aspects of INDI. At any rate, please test and report back.

---

<div class="post-metadata">

**Author:** ![luzik](https://forum.indilib.org/letter_avatar_proxy/v4/letter/l/eada6e/32.png) [@luzik](https://forum.indilib.org/u/luzik)\
**Post date:** [September 5, 2021, 5:12pm UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744/2 "2021-09-05T17:12:17Z")

</div>

Is this already released ?  
Wanted to test with Alt-Az

---

<div class="post-metadata">

**Author:** ![knro](https://forum.indilib.org/user_avatar/forum.indilib.org/knro/32/64_2.png) [@knro](https://forum.indilib.org/u/knro)\
**Post date:** [September 5, 2021, 7:53pm UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744/3 "2021-09-05T19:53:15Z")

</div>

It’s in beta/nightly, please test from there if you can.

---

<div class="post-metadata">

**Author:** ![interplanetary](https://forum.indilib.org/letter_avatar_proxy/v4/letter/i/779978/32.png) [@interplanetary](https://forum.indilib.org/u/interplanetary)\
**Post date:** [December 25, 2023, 2:22am UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744/4 "2023-12-25T02:22:39Z")

</div>

Jasem,

I am currently developing an Alt/Az driver for a “dumb” Alt/Az mount that does not have any built-in capabilities — it just takes position commands and feeds back encoder position. To enhance its functionality, I have been integrating the Alignment subsystem into the driver. During this process, I encountered some unexpected results with the TelescopeAltAzToSky and SkyToTelescopeAltAz transformations, which led me to finding this thread about Nearest Math Plugin.

After your mention of looking for AltAz testers, I decided to switch the Math plugin to the SVD (Singular Value Decomposition) Math Plugin. This change resulted in the transformations aligning with my expectations.

Perhaps there might be a bug in the Nearest Math plugin? To provide more context, my use case involves a significant misalignment scenario. Specifically, I have adjusted my mount to have its hardstop pointing west, effectively rotating the mount by in azimuth 90 degrees. It’s possible that this substantial misalignment might be contributing to the issues I observed.

Additionally, I noticed that the Inbuilt Math Plugin also struggles with accurate transformations under these conditions, so perhaps its a common failure mode, or the code isn’t meant to address very large misalignments.

Let me know if there are any tests I can do to provide insight.

---

<div class="post-metadata">

**Author:** ![knro](https://forum.indilib.org/user_avatar/forum.indilib.org/knro/32/64_2.png) [@knro](https://forum.indilib.org/u/knro)\
**Post date:** [December 25, 2023, 4:30am UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744/5 "2023-12-25T04:30:48Z")

</div>

Thank you Chris for looking into this! The nearest plugin is pretty straight forward without any fancy math. How does it exactly not meet your expectation?

---

<div class="post-metadata">

**Author:** ![interplanetary](https://forum.indilib.org/letter_avatar_proxy/v4/letter/i/779978/32.png) [@interplanetary](https://forum.indilib.org/u/interplanetary)\
**Post date:** [December 25, 2023, 5:30am UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744/6 "2023-12-25T05:30:35Z")

</div>

Merry Christmas! Alignment simply doesn’t perform the correct transformations either from mount to sky or sky to mount, after syncing it with 4 points. My observation site is fairly constrained, so I’m not able to do a full east/west sync point or north/south sync point.

To accelerate testing, I created a function to inject sync points, and set it up as follows:

1. 0 degrees altitude, 90 degrees azimuth (due east)
2. 45 degrees altitude, 90 degrees azimuth (east-up)
3. 60 degrees altitude 45 degrees azimuth (north-east, up)
4. 0 degrees altitude, 180 degrees azimuth (due south)

Neither the nearest plugin, or the built-in can consistently map the sky or mount coordinates against its physical location, but the SVD algorithm seems to do well (with limited testing).

---

<div class="post-metadata">

**Author:** ![luzik](https://forum.indilib.org/letter_avatar_proxy/v4/letter/l/eada6e/32.png) [@luzik](https://forum.indilib.org/u/luzik)\
**Post date:** [December 25, 2023, 5:11pm UTC](https://forum.indilib.org/t/nearest-math-plugin-for-indi-alignment-subsystem/8744/7 "2023-12-25T17:11:10Z")

</div>

This is my old bug report for this code. Do we talking about the same issue ?

1. Reboot software and mount, let it go with fresh run.  
2. Set physically mount to point 20deg Alt, 0 deg Az North  
3. Using Kstars mount control sync it to that point (change to az → enter values AZ:0 and AL:20 → press sync)  
4. Using Kstars mount control only left arrow move the mount 90 deg left to AZ 270 West  
5. notice that mount physically is pointing AZ:270 ALT:20, Kstars report it as AZ:270 ALT:0  
6. Using Kstars mount control sync to point where mount is physically pointing (enter values AZ:270 AL:20 → press sync)  
7. Using Kstars mount control goto back to AZ: 0 North ALT:20  
8. this is looking all right  
9. Using Kstars mount control goto AZ:90 East ALT:20  
boooom!!! My mount physically going to AZ:90 ALT:60 !!
