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)); }
private Ray ReflectRay(Ray sourceRay, PosVector normal) { return(new Ray( sourceRay.Position, sourceRay.Direction + normal * 2.0 * -normal.Dot(sourceRay.Direction))); }
public static double CosVectors(PosVector v1, PosVector v2) { return(v1.Dot(v2) / Math.Sqrt(v1.MagnitudeSquared() * v2.MagnitudeSquared())); }
private Ray GetReflectionRay(PosVector p, PosVector n, PosVector v) { var rl = v + n * 2.0 * -n.Dot(v); return(new Ray(p, rl)); }