mathnet / mathnet-spatial

Math.NET Spatial
http://spatial.mathdotnet.com
MIT License
376 stars 132 forks source link

Vector2D.SignedAngleTo returns bad angle result (fix described) #195

Closed sdoiel61 closed 1 year ago

sdoiel61 commented 2 years ago
                Vector2D inst = new Vector2D(15, -0.014999866485595703);
                Vector2D arg = new Vector2D(14.999354151329246, 0.14000013927224053);
                Angle signedAngleTo = inst.SignedAngleTo(arg, false, true);

Result: Degrees -359.40793611193084 double Radians -6.27285184295062 double

Fix - Change line 334: var a = sign (a2 - a1); To: var a = Math.IEEERemainder( sign (a2 - a1), 2.0 * Math.PI );

Note, the lines: if (a > Math.PI && returnNegative) { a -= 2 * Math.PI; } Can then be deleted (lines 340 to343)

Fixed result: Degrees 0.5920638880691893 double Radians 0.010333464228966527 double

I forked and cloned the repository but I could not get the project to build.

mathnet-spatial.paket\Paket.Restore.targets(171,5): error MSB3073: The command "dotnet paket restore" exited with code 1.

I have no idea what tool this is attempting to use but it is not present on my system.