public void Raytrace() { Parallel.For(0, Rays.Length, (i) => { while (Rays[i].Radius > 1 && Rays[i].Radius < TextureMap.Radius) { var radius = Rays[i].Position.Length(); var h2 = Vector3.Cross(Rays[i].Position, Rays[i].Velocity).LengthSquared(); var accel = (float)(-1.5 * h2 / (radius * radius * radius * radius * radius)) * Rays[i].Position; Rays[i].Position += Rays[i].Velocity * Step; Rays[i].Velocity += accel * Step; } if (Abs(Rays[i].Radius - TextureMap.Radius) <= 10 * Step) { Rays[i].Color = TextureMap.ColorAt(Rays[i].Position); } }); }