public static void ExempleSpiral() { UlamSpiral spiral = new UlamSpiral(189); System.Diagnostics.Stopwatch watch; // watch = System.Diagnostics.Stopwatch.StartNew(); for (int i = 0; i <= spiral.MaxCycle; i++) { spiral.Cycle(i); } watch.Stop(); Console.WriteLine("{0} ticks pour les cycles", watch.ElapsedTicks); /**/ watch = System.Diagnostics.Stopwatch.StartNew(); int distance = spiral.Resolve(); watch.Stop(); Console.WriteLine("{0} ticks pour la résolution", watch.ElapsedTicks); Console.WriteLine("{0} est à une distance de {1} du centre.", spiral.TargetValue, distance); Console.WriteLine(spiral); }
public void TestUlamSpiralGetStartLocationOK() { UlamSpiral spiral = null; int[] location = null; spiral = new UlamSpiral(81); int[] centerLocation = spiral.GetCenterLocation(); location = spiral.GetStartLocation(0); Assert.AreEqual(location[0], centerLocation[0]); // x Assert.AreEqual(location[1], centerLocation[1]); // y location = spiral.GetStartLocation(1); Assert.AreEqual(location[0], centerLocation[0] + 1); // x Assert.AreEqual(location[1], centerLocation[1]); // y location = spiral.GetStartLocation(2); Assert.AreEqual(location[0], centerLocation[0] + 2); // x Assert.AreEqual(location[1], centerLocation[0] + 1); // y }
private void FrmLibrary_Load(object sender, EventArgs e) { int num = 2381; UlamSpiral abc = new UlamSpiral(num); this.Text = Convert.ToString($"NUM= {num} X= {abc.X} Y= {abc.Y}"); }
public void TestUlamSpiralCycleOK() { UlamSpiral spiral = null; int[] loc = null; int cycleNumber = 0; spiral = new UlamSpiral(25); cycleNumber = 1; spiral.Cycle(cycleNumber); loc = spiral.GetStartLocation(cycleNumber); Assert.AreEqual(2, spiral.Matrix[loc[1], loc[0]]); spiral = new UlamSpiral(25); cycleNumber = 2; spiral.Cycle(cycleNumber); loc = spiral.GetStartLocation(cycleNumber); Assert.AreEqual(10, spiral.Matrix[loc[1], loc[0]]); spiral = new UlamSpiral(49); cycleNumber = 3; spiral.Cycle(cycleNumber); loc = spiral.GetStartLocation(cycleNumber); Assert.AreEqual(26, spiral.Matrix[loc[1], loc[0]]); }
public void TestUlamSpiralGetMaxValueOK() { UlamSpiral spiral = new UlamSpiral(0); Assert.AreEqual(1, spiral.GetMaxValue(0)); Assert.AreEqual(9, spiral.GetMaxValue(1)); Assert.AreEqual(25, spiral.GetMaxValue(2)); Assert.AreEqual(49, spiral.GetMaxValue(3)); }
public void TestUlamSpiralGetSpiralSizeOK() { UlamSpiral spiral = new UlamSpiral(0); Assert.AreEqual(1, spiral.GetSpiralSize(0)); Assert.AreEqual(3, spiral.GetSpiralSize(1)); Assert.AreEqual(5, spiral.GetSpiralSize(2)); Assert.AreEqual(7, spiral.GetSpiralSize(3)); }
public void TestUlamSpiralGetCycleNumberFromValueOK() { UlamSpiral spiral = new UlamSpiral(0); Assert.AreEqual(0, spiral.GetCycleNumberFromValue(0)); Assert.AreEqual(0, spiral.GetCycleNumberFromValue(1)); Assert.AreEqual(1, spiral.GetCycleNumberFromValue(2)); Assert.AreEqual(1, spiral.GetCycleNumberFromValue(3)); Assert.AreEqual(1, spiral.GetCycleNumberFromValue(9)); Assert.AreEqual(2, spiral.GetCycleNumberFromValue(10)); }
public void TestUlamSpiralGetCenterLocation() { UlamSpiral spiral = null; int[] location = null; spiral = new UlamSpiral(9); location = spiral.GetCenterLocation(); Assert.AreEqual(location[0], 1); // x Assert.AreEqual(location[1], 1); // y }
protected override void Load(ContainerBuilder builder) { var ulamSpiral = new UlamSpiral(new Point(250, 250)); var archimedeanSpiral = new ArchimedeanSpiral(new Point(250, 250), 0.2, 1.0); var formConfig = new FormConfig(Color.Tan, new Size(600, 600), SpiralType.Archimedean); builder.RegisterInstance(formConfig); builder.RegisterInstance(ulamSpiral).As <ISpiral>(); builder.RegisterInstance(archimedeanSpiral).As <ISpiral>().PreserveExistingDefaults(); builder.RegisterType <LayouterFactory>().As <ILayouterFactory>(); builder.RegisterType <WordValidator>().As <IWordValidator>(); builder.RegisterType <BitmapSaver>().As <IBitmapSaver>(); builder.RegisterType <TextParser>().As <ITextParser>(); builder.RegisterType <CloudLayouter>().As <ILayouter>(); builder.RegisterType <TagsVisualizer>(); builder.RegisterType <TagsCloudContainer.TagsCloudContainer.TagsCloudContainer>().As <ITagsContainer>(); builder.RegisterType <TagsCloudForm>(); }
public void SetUp() { Center = new Point(500, 500); Spiral = new UlamSpiral(Center); }