Esempio n. 1
0
        /// <summary>
        /// calculate total rotation by taking current rotation and then
        /// apply rotation r
        ///
        /// if both angles are quaternions then this is a multiplication
        /// </summary>
        /// <param name="r"></param>
        public void combine(VecRotation r)
        {
            toQuaternion();
            if (r == null)
            {
                return;
            }
            double qax = X;
            double qay = Y;
            double qaz = Z;
            double qaw = Angle;

            double s   = Math.Sin(r.Angle / 2);
            double qbx = r.X * s;
            double qby = r.Y * s;
            double qbz = r.Z * s;
            double qbw = Math.Cos(r.Angle / 2);

            // now multiply the quaternions
            Angle = (double)(qaw * qbw - qax * qbx - qay * qby - qaz * qbz);
            X     = (double)(qax * qbw + qaw * qbx + qay * qbz - qaz * qby);
            Y     = (double)(qaw * qby - qax * qbz + qay * qbw + qaz * qbx);
            Z     = (double)(qaw * qbz + qax * qby - qay * qbx + qaz * qbw);
            toAxisAngle();
        }
Esempio n. 2
0
        /// <summary>
        /// calculate total rotation by taking current rotation and then
        /// apply rotation r
        /// 
        /// if both angles are quaternions then this is a multiplication
        /// </summary>
        /// <param name="r"></param>
        public void combine(VecRotation r)
        {
            toQuaternion();
            if (r == null) return;
            double qax = X;
            double qay = Y;
            double qaz = Z;
            double qaw = Angle;

            double s = Math.Sin(r.Angle / 2);
            double qbx = r.X * s;
            double qby = r.Y * s;
            double qbz = r.Z * s;
            double qbw = Math.Cos(r.Angle / 2);

            // now multiply the quaternions
            Angle = (double)(qaw * qbw - qax * qbx - qay * qby - qaz * qbz);
            X = (double)(qax * qbw + qaw * qbx + qay * qbz - qaz * qby);
            Y = (double)(qaw * qby - qax * qbz + qay * qbw + qaz * qbx);
            Z = (double)(qaw * qbz + qax * qby - qay * qbx + qaz * qbw);
            toAxisAngle();
        }
Esempio n. 3
0
        void RotateZ(double angle)
        {
            Fractrace.Geometry.VecRotation rotation = new VecRotation();
            rotation.FromEuler(Math.PI * ParameterDict.Current.GetDouble("Transformation.Camera.AngleX") / 180.0,
                Math.PI * ParameterDict.Current.GetDouble("Transformation.Camera.AngleY") / 180.0,
                Math.PI * ParameterDict.Current.GetDouble("Transformation.Camera.AngleZ") / 180.0);

            rotation.Normalize();
            rotation.combine(0, 0, angle);

            double ax = 0, ay = 0, az = 0;
            rotation.toEuler(ref ax, ref ay, ref az);

            ax = 180 * ax / Math.PI;
            ay = 180 * ay / Math.PI;
            az = 180 * az / Math.PI;

            ParameterDict.Current.SetDouble("Transformation.Camera.AngleX", ax);
            ParameterDict.Current.SetDouble("Transformation.Camera.AngleY", ay);
            ParameterDict.Current.SetDouble("Transformation.Camera.AngleZ", az);
        }
Esempio n. 4
0
        /// <summary>
        /// Benutzung der Vektorrotation.
        /// </summary>
        /// <param name="ar"></param>
        /// <param name="ai"></param>
        /// <param name="aj"></param>
        /// <param name="ak"></param>
        /// <param name="br"></param>
        /// <param name="bi"></param>
        /// <param name="bj"></param>
        /// <param name="bk"></param>
        /// <param name="zkl"></param>
        /// <param name="invers"></param>
        /// <returns></returns>
        long H7(double ar, double ai, double aj, double ak, double br, double bi, double bj, double bk, long zkl, bool invers)
        {
            double xx, yy, zz;
            long tw;
            int n;
            ai = 0; aj = 0; ak = 0;

            double x = 1, y = 0, z = 0;

            xx = x * x; yy = y * y; zz = z * z;
            tw = 0;
            double r = Math.Sqrt(xx + yy + zz);
            VecRotation vecRot = new VecRotation();

            x = 1; // Um den Startwinkel eindeutig zu definieren.
            for (n = 1; n < zkl; n++)
            {

                double theta = Math.Atan2(Math.Sqrt(xx + yy), z);
                double phi = Math.Atan2(y, x);

                vecRot.X = y;
                vecRot.Y = x;
                vecRot.Z = z;
                vecRot.Angle = theta;
                //   vecRot.angle = 0.03;
                vecRot.X = x;
                vecRot.Y = z;
                vecRot.Z = y;
                vecRot.Angle = phi;

                /*
                vecRot.x = 0.4;
                vecRot.y = 0.2;
                vecRot.z = 0.8;
                vecRot.angle = phi;
                */
                y += bj;
                x += bi;
                z += br;
                Vec3 pos = new Vec3(x, y, z);
                Vec3 newPos = vecRot.getTransform(pos);

                x = newPos.X;
                y = newPos.Y;
                z = newPos.Z;

                xx = x * x; yy = y * y; zz = z * z;// aak = ak * ak;
                r = Math.Sqrt(xx + yy + zz);

                x *= r;
                y *= r;
                z *= r;
                if (r > gr)
                {
                    tw = n; break;
                }

            }

            if (invers)
            {
                if (tw == 0)
                    tw = 1;
                else
                    tw = 0;
            }
            return (tw);
        }