Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
rzError
//Rextester.Program.Main is the entry point for your code. Don't change it. //Compiler version 4.0.30319.17929 for Microsoft (R) .NET Framework 4.5 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { // Make rotation r -180 <= r <= 180 static double Normalize(double degrees) { while (degrees > 180) degrees -= 360; while (degrees < -180) degrees += 360; return degrees; } static void TestRzError(double target, double current, double expected) { double rzError = Normalize(((current%360) - (target%360)) % 360); const double tol = 1e-6; if (Math.Abs(rzError - expected) > tol) Console.WriteLine("{0} {1} error is {2} but expected {3}", target, current, rzError, expected); } public static void Main(string[] args) { TestRzError(180, 0, -180); // Expect -180 TestRzError(0, 180, 180); // Expect 180 TestRzError(90, 0, -90); // Expect -90 TestRzError(0, 90, 90); // Expect 90 TestRzError(180, -180, 0); // Expect 0 TestRzError(-180, 180, 0); // Expect 0 TestRzError(180, 0.01, -179.99); // Expect -179.99 TestRzError(0.01, 180, 179.99); // Expect 179.99 TestRzError(180, -179.99, .01); // Expect .01 TestRzError(180, 179.99, -.01); // Expect -.01 TestRzError(-180, -179.99, .01); // Expect .01 TestRzError(-180, 179.99, -.01); // Expect -.01 TestRzError(180.01, -179.99, 0); // Expect 0 TestRzError(-179.99, 180.01, 0); // Expect 0 TestRzError(179.99, -179.99, .02); // Expect 0.02 TestRzError(-179.99, 179.99, -.02); // Expect -0.02 TestRzError(180, 89.995, -90.005); // Expect -90.005 TestRzError(-5, -4, 1); // Expect 1 TestRzError(-4, -5, -1); // Expect -1 // Don't try this at home! TestRzError(180, -1800, -180); // Expect -180 TestRzError(-1800, 180, 180); // Expect 180 } } }
run
|
edit
|
history
|
help
0
code
codetility CyclicRotation
6. Parallelism: threads
out parameters
First Non repeat char
look at this, soaches
Gerador de Matriz Data
Unsorted Parallel Arrays finding min & max values.
Jai
IntToExcelColumnNotation