public void TestMap_NotNormalized() { Graph.SinMap1DNode map1DNode = new Graph.SinMap1DNode(false, 0); SomeMap <float, float> map = map1DNode.ValueForOutput <SomeMap <float, float> >("value", null, null) as SomeMap <float, float>; Assert.NotNull(map); Assert.AreEqual(Mathf.Sin(0), map.ValueFor(0), .001f); Assert.AreEqual(Mathf.Sin(0.3f * 2.0f * Mathf.PI), map.ValueFor(0.3f), .001f); }
public void TestMap_YAxis() { Graph.SinMap1DNode map1DNode = new Graph.SinMap1DNode(false, 0); Graph.Map1DToMap2DNode transformNode = new Graph.Map1DToMap2DNode(Axis2D.Y); map1DNode.AddOutput("value", transformNode, "value"); SomeMap <Vector2, float> map = transformNode.ValueForOutput <SomeMap <Vector2, float> >("value", null, null) as SomeMap <Vector2, float>; Assert.NotNull(map); Assert.AreEqual(Mathf.Sin(0), map.ValueFor(new Vector2(0.5f, 0))); Assert.AreEqual(Mathf.Sin(0.3f * 2.0f * Mathf.PI), map.ValueFor(new Vector2(0.5f, 0.3f)), .001f); }
public void TestMap_Normalized() { Graph.SinMap1DNode map1DNode = new Graph.SinMap1DNode(true, 0); SomeMap <float, float> map = map1DNode.ValueForOutput <SomeMap <float, float> >("value", null, null) as SomeMap <float, float>; Assert.NotNull(map); Assert.AreEqual(0.5f, map.ValueFor(0), .001f); Assert.AreEqual(1.0f, map.ValueFor(0.25f), .001f); Assert.AreEqual(0, map.ValueFor(0.75f), .001f); Assert.AreEqual(0.5f, map.ValueFor(1.0f), .001f); }
public void TestMap() { Graph.SinMap1DNode map1DNode = new Graph.SinMap1DNode(false, 0); Graph.Map1DToMap2DNode transformNode = new Graph.Map1DToMap2DNode(Axis2D.X); map1DNode.AddOutput("value", transformNode, "value"); var factor = 3.0f; var multiplyNode = new Graph.MultiplyMap2DNode(factor); transformNode.AddOutput("value", multiplyNode, "value"); SomeMap <Vector2, float> map = multiplyNode.ValueForOutput <SomeMap <Vector2, float> >("value", null, null) as SomeMap <Vector2, float>; Assert.NotNull(map); Assert.AreEqual(Mathf.Sin(0) * factor, map.ValueFor(new Vector2(0, 0.5f))); Assert.AreEqual(Mathf.Sin(0.3f * 2.0f * Mathf.PI) * factor, map.ValueFor(new Vector2(0.3f, 0.5f)), .001f); }
public void TestMap() { Graph.CircleMap2DNode mapNode = new Graph.CircleMap2DNode(Vector2.zero, 1.0f, 1.0f, 0); SomeMap <Vector2, float> map = mapNode.ValueForOutput <SomeMap <Vector2, float> >("value", null, null) as SomeMap <Vector2, float>; Assert.NotNull(map); Assert.AreEqual(1.0f, map[Vector2.zero]); Assert.AreEqual(1.0f, map[new Vector2(1.0f, 0)]); Assert.AreEqual(1.0f, map[new Vector2(-1.0f, 0)]); Assert.AreEqual(1.0f, map[new Vector2(0, 1.0f)]); Assert.AreEqual(1.0f, map[new Vector2(0, -1.0f)]); Assert.AreEqual(0, map[new Vector2(1.01f, 0)]); Assert.AreEqual(0, map[new Vector2(-1.01f, 0)]); Assert.AreEqual(0, map[new Vector2(0, 1.01f)]); Assert.AreEqual(0, map[new Vector2(0, -1.01f)]); }