public void Equals_ReturnsTrueForSameRay() { const float x = 5, y = 6, z = 7, dx = 4, dy = 3, dz = 2; var ray1 = new Ray(x, y, z, dx, dy, dz); var ray2 = new Ray(x, y, z, dx, dy, dz); Assert.IsTrue(ray1.Equals(ray2)); }
public void Constructor3D_CreatesValidRay() { const float x = 5, y = 6, z = 7, dx = 4, dy = 3, dz = 2; var ray = new Ray(x, y, z, dx, dy, dz); var dlen = (float)Math.Sqrt(dx * dx + dy * dy + dz * dz); Assert.IsTrue(ray.Start.X == x && ray.Start.Y == y && ray.Start.Z == z && ray.Direction.X == dx / dlen && ray.Direction.Y == dy / dlen && ray.Direction.Z == dz / dlen); }
public void Equals_ReturnsFalseForDifferentRay() { const float x = 5, y = 6, z = 7, dx = 4, dy = 3, dz = 2; var ray1 = new Ray(x, y, z, dx, dy, dz); var ray2 = new Ray(z, y, x, dx, dy, dz); Assert.IsFalse(ray1.Equals(ray2)); }
public void Constructor2D_CreatesValidRay() { const float x = 5, y = 6, dx = 4, dy = 3; var ray = new Ray(x, y, dx, dy); var dlen = (float)Math.Sqrt(dx * dx + dy * dy); Assert.IsTrue(ray.Start.X == x && ray.Start.Y == y && ray.Start.Z == 0 && ray.Direction.X == dx / dlen && ray.Direction.Y == dy / dlen && ray.Direction.Z == 0); }
public static void DrawRay(this Graphics g, Pen pen, Ray line) { g.DrawLine(pen, line.Start.X, line.Start.Y, line.Direction.X * g.ClipBounds.Width * 2, line.Direction.Y * g.ClipBounds.Height * 2); }