public void TestMethod1() { var octave = 1; var persistance = .5f; var amplitude = 20; var mockRand = new Mock <IRandom2>(); mockRand.Setup(r => r.NextD(It.IsAny <int>(), It.IsAny <int>())) .Returns(1f); var sg = new SegmentDivider(mockRand.Object, amplitude, persistance); var inputLine = new LineSegment(new Vector2(1, 1), new Vector2(65, 65)); var exPoint = new Vector2(40, 25); var expected1 = new LineSegment(new Vector2(1, 1), exPoint); var expected2 = new LineSegment(exPoint, new Vector2(65, 65)); // act var actualLines = sg.Subdivide(inputLine.Point1, inputLine.Point2); for (int i = 0; i < actualLines.Count; i++) { var al = actualLines[i]; var p1 = new Vector2((int)al.Point1.X, (int)al.Point1.Y); var p2 = new Vector2((int)al.Point2.X, (int)al.Point2.Y); actualLines[i] = new LineSegment(p1, p2); } // assert Assert.AreEqual(actualLines[0], expected1); Assert.AreEqual(actualLines[1], expected2); }
public async Task SaveLayers() { var countOfCells = 4; var amplitude = 50; var rnd2 = new RandomSeeded(seed); SegmentDivider divider = new SegmentDivider(rnd2, amplitude, 1); doVor(countOfCells, divider); //var profile = printMountainProfile(countOfCells, divider); //vl.Log(profile, "profile"); }
public override ISubGenerator Build(int seed) { var np = _noiseBuilder.Random(new Rand(seed)).Build(); var lp = _layerBuilder.Build(); // TODO change rand approach var rnd2 = new RandomSeeded(seed); var sd = new SegmentDivider(rnd2, 30, 1); var c = new VoronoiConverter(sd); var g = new VoronoiGenerator(c); var gg = new VoronoiAreaGenerator(g, new Rand(seed)); // todo Use parameters return(new MountainGenerator(new VisualLogger(), gg, np, lp) { Influence = _influence }); }
private static void doVor(int countOfCells, SegmentDivider divider) { printVoronoi(countOfCells, divider); }