Inaccurate rotation recreation

I am trying to create aiming dots that will help assist the player in launch the object is the desired direction.

The problem is that there is a weird offset that happens when aiming I can’t just add a number to fix it because this is circle type aiming system meaning radians and degrees are involved. I don’t know what to do please help.

Below is the relevant code and pictures.

public class AimingDots : MonoBehaviour {

public ArmLauncher armLauncher;  public float changingXAim; public float changingXAimUnRounded;  public GameObject[] madeDots; public GameObject fullDotObjects;  // Start is called before the first frame update void Start() {     armLauncher = FindObjectOfType<ArmLauncher>();     madeDots = GameObject.FindGameObjectsWithTag("AimingDot");      fullDotObjects = GameObject.Find("AimingDots");      foreach (GameObject aimDot in madeDots)     {         aimDot.gameObject.SetActive(false);     } }  // Update is called once per frame void Update() {     changingXAimUnRounded = armLauncher.changingX / 1400;     changingXAim = Mathf.Round(armLauncher.changingX / 200);     changingXAim = Mathf.Clamp(changingXAim, 0f, 9f);        MakeDots();     DotsBehavior();     RotateDots();      Debug.Log("Dot Rotation: " + fullDotObjects.transform.eulerAngles); }  public void MakeDots() {     if (changingXAim > 0.5f)     {         if (changingXAim >= 1 && changingXAim <= 1.9f)         {             madeDots[0].gameObject.SetActive(false);             madeDots[1].gameObject.SetActive(false);             madeDots[2].gameObject.SetActive(false);             madeDots[3].gameObject.SetActive(false);             madeDots[4].gameObject.SetActive(false);             madeDots[5].gameObject.SetActive(false);             madeDots[6].gameObject.SetActive(false);         }          if (changingXAim >= 2 && changingXAim <= 2.9f)         {             madeDots[0].gameObject.SetActive(true);             madeDots[1].gameObject.SetActive(false);             madeDots[2].gameObject.SetActive(false);             madeDots[3].gameObject.SetActive(false);             madeDots[4].gameObject.SetActive(false);             madeDots[5].gameObject.SetActive(false);             madeDots[6].gameObject.SetActive(false);         }         else if (changingXAim >= 3 && changingXAim <= 3.9f)         {             madeDots[0].gameObject.SetActive(true);             madeDots[1].gameObject.SetActive(true);             madeDots[2].gameObject.SetActive(false);             madeDots[3].gameObject.SetActive(false);             madeDots[4].gameObject.SetActive(false);             madeDots[5].gameObject.SetActive(false);             madeDots[6].gameObject.SetActive(false);         }         else if (changingXAim >= 4 && changingXAim <= 4.9f)         {             madeDots[0].gameObject.SetActive(true);             madeDots[1].gameObject.SetActive(true);             madeDots[2].gameObject.SetActive(true);             madeDots[3].gameObject.SetActive(false);             madeDots[4].gameObject.SetActive(false);             madeDots[5].gameObject.SetActive(false);             madeDots[6].gameObject.SetActive(false);         }         else if (changingXAim >= 5 && changingXAim <= 5.9f)         {             madeDots[0].gameObject.SetActive(true);             madeDots[1].gameObject.SetActive(true);             madeDots[2].gameObject.SetActive(true);             madeDots[3].gameObject.SetActive(true);             madeDots[4].gameObject.SetActive(false);             madeDots[5].gameObject.SetActive(false);             madeDots[6].gameObject.SetActive(false);         }         else if (changingXAim >= 6 && changingXAim <= 6.9f)         {             madeDots[0].gameObject.SetActive(true);             madeDots[1].gameObject.SetActive(true);             madeDots[2].gameObject.SetActive(true);             madeDots[3].gameObject.SetActive(true);             madeDots[4].gameObject.SetActive(true);             madeDots[5].gameObject.SetActive(false);             madeDots[6].gameObject.SetActive(false);         }         else if (changingXAim >= 7 && changingXAim <= 7.9f)         {             madeDots[0].gameObject.SetActive(true);             madeDots[1].gameObject.SetActive(true);             madeDots[2].gameObject.SetActive(true);             madeDots[3].gameObject.SetActive(true);             madeDots[4].gameObject.SetActive(true);             madeDots[5].gameObject.SetActive(true);             madeDots[6].gameObject.SetActive(false);         }         else if (changingXAim >= 8 && changingXAim <= 9)         {             madeDots[0].gameObject.SetActive(true);             madeDots[1].gameObject.SetActive(true);             madeDots[2].gameObject.SetActive(true);             madeDots[3].gameObject.SetActive(true);             madeDots[4].gameObject.SetActive(true);             madeDots[5].gameObject.SetActive(true);             madeDots[6].gameObject.SetActive(true);         }     } }  public void DotsBehavior() {     madeDots[0].gameObject.transform.localPosition = new Vector3(-2.47f, 0, 0);     madeDots[1].gameObject.transform.localPosition = new Vector3(madeDots[0].gameObject.transform.localPosition.x - changingXAimUnRounded, 0, 0);     madeDots[2].gameObject.transform.localPosition = new Vector3(madeDots[1].gameObject.transform.localPosition.x - changingXAimUnRounded, 0, 0);     madeDots[3].gameObject.transform.localPosition = new Vector3(madeDots[2].gameObject.transform.localPosition.x - changingXAimUnRounded, 0, 0);     madeDots[4].gameObject.transform.localPosition = new Vector3(madeDots[3].gameObject.transform.localPosition.x - changingXAimUnRounded, 0, 0);     madeDots[5].gameObject.transform.localPosition = new Vector3(madeDots[4].gameObject.transform.localPosition.x - changingXAimUnRounded, 0, 0);     madeDots[6].gameObject.transform.localPosition = new Vector3(madeDots[5].gameObject.transform.localPosition.x - changingXAimUnRounded, 0, 0); }  public void RotateDots() {     fullDotObjects.transform.eulerAngles = new Vector3(0, 0, -armLauncher.finalLaunch.y); } 

} ////////////////////////////////////////////////////////////////////////////////

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class ArmLauncher : MonoBehaviour {

public bool startTracking; public bool preTracking = true;  public GameObject throwingArmPiv; public GameObject phoneObject; public GameObject phoneLaunchPanel; public GameObject playerCharacter; public GameObject rotationManager;  public float yStartValueLaunchAngle, yValueLaunchAngle = 0; public float xStartValueLauchPower, xValueLauchPower = 0;  public Vector3 changingYLookArmRestricted; public Vector3 changingY;  public float changingX;  public Vector3 beforeTouchPosition, touchPosition; public Vector3 finalLaunch;  void Awake() {     startTracking = true; }  // Use this for initialization void Start () {     throwingArmPiv = GameObject.Find("ThrowingArmPiv");     phoneLaunchPanel = GameObject.Find("PhoneLaunchPanel");     rotationManager = GameObject.Find("RotationManager"); }  // Update is called once per frame void Update () {      beforeTouchPosition = new Vector3(Input.mousePosition.x, Input.mousePosition.y, Input.mousePosition.z);     touchPosition = Camera.main.ScreenToWorldPoint(beforeTouchPosition);      playerCharacter = GameObject.Find("PlayerCharacter");     StartTracking();      Debug.Log("final lauch: " + finalLaunch);  }  public void BeginArmLaunch() {     phoneObject = GameObject.Find("Phone");     xStartValueLauchPower = Input.mousePosition.x;     yStartValueLaunchAngle = Input.mousePosition.y;     startTracking = true; }  public void LaunchPhone() {     phoneLaunchPanel.SetActive(false);      startTracking = false;     phoneObject.GetComponent<Rigidbody2D>().bodyType = RigidbodyType2D.Dynamic;     phoneObject.GetComponent<Rigidbody2D>().mass = 10;      phoneObject.transform.SetParent(null);      phoneObject.GetComponent<Rigidbody2D>().velocity = finalLaunch;     phoneObject.GetComponent<SpriteRenderer>().sortingOrder = 9; }  public void StartTracking() {     if (startTracking)     {         xValueLauchPower = Input.mousePosition.x;         yValueLaunchAngle = Input.mousePosition.y;          changingY = throwingArmPiv.transform.eulerAngles = new Vector3(0, 0, Mathf.Atan2((touchPosition.y - transform.position.y), (touchPosition.x - transform.position.x)) * Mathf.Rad2Deg);          changingX = xValueLauchPower - xStartValueLauchPower;          changingYLookArmRestricted = new Vector3(0, 0, Mathf.Clamp(changingY.z, 23.8f, 132f));          throwingArmPiv.transform.eulerAngles = changingYLookArmRestricted;          finalLaunch = new Vector3(-changingX / 4, -changingY.z, 0f);          if (changingYLookArmRestricted.y <= 23.8f)         {             rotationManager.transform.eulerAngles = changingY / 2.35f;         }         else if (changingYLookArmRestricted.y >= 132f)         {             rotationManager.transform.eulerAngles = changingY / 4;         }      } } 

} //////////////////////////////////////////////////////// Example of it going wrong. You can see how it is slightly off /////////////////////////////////////////////////////// Example of when it goes right. For some reason its always around that rotation where it is correct //////////////////////////////////////////////////////  Example of when it foes wrong again. It is slightly off

