Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idts"></param>
        /// <param name="xy"></param>
        /// <param name="zArr"></param>
        /// <param name="startIndex"></param>
        /// <param name="numPoints"></param>
        private static void ApplyParameterizedTransform(IDatumTransformStage idts, double[] xy, double[] zArr, int startIndex, int numPoints)
        {
            double[] shift;

            if (idts.Method == TransformMethod.Param3)
            {
                shift    = new double[3];
                shift[0] = idts.DeltaX;
                shift[1] = idts.DeltaY;
                shift[2] = idts.DeltaZ;
            }
            else
            {
                shift    = new double[7];
                shift[0] = idts.DeltaX;
                shift[1] = idts.DeltaY;
                shift[2] = idts.DeltaZ;
                shift[3] = idts.RotateX * SecToRad;
                shift[4] = idts.RotateY * SecToRad;
                shift[5] = idts.RotateZ * SecToRad;
                shift[6] = idts.DeltaScale;
                shift[6] = (shift[6] / 1E6) + 1;
            }

            if (shift.Length == 3)
            {
                for (int i = startIndex; i < numPoints; i++)
                {
                    if (double.IsNaN(xy[2 * i]) || double.IsNaN(xy[2 * i + 1]))
                    {
                        continue;
                    }
                    xy[2 * i]     = xy[2 * i] + shift[0];     // dx
                    xy[2 * i + 1] = xy[2 * i + 1] + shift[1]; // dy
                    zArr[i]       = zArr[i] + shift[2];
                }
            }
            else
            {
                for (int i = startIndex; i < numPoints; i++)
                {
                    if (double.IsNaN(xy[2 * i]) || double.IsNaN(xy[2 * i + 1]))
                    {
                        continue;
                    }
                    double x = xy[2 * i];
                    double y = xy[2 * i + 1];
                    double z = zArr[i];
                    xy[2 * i]     = shift[6] * x - shift[5] * y + shift[4] * z + shift[0];
                    xy[2 * i + 1] = shift[5] * x + shift[6] * y - shift[3] * z + shift[1];
                    zArr[i]       = -shift[4] * x + shift[3] * y + shift[6] * z + shift[2];
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="aiDatumTransformStage"></param>
 public DatumTransform(IDatumTransformStage[] aiDatumTransformStage)
 {
     if (aiDatumTransformStage == null)
     {
         throw new Exception("Null DatumTransformStage array passed to constructor");
     }
     //for (int i = 1; i < aiDatumTransformStage.Length; i++) {
     //  if (aiDatumTransformStage[i - 1].ToDatum != aiDatumTransformStage[i].FromDatum) {
     //    throw new Exception("DatumTranformStage array contained consecutive stages with unmatched from/to datums.");
     //  }
     //}
     _aiDts = aiDatumTransformStage;
 }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idts"></param>
        /// <param name="xy"></param>
        /// <param name="zArr"></param>
        /// <param name="startIndex"></param>
        /// <param name="numPoints"></param>
        private static void ApplyParameterizedTransform(IDatumTransformStage idts, double[] xy, double[] zArr, int startIndex, int numPoints)
        {
            double[] shift;

            if (idts.Method == TransformMethod.Param3)
            {
                shift = new double[3];
                shift[0] = idts.DeltaX;
                shift[1] = idts.DeltaY;
                shift[2] = idts.DeltaZ;
            }
            else
            {
                shift = new double[7];
                shift[0] = idts.DeltaX;
                shift[1] = idts.DeltaY;
                shift[2] = idts.DeltaZ;
                shift[3] = idts.RotateX * SecToRad;
                shift[4] = idts.RotateY * SecToRad;
                shift[5] = idts.RotateZ * SecToRad;
                shift[6] = idts.DeltaScale;
                shift[6] = (shift[6] / 1E6) + 1;
            }

            if (shift.Length == 3)
            {
                for (int i = startIndex; i < numPoints; i++)
                {
                    if (double.IsNaN(xy[2 * i]) || double.IsNaN(xy[2 * i + 1])) continue;
                    xy[2 * i] = xy[2 * i] + shift[0]; // dx
                    xy[2 * i + 1] = xy[2 * i + 1] + shift[1]; // dy
                    zArr[i] = zArr[i] + shift[2];
                }
            }
            else
            {
                for (int i = startIndex; i < numPoints; i++)
                {
                    if (double.IsNaN(xy[2 * i]) || double.IsNaN(xy[2 * i + 1])) continue;
                    double x = xy[2 * i];
                    double y = xy[2 * i + 1];
                    double z = zArr[i];
                    xy[2 * i] = shift[6] * x - shift[5] * y + shift[4] * z + shift[0];
                    xy[2 * i + 1] = shift[5] * x + shift[6] * y - shift[3] * z + shift[1];
                    zArr[i] = -shift[4] * x + shift[3] * y + shift[6] * z + shift[2];
                }
            }
        }