Esempio n. 1
0
        public static Double VectorMagnitude(CartVect vector)
        {
            double magnitude = 0.0;

            magnitude = Math.Sqrt(Math.Pow((vector.X), 2) + Math.Pow((vector.Y), 2) + Math.Pow((vector.Z), 2));
            return(magnitude);
        }
Esempio n. 2
0
 public static Double VectorMagnitude(CartVect vector)
 {
     double magnitude= 0.0;
     
     magnitude = Math.Sqrt(Math.Pow((vector.X),2) + Math.Pow((vector.Y),2) + Math.Pow((vector.Z),2));
     return magnitude;
 }
Esempio n. 3
0
 public static CartVect CreateVector(CartCoord cd1, CartCoord cd2)
 {
     CartVect vector = new CartVect();
     vector.X = cd2.X - cd1.X;
     vector.Y = cd2.Y - cd1.Y;
     vector.Z = cd2.Z - cd1.Z;
     return vector;
 }
Esempio n. 4
0
        public static CartVect CrossProduct(CartVect vector1, CartVect vector2)
        {
            CartVect xProd = new CartVect();

            xProd.X = vector2.Z * vector1.Y - vector1.Z * vector2.Y;
            xProd.Y = vector2.Z * vector1.X - vector1.Z * vector2.X;
            xProd.Z = vector2.Y * vector1.X - vector1.Y * vector2.X;
            return xProd;
        }
Esempio n. 5
0
        public static CartVect CrossProduct(CartVect vector1, CartVect vector2)
        {
            CartVect xProd = new CartVect();

            xProd.X = vector2.Z * vector1.Y - vector1.Z * vector2.Y;
            xProd.Y = vector2.Z * vector1.X - vector1.Z * vector2.X;
            xProd.Z = vector2.Y * vector1.X - vector1.Y * vector2.X;
            return(xProd);
        }
Esempio n. 6
0
        public static CartVect CreateVector(CartCoord cd1, CartCoord cd2)
        {
            CartVect vector = new CartVect();

            vector.X = cd2.X - cd1.X;
            vector.Y = cd2.Y - cd1.Y;
            vector.Z = cd2.Z - cd1.Z;
            return(vector);
        }
Esempio n. 7
0
        public static CartVect UnitVector(CartVect vector)
        {
            CartVect UV = new CartVect();
            double magnitude = VectorMagnitude(vector);

            UV.X = vector.X / magnitude;
            UV.Y = vector.Y / magnitude;
            UV.Z = vector.Z / magnitude;
            return UV;
        }
Esempio n. 8
0
        public static CartVect UnitVector(CartVect vector)
        {
            CartVect UV        = new CartVect();
            double   magnitude = VectorMagnitude(vector);

            UV.X = vector.X / magnitude;
            UV.Y = vector.Y / magnitude;
            UV.Z = vector.Z / magnitude;
            return(UV);
        }
Esempio n. 9
0
        public static CartVect GetRHR(List <CartCoord> plCoords)
        {
            CartVect plRHRVect = new CartVect();
            //this list will store all of the rhr values returned by any arbitrary polyloop
            List <CartVect> RHRs = new List <CartVect>();

            int coordCount = plCoords.Count;

            for (int i = 0; i < coordCount - 2; i++)
            {
                CartVect v1 = CreateVector(plCoords[i], plCoords[i + 1]);
                CartVect v2 = CreateVector(plCoords[i + 1], plCoords[i + 2]);
                CartVect uv = UnitVector(CrossProduct(v1, v2));
                RHRs.Add(uv);
            }
            int             RHRVectorCount    = RHRs.Count;
            List <CartVect> distinctRHRs      = new List <CartVect>();
            int             parallelCount     = 0;
            int             antiParallelCount = 0;

            //the Distinct().ToList() routine did not work because, we believe, the item in the list is not recognized by Distinct()
            //distinctRHRs = RHRs.Distinct().ToList();
            //so we took the following approach to try and find unique vectors and store them
            distinctRHRs.Add(RHRs[0]);
            List <int> uniqueIndices = new List <int>();

            for (int j = 1; j < RHRVectorCount; j++)
            {
                if (RHRs[j].X == distinctRHRs[0].X * -1 && RHRs[j].Y == distinctRHRs[0].Y * -1 && RHRs[j].Z == distinctRHRs[0].Z * -1)
                {
                    //means that the vectors are not facing in the same direction
                    antiParallelCount++;
                }
                else
                {
                    parallelCount++;
                }
            }

            if (antiParallelCount > parallelCount)
            {
                CartVect antiParallel = new CartVect {
                };
                antiParallel.X = distinctRHRs[0].X * -1;
                antiParallel.Y = distinctRHRs[0].Y * -1;
                antiParallel.Z = distinctRHRs[0].Z * -1;

                return(antiParallel);
            }
            else
            {
                return(distinctRHRs[0]);
            }
        }
