public UCS(FeatureCAM.FMUcs fc_ucs)
        {
            this.ucs  = fc_ucs;
            this.name = fc_ucs.Name;
            this.ucs.GetLocation(out x, out y, out z);
            this.x = Math.Round(x, 4);
            this.y = Math.Round(y, 4);
            this.z = Math.Round(z, 4);

            ComputeEulerAngles();
        }
示例#2
0
        private static void ComputeEulerAngles(FeatureCAM.FMUcs ucs,
                                               out double i, out double j, out double k)
        {
            double
                x1, y1, z1,
                x2, y2, z2,
                x3, y3, z3,
                i1, j1, k1,
                j1_rad;

            ucs.GetVectors(out x1, out x2, out x3, out y1, out y2, out y3, out z1, out z2, out z3);

            if (z1 != 1 && z1 != -1)
            {
                j1_rad = -Math.Asin(x3);
                j1     = Lib.Radians2Degrees(j1_rad);
                i1     = Lib.Radians2Degrees(Math.Atan2(y3 / Math.Cos(j1_rad), z3 / Math.Cos(j1_rad)));
                k1     = Lib.Radians2Degrees(Math.Atan2(x2 / Math.Cos(j1_rad), x1 / Math.Cos(j1_rad)));
                i      = i1;
                j      = j1;
                k      = k1;
            }
            else
            {
                k = 0;
                if (z1 == -1)
                {
                    j = 90;
                    i = k + Lib.Radians2Degrees(Math.Atan2(x2, x3));
                }
                else
                {
                    j = -90;
                    i = -k + Lib.Radians2Degrees(Math.Atan2(-x2, -x3));
                }
            }
            i = Math.Round(i, 4);
            j = Math.Round(j, 4);
            k = Math.Round(k, 4);
        }