/// <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; }
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); }
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); }
public void TestScalar(Vector2F a, float expected) { var actual = a.Magnitude; Assert.AreEqual(expected, actual); }
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)); }
public void TestMinusWithParams(Vector2F a, Vector2F b, Vector2F expected) { var actual = a - b; Assert.AreEqual(expected,actual); }
public void TestEquals() { var vectorA = new Vector2F(2,2); var vectorB = new Vector2F(2, 2); Assert.AreEqual(vectorA,vectorB); }
public void SetupTests() { _vectorA = new Vector2F(5, 6); }