public IDefinitionNodeNetwork GenerateGrid2D() { const int width = 1000; const int height = 1000; var random = new Random(); var dictionary = new Dictionary <DelaunayNode, int>(); var nodeNetwork = new DefinitionNodeNetwork(new Vector2(1, 1)); for (var i = 0; i < 100; i++) { var nodeIndex = nodeNetwork.AddNode(new Vector2(random.Next(0, width), random.Next(0, height))); ref var node = ref nodeNetwork.NodeArray[nodeIndex]; var defaultNode = new DelaunayNode(new Vector2(node.Position.X, node.Position.Y)); dictionary.Add(defaultNode, nodeIndex); }
public void GetNode() { var nodeNetwork = new DefinitionNodeNetwork(new Vector2(1, 1)); var positions = new List <Vector2> { new Vector2(0, 0), new Vector2(1, 2), new Vector2(8, 13) }; foreach (var position in positions) { nodeNetwork.AddNode(position); } foreach (var position in positions) { var node = nodeNetwork.GetNode(position.X, position.Y); Assert.Equal(position, node.Position); } }