public void ProjectToException1() { VectorD v = new VectorD(1); v.ProjectTo(null); }
public void ProjectTo2() { VectorD unitX = new VectorD(new double[] { 1, 0, 0, 0 }); VectorD unitY = new VectorD(new double[] { 0, 1, 0, 0 }); VectorD unitZ = new VectorD(new double[] { 0, 0, 1, 0 }); VectorD one = new VectorD(new double[] { 1, 1, 1, 1 }); // Project (1, 1, 1) to axes VectorD projection = new VectorD(new double[] { 1, 1, 1, 0 }); projection.ProjectTo(unitX); Assert.AreEqual(unitX, projection); projection.Set(one); projection.ProjectTo(unitY); Assert.AreEqual(unitY, projection); projection.Set(one); projection.ProjectTo(unitZ); Assert.AreEqual(unitZ, projection); // Project axes to (1, 1, 1) VectorD expected = new VectorD(new double[] { 1, 1, 1, 0 }) / 3.0; projection.Set(unitX); projection.ProjectTo(new VectorD(new double[] { 1, 1, 1, 0 })); Assert.AreEqual(expected, projection); projection.Set(unitY); projection.ProjectTo(new VectorD(new double[] { 1, 1, 1, 0 })); Assert.AreEqual(expected, projection); projection.Set(unitZ); projection.ProjectTo(new VectorD(new double[] { 1, 1, 1, 0 })); Assert.AreEqual(expected, projection); }