Пример #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));
        }