Ejemplo n.º 1
0
        public static List <NI2dPoint> unwindingmacroParabola(double alpha, NI2dPoint F, double r, NI2dPoint P, double phi_start, double phi_end, double phi_step)
        {
            List <NI2dPoint> parabolaPts = new List <NI2dPoint>();
            NI2dVector       v1          = new NI2dVector(P, F);
            NI2dVector       v2          = new NI2dVector(Math.Cos(alpha), Math.Sin(alpha));
            double           phiP        = v1.AngleBetween(v2) - Math.Asin(r / NI2dPoint.DistanceBetweenPoints(P, F));

            if (phiP < 0.0)
            {
                phiP = 2 * Math.PI + phiP;
            }

            double t1 = Math.Sqrt((NI2dPoint.DistanceBetweenPoints(P, F) * NI2dPoint.DistanceBetweenPoints(P, F)) - (r * r));
            double t2 = (1 - Math.Cos(phiP));
            double t3 = (1 - phiP + Math.Sin(phiP));
            double K  = (t1 * t2) + (r * t3);

            for (double phi = phi_start; phi < phi_end + phi_step; phi += phi_step)
            {
                NI2dPoint pt1        = new NI2dPoint(-1 * Math.Sin(phi + alpha), Math.Cos(phi + alpha));
                NI2dPoint pt2        = new NI2dPoint(Math.Cos(phi + alpha), Math.Sin(phi + alpha));
                double    c1         = (K + r * (phi - 1 - Math.Sin(phi))) / (1 - Math.Cos(phi));
                NI2dPoint parabpoint = (r * pt1) + (c1 * pt2) + F;
                parabolaPts.Add(parabpoint);
            }

            return(parabolaPts);
        }
Ejemplo n.º 2
0
        public static List <NI2dPoint> unwindingmacroEllipse(NI2dPoint F, double r, NI2dPoint G, NI2dPoint P, double phi_start, double phi_end, double phi_step)
        {
            List <NI2dPoint> ellipsepts = new List <NI2dPoint>();
            double           distanceFP = NI2dPoint.DistanceBetweenPoints(F, P);
            double           f          = NI2dPoint.DistanceBetweenPoints(F, G);
            double           alpha      = new NI2dVector(G, F).AngleH();
            NI2dVector       v1         = new NI2dVector(Math.Cos(alpha), Math.Sin(alpha));
            NI2dVector       v2         = new NI2dVector(P, F);
            double           phiP       = v2.AngleBetween(v1) - Math.Asin(r / distanceFP);

            if (phiP < 0)
            {
                phiP = phiP + 2 * Math.PI;
            }

            double tp = Math.Sqrt((distanceFP * distanceFP) - (r * r));
            double K  = tp - (r * phiP) + Math.Sqrt((f * f) + (r * r) + (tp * tp) - (2 * f * ((tp * Math.Cos(phiP)) - (r * Math.Sin(phiP)))));



            for (double phi = phi_start; phi < phi_end + phi_step; phi += phi_step)
            {
                NI2dPoint pt1           = new NI2dPoint(-1 * Math.Sin(phi + alpha), Math.Cos(phi + alpha));
                NI2dPoint pt2           = new NI2dPoint(Math.Cos(phi + alpha), Math.Sin(phi + alpha));
                double    c1numerator   = ((K + r * phi) * (K + r * phi)) - 2 * f * r * Math.Sin(phi) - (f * f) - (r * r);
                double    c1denominator = 2 * (K + (r * phi) - (f * Math.Cos(phi)));
                double    c1            = c1numerator / c1denominator;
                NI2dPoint ellipsePoint  = (r * pt1) + (c1 * pt2) + F;
                ellipsepts.Add(ellipsePoint);
            }

            return(ellipsepts);
        }
Ejemplo n.º 3
0
        public static double PlaneAngleBetween(NI2dVector v1, NI2dVector v2)
        {
            if (((v2.x1 * v1.x2) - (v2.x2 * v1.x1)) >= 0)
            {
                return(NI2dVector.AngleBetween(v1, v2));
            }

            else
            {
                return((2 * Math.PI) - NI2dVector.AngleBetween(v1, v2));
            }
        }
Ejemplo n.º 4
0
        public static List <NI2dPoint> cartesianOvalParallel(NI2dPoint F, double n1, double n2, NI2dPoint P, double alpha, double phi_start, double phi_end, double phi_step)
        {
            List <NI2dPoint> ovalpts    = new List <NI2dPoint>();
            double           distanceFP = NI2dPoint.DistanceBetweenPoints(F, P);
            NI2dVector       v1         = new NI2dVector(P, F);
            NI2dVector       v2         = new NI2dVector(Math.Cos(alpha), Math.Sin(alpha));
            double           phiP       = v1.AngleBetween(v2);

            for (double phi = phi_start; phi < phi_end + phi_step; phi += phi_step)
            {
                NI2dPoint pt1       = new NI2dPoint(Math.Cos(phi + alpha), Math.Sin(phi + alpha));
                double    c1        = (distanceFP * (n1 - (n2 * Math.Cos(phiP)))) / (n1 - (n2 * Math.Cos(phi)));
                NI2dPoint ovalPoint = (c1 * pt1) + F;
                ovalpts.Add(ovalPoint);
            }

            return(ovalpts);
        }
Ejemplo n.º 5
0
        public static List <NI2dPoint> cartesianOvalDiverge(NI2dPoint F, double n1, NI2dPoint G, double n2, NI2dPoint P, double phi_start, double phi_end, double phi_step)
        {
            List <NI2dPoint> ovalpts    = new List <NI2dPoint>();
            double           distanceFP = NI2dPoint.DistanceBetweenPoints(F, P);
            double           distancePG = NI2dPoint.DistanceBetweenPoints(P, G);
            double           K          = (n1 * distanceFP) - (n2 * distancePG);
            double           f          = NI2dPoint.DistanceBetweenPoints(F, G);
            double           phiC       = 0;


            if (Math.Abs(K) <= n1 * f)
            {
                phiC = Math.Acos(K / (f * n1));
            }
            else if (Math.Abs(K) > n1 * f)
            {
                phiC = 0;
            }

            NI2dVector v1 = new NI2dVector(P, F);
            NI2dVector v2 = new NI2dVector(G, F);

            if (K > -1 * n2 * f && v1.AngleBetween(v2) >= phiC)
            {
                for (double phi = phi_start; phi < phi_end + phi_step; phi += phi_step)
                {
                    double    D             = (f * n1 - K * Math.Cos(phi)) * (f * n1 - K * Math.Cos(phi)) + (K * K - f * f * n2 * n2) * Math.Sin(phi) * Math.Sin(phi);
                    double    alpha         = new NI2dVector(G, F).AngleH();
                    double    c1numerator   = K * n1 - f * n2 * n2 * Math.Cos(phi) + n2 * Math.Sqrt(D);
                    double    c1denominator = n1 * n1 - n2 * n2;
                    double    c1            = c1numerator / c1denominator;
                    NI2dPoint pt1           = new NI2dPoint(Math.Cos(phi + alpha), Math.Sin(phi + alpha));
                    NI2dPoint ovalPoint     = (c1 * pt1) + F;
                    ovalpts.Add(ovalPoint);
                }
            }

            return(ovalpts);
        }