예제 #1
0
        private Ray GetRefractionRay(PosVector p, PosVector n, PosVector v, double refraction)
        {
            var c1 = n.Dot(v);
            var c2 = 1.0 - refraction * refraction * Math.Sqrt(1.0 - c1 * c1);
            var t  = (n * (refraction * c1 - c2) - v * refraction * -1.0).Normalize();

            return(new Ray(p, t));
        }
예제 #2
0
 private Ray ReflectRay(Ray sourceRay, PosVector normal)
 {
     return(new Ray(
                sourceRay.Position,
                sourceRay.Direction + normal * 2.0 * -normal.Dot(sourceRay.Direction)));
 }
예제 #3
0
 public static double CosVectors(PosVector v1, PosVector v2)
 {
     return(v1.Dot(v2) / Math.Sqrt(v1.MagnitudeSquared() * v2.MagnitudeSquared()));
 }
예제 #4
0
        private Ray GetReflectionRay(PosVector p, PosVector n, PosVector v)
        {
            var rl = v + n * 2.0 * -n.Dot(v);

            return(new Ray(p, rl));
        }