Esempio n. 1
0
 /// <summary>
 /// Скалярное произведение векторов
 /// </summary>
 /// <param name="a">вектора А</param>
 /// <param name="b">вектор Б</param>
 /// <returns>range [-1,1]</returns>
 public static float Dot(Vector2F a, Vector2F b)
 {
     var aN = a.Normalized;
     var bN = b.Normalized;
     return aN.X*bN.X + aN.Y*bN.Y;
 }
Esempio n. 2
0
 public void TestSumVectors()
 {
     var vectorB = new Vector2F(2, 16);
     var vectorExpected = new Vector2F(7, 22);
     var vectorActual = _vectorA + vectorB;
     Assert.AreEqual(vectorExpected.X, vectorActual.X);
     Assert.AreEqual(vectorExpected.Y, vectorActual.Y);
 }
Esempio n. 3
0
 void FillVectors(out Vector2F a, out Vector2F b)
 {
     a = new Vector2F((float) AxText.Value, (float) AyText.Value);
     b = new Vector2F((float) BxText.Value, (float) ByText.Value);
 }
Esempio n. 4
0
 public void TestScalar(Vector2F a,  float expected)
 {
     var actual = a.Magnitude;
     Assert.AreEqual(expected, actual);
 }
Esempio n. 5
0
 public void TestScalar(Vector2F a, Vector2F b, float expected)
 {
     var actual = Vector2F.Dot(a,b);
     Assert.AreEqual(Math.Round(expected,4), Math.Round(actual,4));
 }
Esempio n. 6
0
 public void TestMinusWithParams(Vector2F a, Vector2F b, Vector2F expected)
 {
     var actual = a - b;
     Assert.AreEqual(expected,actual);
 }
Esempio n. 7
0
 public void TestEquals()
 {
     var vectorA = new Vector2F(2,2);
     var vectorB = new Vector2F(2, 2);
     Assert.AreEqual(vectorA,vectorB);
 }
Esempio n. 8
0
 public void SetupTests()
 {
     _vectorA = new Vector2F(5, 6);
 }