static void Main(string[] args) { TVector2D q = new TVector2D(); q.X = 14; Console.WriteLine(q.X); q.setVect(1, 25, 1, 6, 3); Console.WriteLine(q.getLenght()); }
public void Test1() {//testing 2d vec Random r = new Random(); for (int i = 0; i < 20; i++) { double s = r.Next(-1000, 1000); double g = r.Next(-1000, 1000); TVector2D vec2d = new TVector2D(s, g); double s2 = r.Next(-1000, 1000); double g2 = r.Next(-1000, 1000); TVector2D vec2d2 = new TVector2D(s2, g2); TVector2D vec = new TVector2D(vec2d + vec2d2); Assert.AreEqual(s + s2, vec.x); } for (int i = 0; i < 20; i++) { double s = r.Next(-1000, 1000); double g = r.Next(-1000, 1000); TVector2D vec2d = new TVector2D(s, g); double s2 = r.Next(-1000, 1000); double g2 = r.Next(-1000, 1000); TVector2D vec2d2 = new TVector2D(s2, g2); TVector2D vec = new TVector2D(vec2d + vec2d2); Assert.AreEqual(g + g2, vec.y); Assert.AreEqual(s + s2, vec.x); } for (int i = 0; i < 20; i++) { double s = r.Next(-1000, 1000); double g = r.Next(-1000, 1000); TVector2D vec2d = new TVector2D(s, g); double s2 = r.Next(-1000, 1000); double g2 = r.Next(-1000, 1000); TVector2D vec2d2 = new TVector2D(s2, g2); Assert.AreEqual(vec2d * vec2d2, (s * s2) + (g * g2)); } for (int i = 0; i < 20; i++) { double s = r.Next(-1000, 1000); double g = r.Next(-1000, 1000); double z = r.Next(-1000, 1000); TVector3D vec2d = new TVector3D(s, g, z); double s2 = r.Next(-1000, 1000); double g2 = r.Next(-1000, 1000); double z2 = r.Next(-1000, 1000); TVector3D vec2d2 = new TVector3D(s2, g2, z2); TVector3D vec = new TVector3D(vec2d - vec2d2); Assert.AreEqual(vec.x, s - s2); Assert.AreEqual(vec.y, g - g2); Assert.AreEqual(vec.z, z - z2); } }