Esempio n. 10
0
        public static CartVect CrossProductNVRetMSNV(MemorySafe_CartVect vector1, CartVect vector2)
        {
            double   xProdX = vector2.Z * vector1.Y - vector1.Z * vector2.Y;
            double   xProdY = -1 * (vector2.Z * vector1.X - vector1.Z * vector2.X);
            double   xProdZ = vector2.Y * vector1.X - vector1.Y * vector2.X;
            CartVect xProd  = new CartVect(xProdX, xProdY, xProdZ);

            xProd.X = xProdX;
            xProd.Y = xProdY;
            xProd.Z = xProdZ;
            return(xProd);
        }
Esempio n. 11
0
 public static MemorySafe_CartVect convertToMemorySafeVector(CartVect vector)
 {
     MemorySafe_CartVect memVect = new MemorySafe_CartVect(vector.X, vector.Y, vector.Z);
     return memVect;
 }
Esempio n. 12
0
        public static MemorySafe_CartVect GetRHR(List<MemorySafe_CartCoord> plCoords)
        {
            CartVect plRHRVect = new CartVect();
            //this list will store all of the rhr values returned by any arbitrary polyloop
            List<MemorySafe_CartVect> RHRs = new List<MemorySafe_CartVect>();

            int coordCount = plCoords.Count;
            for (int i = 0; i < coordCount - 2; i++)
            {
                MemorySafe_CartVect v1 = CreateMemorySafe_Vector(plCoords[i], plCoords[i + 1]);
                MemorySafe_CartVect v2 = CreateMemorySafe_Vector(plCoords[i + 1], plCoords[i + 2]);
                MemorySafe_CartVect uv = UnitVector(CrossProduct(v1, v2));
                RHRs.Add(uv);
            }
            int RHRVectorCount = RHRs.Count;
            List<MemorySafe_CartVect> distinctRHRs = new List<MemorySafe_CartVect>();
            int parallelCount = 0;
            int antiParallelCount = 0;
            //the Distinct().ToList() routine did not work because, we believe, the item in the list is not recognized by Distinct()
            //distinctRHRs = RHRs.Distinct().ToList();
            //so we took the following approach to try and find unique vectors and store them
            distinctRHRs.Add(RHRs[0]);
            List<int> uniqueIndices = new List<int>();
            for (int j = 1; j < RHRVectorCount; j++)
            {

                if (RHRs[j].X == distinctRHRs[0].X * -1 && RHRs[j].Y == distinctRHRs[0].Y * -1 && RHRs[j].Z == distinctRHRs[0].Z * -1)
                {
                    //means that the vectors are not facing in the same direction
                    antiParallelCount++;
                }
                else
                {
                    parallelCount++;
                }

            }

            if (antiParallelCount > parallelCount)
            {
                double X = distinctRHRs[0].X * -1;
                double Y = distinctRHRs[0].Y * -1;
                double Z = distinctRHRs[0].Z * -1;
                MemorySafe_CartVect antiParallel = new MemorySafe_CartVect(X, Y, Z);
                return antiParallel;
            }
            else
            {
                return distinctRHRs[0];
            }
        }
Esempio n. 13
0
 public static CartVect CrossProductNVRetMSNV(MemorySafe_CartVect vector1, CartVect vector2)
 {
     double xProdX = vector2.Z * vector1.Y - vector1.Z * vector2.Y;
     double xProdY = -1 * (vector2.Z * vector1.X - vector1.Z * vector2.X);
     double xProdZ = vector2.Y * vector1.X - vector1.Y * vector2.X;
     CartVect xProd = new CartVect(xProdX, xProdY, xProdZ);
     xProd.X = xProdX;
     xProd.Y = xProdY;
     xProd.Z = xProdZ;
     return xProd;
 }
Esempio n. 14
0
        public static MemorySafe_CartVect convertToMemorySafeVector(CartVect vector)
        {
            MemorySafe_CartVect memVect = new MemorySafe_CartVect(vector.X, vector.Y, vector.Z);

            return(memVect);
        }