iPhone compass woefully inaccurate

Not sure when this started, but heading/compass on 2 iPhones (6 and X) is way off for some reason. Magnetic north is off by 10-40°, depending on how much moving around I do. True north mostly works, but is also off. There is a difference between the two devices of 5-30° No electromagnetic interference that I can trace nearby. What could possibly cause this? The GPS signal on the X is also quite bad and takes very long to lock. I did the sim eject-reboot routine, to no effect

Inaccurate zero eigenvalues for 7*7 matrix

I have symbolic entries for all the elements of a 7*7 matrix. At the symbolic level Eigenvalues gives two zeroes and five others that are extremely complicated. At the same time Det evaluates to exactly zero.

I take this to mean that, no matter what values the symbols within the matrix are assigned, I will have at least two zero eigenvalues. Exactly zero eigenvalues.

However, when I assign values to the symbols by hand, for eg., a=10; b=50, and so on, and evaluate the same codes, Eigenvalues evaluates to give two eigenvalues of the order of 10^-12. For my purpose, this magnitude cannot be treated as a zero. And I am also in need of a different eigenvalue of the same matrix which is very small, of this order or even smaller, but is not exactly zero. So I need the zeroes to show up much more accurately.

I have tried adding $ MinPrecision=50 to my code before executing the rest of it. It does not help at all.

A similar question was posted, Is there a good way to check, whether a small value produced numerically is a symbolic zero? However I could not decipher anything of use out of it.