示例#1
0
        public static NI2dPoint divergingOvalptpt(NI2dPoint F, double n1, NI2dVector v, NI2dPoint G, double n2, double S)
        {
            NI2dPoint ovalpt = new NI2dPoint(0, 0);

            v.Normalize();
            NI2dVector v1    = new NI2dVector(F, G);
            double     C1    = n1 * S + (n2 * n2) * v1.DotProduct(v);
            double     C2    = S * S - (n2 * n2) * v1.DotProduct(v1);
            double     gamma = -1.0;
            double     sigma = 0.0;

            if (n1 > n2)
            {
                sigma = -1 * gamma;
            }
            else if (n1 < n2)
            {
                sigma = 1 * gamma;
            }

            double c1numerator   = C1 + sigma * Math.Sqrt(C2 * (n2 * n2 - n1 * n1) + C1 * C1);
            double c1denominator = n1 * n1 - n2 * n2;
            double c1            = c1numerator / c1denominator;

            ovalpt = F + c1 * v.ConverttoPoint();

            return(ovalpt);
        }
示例#2
0
        public static NI2dVector refractedRay(NI2dVector i, NI2dVector ns, double n1, double n2)
        {
            NI2dVector r = new NI2dVector(0, 0);
            NI2dVector n = new NI2dVector(0, 0);

            i.Normalize();
            ns.Normalize();

            double ncheck = i.DotProduct(ns);

            if (ncheck >= 0.0)
            {
                n = ns;
            }
            if (ncheck < 0.0)
            {
                n = -1 * ns;
            }

            double delta = 1 - ((n1 / n2) * (n1 / n2) * (1 - (i.DotProduct(n) * i.DotProduct(n))));

            if (delta > 0)
            {
                r = (n1 / n2) * i + ((-1 * (i.DotProduct(n)) * (n1 / n2) + Math.Sqrt(delta)) * n);
            }
            if (delta <= 0)
            {
                r = reflectedRay(i, ns);
            }

            return(r);
        }
示例#3
0
        public static NI2dPoint reflectingOvalptpt(NI2dPoint F, NI2dVector v, NI2dPoint G, double n, double S)
        {
            NI2dPoint ovalpt = new NI2dPoint(0, 0);

            v.Normalize();
            NI2dVector v1            = new NI2dVector(F, G);
            double     c1numerator   = (S / n) * (S / n) - v1.DotProduct(v1);
            double     c1denominator = 2 * ((S / n) + v1.DotProduct(v));
            double     c1            = c1numerator / c1denominator;

            ovalpt = F + c1 * v.ConverttoPoint();

            return(ovalpt);
        }
示例#4
0
        public static NI2dVector reflectedRay(NI2dVector i, NI2dVector n)
        {
            NI2dVector r = new NI2dVector(0, 0);

            i.Normalize();
            n.Normalize();
            r = i - 2 * (i.DotProduct(n)) * n;

            return(r);
        }
示例#5
0
        public static NI2dPoint line2DIntersection(NI2dPoint P, NI2dVector v, NI2dPoint Q, NI2dVector u)
        {
            NIRotMatrix rotation = new NIRotMatrix(Math.PI / 2);

            u.RotateVector(Math.PI / 2);
            NI2dVector up  = u;
            NI2dVector qp  = new NI2dVector(Q - P);
            NI2dPoint  isl = P + (((qp.DotProduct(up)) / v.DotProduct(up)) * v).ConverttoPoint();

            return(isl);
        }
示例#6
0
        public static NI2dPoint planewaveOvalpt(NI2dPoint F, double n1, NI2dVector v, NI2dPoint Q, double n2, NI2dVector n, double S)
        {
            NI2dPoint  ovalpt        = new NI2dPoint(0, 0);
            NI2dVector v1            = new NI2dVector(Q, F);
            double     c1numerator   = S - n2 * (v1.DotProduct(n));
            double     c1denominator = n1 - n2 * (v.DotProduct(n));
            double     c1            = c1numerator / c1denominator;

            ovalpt = F + c1 * v.ConverttoPoint();

            return(ovalpt);
        }
示例#7
0
 public static double AngleBetween(NI2dVector v1, NI2dVector v2)
 {
     return(Math.Acos(NI2dVector.DotProduct(v1, v2) / (v1.Magnitude * v2.Magnitude)));
 }