public void CanSubtractTwoVectors() { var v1 = Tuple.NewVector(3, 2, 1); var v2 = Tuple.NewVector(5, 6, 7); Assert.Equal(Tuple.NewVector(-2, -4, -6), v1 - v2); }
public void CanSubtractTwoPoints() { var p1 = Tuple.NewPoint(3, 2, 1); var p2 = Tuple.NewPoint(5, 6, 7); Assert.Equal(Tuple.NewVector(-2, -4, -6), p1 - p2); }
public void CanSubtractAVectorFromAPoint() { var p = Tuple.NewPoint(3, 2, 1); var v = Tuple.NewVector(5, 6, 7); Assert.Equal(Tuple.NewPoint(-2, -4, -6), p - v); }
public void CanSubtractAVectorFromTheZeroVector() { var zero = Tuple.NewVector(0, 0, 0); var v = Tuple.NewVector(1, -2, 3); Assert.Equal(Tuple.NewVector(-1, 2, -3), zero - v); }
public void CanCalculateTheDotProductOfTwoVectors() { var a = Tuple.NewVector(1, 2, 3); var b = Tuple.NewVector(2, 3, 4); Assert.True(FloatMath.AreEqual(20, a.Dot(b))); }
public void CanCalculateTheCrossProductOfTwoVectors() { var a = Tuple.NewVector(1, 2, 3); var b = Tuple.NewVector(2, 3, 4); Assert.Equal(Tuple.NewVector(-1, 2, -1), a.Cross(b)); Assert.Equal(Tuple.NewVector(1, -2, 1), b.Cross(a)); }
private static void Main(string[] args) { Console.WriteLine("Projectile Demo"); var p = new Projectile(Tuple.NewPoint(0, 1, 0), Tuple.NewVector(1, 1, 0).Normalized); var w = new World(Tuple.NewVector(0, -0.1, 0), Tuple.NewVector(-0.01, 0, 0)); var numTicks = 0; Console.WriteLine($"Y: {p.Position.Y}, Ticks: {numTicks}"); while (p.Position.Y > 0) { p = Tick(w, p); numTicks++; Console.WriteLine($"Y: {p.Position.Y}, Ticks: {numTicks}"); } Console.WriteLine($"It took {numTicks} ticks to hit the ground."); Console.Read(); }
public void TupleFactoryCanCreateAVector() { var p = Tuple.NewVector(4, -4, 3); Assert.Equal(new Tuple4(4, -4, 3, 0), p); }
public void MagnitudeOfANormalizedVectorEqualsOne() { var v = Tuple.NewVector(1, 2, 3); Assert.True(FloatMath.AreEqual(1, v.Normalized.Magnitude)); }
public void CanNormalizeAVector(double v1, double v2, double v3, double r1, double r2, double r3) { var v = Tuple.NewVector(v1, v2, v3); Assert.Equal(Tuple.NewVector(r1, r2, r3), v.Normalized); }
public void VectorsHaveAFloatingPointMagnitude(double a, double b, double c) { var v = Tuple.NewVector(a, b, c); Assert.True(FloatMath.AreEqual(v.Magnitude, Math.Sqrt(14))); }
public void VectorsHaveAMagnitude(double a, double b, double c, double expected) { var v = Tuple.NewVector(a, b, c); Assert.True(FloatMath.AreEqual(v.Magnitude, expected)); }
public Tuple4 Cross(Tuple4 other) { return(Tuple.NewVector(Y * other.Z - Z * other.Y, Z * other.X - X * other.Z, X * other.Y - Y * other.X)); }