コード例 #1
0
ファイル: Character.cs プロジェクト: evrenvural/pong-game
 public Character(int _x, int _y, int _height, int _width, Rotations _rotation) : base(_x, _y, _height, _width, _rotation)
 {
     Collider = new Collider(X, Y, Width, Height);
 }
コード例 #2
0
 TransportRotationRecord GetAnimRotation(uint time)
 {
     return(Rotations.LookupByKey(time));
 }
コード例 #3
0
        public void CalculateBoneRotations()
        {
            // calculate the Bone Global Rotations
            for (int i = 0; i < 15; i++)
            {
                Rotations.Add(Quaternion.identity); // initialize the Rotations
            }

            // define the initial reference coordinate rotations
            var rotLeftForward = Quaternion.LookRotation(Vector3.left, Vector3.forward);
            var rotLeftBack    = Quaternion.LookRotation(Vector3.left, Vector3.back);
            var rotLeftDown    = Quaternion.LookRotation(Vector3.left, Vector3.down);
            var rotLeftUp      = Quaternion.LookRotation(Vector3.left, Vector3.up);

            // TODO: make sure that the coordinate system will be the same(fixed to the bones) for every frame based on the human joint keypoints
            Rotations[0] = CalculateGlobalRotation(Positions[2] - Positions[6], Positions[7] - Positions[6], rotLeftDown);
            Rotations[1] = CalculateGlobalRotation(Positions[1] - Positions[2], Positions[0] - Positions[1], rotLeftForward);
            Rotations[2] = CalculateGlobalRotation(Positions[0] - Positions[1], Positions[2] - Positions[1], rotLeftForward);

            Rotations[3] = CalculateGlobalRotation(Positions[3] - Positions[6], Positions[6] - Positions[7], rotLeftDown);
            Rotations[4] = CalculateGlobalRotation(Positions[4] - Positions[3], Positions[5] - Positions[4], rotLeftForward);
            Rotations[5] = CalculateGlobalRotation(Positions[5] - Positions[4], Positions[3] - Positions[4], rotLeftForward);

            Rotations[6] = CalculateGlobalRotation(Positions[7] - Positions[6], Positions[3] - Positions[2], rotLeftDown);
            Rotations[7] = CalculateGlobalRotation(Positions[8] - Positions[7], Positions[6] - Positions[7], rotLeftDown);
            Rotations[8] = CalculateGlobalRotation(Positions[9] - Positions[8], Positions[13] - Positions[12], rotLeftDown);

            Rotations[9]  = CalculateGlobalRotation(Positions[12] - Positions[8], Positions[8] - Positions[7], rotLeftUp);
            Rotations[10] = CalculateGlobalRotation(Positions[11] - Positions[12], Positions[10] - Positions[11], rotLeftBack);
            Rotations[11] = CalculateGlobalRotation(Positions[10] - Positions[11], Positions[12] - Positions[11], rotLeftBack);

            Rotations[12] = CalculateGlobalRotation(Positions[13] - Positions[8], Positions[7] - Positions[8], rotLeftUp);
            Rotations[13] = CalculateGlobalRotation(Positions[14] - Positions[13], Positions[15] - Positions[14], rotLeftBack);
            Rotations[14] = CalculateGlobalRotation(Positions[15] - Positions[14], Positions[13] - Positions[14], rotLeftBack);
            // Rotations[0] = CalculateGlobalRotation(Positions[2]-Positions[6], Positions[7]-Positions[6]);
            // Rotations[1] = CalculateGlobalRotation(Positions[1]-Positions[2], Positions[0]-Positions[1]);
            // Rotations[2] = CalculateGlobalRotation(Positions[0]-Positions[1], Positions[2]-Positions[1]);

            // Rotations[3] = CalculateGlobalRotation(Positions[3]-Positions[6], Positions[6]-Positions[7]);
            // Rotations[4] = CalculateGlobalRotation(Positions[4]-Positions[3], Positions[5]-Positions[4]);
            // Rotations[5] = CalculateGlobalRotation(Positions[5]-Positions[4], Positions[3]-Positions[4]);

            // Rotations[6] = CalculateGlobalRotation(Positions[7]-Positions[6], Positions[3]-Positions[2]);
            // Rotations[7] = CalculateGlobalRotation(Positions[8]-Positions[7], Positions[6]-Positions[7]);
            // Rotations[8] = CalculateGlobalRotation(Positions[9]-Positions[8], Positions[13]-Positions[12]);

            // Rotations[9] = CalculateGlobalRotation(Positions[12]-Positions[8], Positions[8]-Positions[7]);
            // Rotations[10] = CalculateGlobalRotation(Positions[11]-Positions[12], Positions[10]-Positions[11]);
            // Rotations[11] = CalculateGlobalRotation(Positions[10]-Positions[11], Positions[12]-Positions[11]);

            // Rotations[12] = CalculateGlobalRotation(Positions[13]-Positions[8], Positions[7]-Positions[8]);
            // Rotations[13] = CalculateGlobalRotation(Positions[14]-Positions[13], Positions[15]-Positions[14]);
            // Rotations[14] = CalculateGlobalRotation(Positions[15]-Positions[14], Positions[13]-Positions[14]);

            // calculate the Bone Local Rotations
            LocalRotations = Rotations.ToList(); // initialize the LocalRotations

            // construct the reference coordinate rotations
            var invRightHipBine = Quaternion.Inverse(Rotations[0]);
            var invRightThigh   = Quaternion.Inverse(Rotations[1]);

            var invLeftHipBone = Quaternion.Inverse(Rotations[3]);
            var invLeftThigh   = Quaternion.Inverse(Rotations[4]);

            var invWaist  = Quaternion.Inverse(Rotations[6]);
            var invCheset = Quaternion.Inverse(Rotations[7]);
            var invNeck   = Quaternion.Inverse(Rotations[8]);

            var invRightClavicle = Quaternion.Inverse(Rotations[9]);
            var invRigthUpperArm = Quaternion.Inverse(Rotations[10]);

            var invLeftClavicle = Quaternion.Inverse(Rotations[12]);
            var invLeftUpperArm = Quaternion.Inverse(Rotations[13]);

            // calculate the bone local roataions of human
            LocalRotations[0] = invWaist * LocalRotations[0];
            LocalRotations[1] = invRightHipBine * LocalRotations[1];
            LocalRotations[2] = invRightThigh * LocalRotations[2];

            LocalRotations[3] = invWaist * LocalRotations[3];
            LocalRotations[4] = invLeftHipBone * LocalRotations[4];
            LocalRotations[5] = invLeftThigh * LocalRotations[5];

            // LocalRotations[6] = invWaist * LocalRotations[6];
            LocalRotations[7] = invWaist * LocalRotations[7];
            LocalRotations[8] = invCheset * LocalRotations[8];

            LocalRotations[9]  = invNeck * LocalRotations[9];
            LocalRotations[10] = invRightClavicle * LocalRotations[10];
            LocalRotations[11] = invRigthUpperArm * LocalRotations[11];

            LocalRotations[12] = invNeck * LocalRotations[12];
            LocalRotations[13] = invLeftClavicle * LocalRotations[13];
            LocalRotations[14] = invLeftUpperArm * LocalRotations[14];
        }
コード例 #4
0
ファイル: Shapes.cs プロジェクト: FelixKras/Discrimination
        private List <PointOnGrid> ComputeProjection(StateVector stateVec, List <PointOnGrid> origPoints)
        {   /*
             * rotation_matrix = yaw_rotation_matrix * pitch_rotation_matrix * roll_rotation_matrix;
             * world_matrix = translation_matrix * rotation_matrix;
             */
            List <PointOnGrid> projPoints = new List <PointOnGrid>();


            double[,] T_mat = Transltions.CreateTranslationMatrix(new double[]
                                                                  { stateVec.XCG, stateVec.YCG, stateVec.ZCG });
            double[,] R_Gen = Rotations.CreateRotationThetaPsiPhi(Rotations.ToRadians(stateVec.PitchAngle),
                                                                  Rotations.ToRadians(stateVec.YawAngle), Rotations.ToRadians(stateVec.RollAngle));


            double[,] World_mat = BLAS.Multiply(T_mat, R_Gen);

            /*
             * [u,v]= Cam_Project_mat*world_matrix*[x y z]
             */

            double[,] Cam_Project_mat  = Camera.CreateProjectionMatrix();
            double[,] Launch_to_Camera = Camera.CreateAxisTranformMatrix();
            double[,] FinalMat         = BLAS.Multiply(Cam_Project_mat, BLAS.Multiply(Launch_to_Camera, World_mat));


            for (int ii = 0; ii < origPoints.Count; ii++)
            {
                // Apply transformation to original position
                double[] vec           = new double[] { origPoints[ii].X, origPoints[ii].Y, origPoints[ii].Z, 1 };
                double[] transf_camera = BLAS.Multiply(FinalMat, vec);


                transf_camera[0] /= transf_camera[2];
                transf_camera[1] /= transf_camera[2];
                transf_camera[2] /= transf_camera[2];

                //double[] transfScaled = BLAS.Multiply(Scales.ScaleMat, transf_camera);
                if (transf_camera[0] > 0 && transf_camera[1] > 0 && transf_camera[0] < Camera.CameraSettings.SensorWidth && transf_camera[1] < Camera.CameraSettings.SensorHeight)
                {
                    projPoints.Add(new PointOnGrid((float)transf_camera[0], (float)transf_camera[1], 0, ii, origPoints[ii].Intensity, origPoints[ii].Component));
                }
            }

            return(projPoints);
        }
コード例 #5
0
 /// <summary>
 /// Constructor by edge and rigidity. Used to create group for point support
 /// </summary>
 internal Group(Geometry.FdVector3d localX, Geometry.FdVector3d localY, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits)
 {
     this._localX  = localX;
     this._localY  = localY;
     this.Rigidity = new RigidityDataType3(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits);
 }
コード例 #6
0
 public static PointSupport Define(Autodesk.DesignScript.Geometry.Point point, Motions motions, [DefaultArgument("MotionsPlasticLimits.Default()")] MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, [DefaultArgument("RotationsPlasticLimits.Default()")] RotationsPlasticLimits rotationsPlasticLimits, [DefaultArgument("S")] string identifier)
 {
     return(new PointSupport(Geometry.FdPoint3d.FromDynamo(point), motions, motionsPlasticLimits, rotations, rotationsPlasticLimits, identifier));
 }
コード例 #7
0
ファイル: MarbleTumble.cs プロジェクト: CaitSith2/KtaneStuff
 public override string ToString()
 {
     return($"Rotations: {Rotations.JoinString(", ")}; Marble: {Marble}");
 }
コード例 #8
0
        /// <summary>
        /// Create a connected point between 2 points with rigidity (motions, rotations) and plastic limits (forces, moments).
        /// </summary>
        public ConnectedPoints(FdPoint3d firstPoint, FdPoint3d secondPoint, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits, GuidListType[] references, string identifier = "CP")
        {
            RigidityDataType2 rigidity = new RigidityDataType2(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits);

            Initialize(firstPoint, secondPoint, rigidity, references, identifier);
        }
コード例 #9
0
ファイル: Ball.cs プロジェクト: evrenvural/pong-game
 public Ball(int _x, int _y, int _height, int _width, int _speed, Rotations _rotation) : base(_x, _y, _height, _width, _rotation)
 {
     Speed    = _speed;
     Collider = new Collider(X, Y, Width, Height);
     Dynamic  = new Dynamic();
 }
コード例 #10
0
        public static double GetTorque(double RPM, double throttle, double boost)
        {
            int BaseEngineCurve = 0x00ADD94C; // TODO: MAP TO SIMULATOR MAPPING

            // get engine torque figures (at this engine RPM)
            // this is directly from memory based engine curves.
            double Rads   = Rotations.RPM_Rads(RPM);
            double Th_L   = 0;
            double Th_H   = 0;
            double Tl_L   = 0;
            double Tl_H   = 0;
            double R_L    = 0;
            double R_H    = 0;
            int    offset = 0;

            double Th_Prev = 0;
            double Tl_Prev = 0;
            double R_Prev  = 0;
            bool   Cached  = ((DoubleList.Count == 0) ? false : true);

            if (!Cached)
            {
                for (offset = 0; offset < 500; offset++)
                {
                    double curve_rpm, Tl_Now, Th_Now;
                    // read rpm
                    curve_rpm = Telemetry.m.Sim.Memory.ReadDouble(new IntPtr(BaseEngineCurve + 0x8 * 3 * offset));
                    Tl_Now    = Telemetry.m.Sim.Memory.ReadDouble(new IntPtr(BaseEngineCurve + 0x8 * 1 + 0x8 * 3 * offset));
                    Th_Now    = Telemetry.m.Sim.Memory.ReadDouble(new IntPtr(BaseEngineCurve + 0x8 * 2 + 0x8 * 3 * offset));

                    DoubleList.Add(curve_rpm);
                    DoubleList.Add(Tl_Now);
                    DoubleList.Add(Th_Now);
                }
                Cached = true;
                offset = 0;
            }
            while (Th_H == 0)
            {
                double curve_rpm, Tl_Now, Th_Now;
                curve_rpm = DoubleList[offset * 3];
                Tl_Now    = DoubleList[offset * 3 + 1];
                Th_Now    = DoubleList[offset * 3 + 2];


                if (curve_rpm >= Rads)
                {
                    Th_L = Th_Prev;
                    Th_H = Th_Now;

                    Tl_L = Tl_Prev;
                    Tl_H = Tl_Now;


                    R_H = curve_rpm;
                    R_L = R_Prev;
                    break;
                }

                R_Prev  = curve_rpm;
                Th_Prev = Th_Now;
                Tl_Prev = Tl_Now;
                offset++;
            }

            // calculate duty cycle and determine torque.
            double RPM_Part = (Rads - R_L) / (R_H - R_L); // factor in rpm curve.
            double TorqueH  = Th_L + RPM_Part * (Th_H - Th_L);
            double TorqueL  = Tl_L + RPM_Part * (Tl_H - Tl_L);

            //return TorqueH * throttle * boost + TorqueL * boost;
            return((TorqueH - TorqueL) * throttle * boost + TorqueL);
        }
コード例 #11
0
 private Action CreateAction(Rotations direction, int degrees)
 {
     return(new Action(direction.ToString(), $"{getRotationString(direction)} {degrees}", Action.ActionTypes.Control, Client));
 }
コード例 #12
0
ファイル: Poses2.cs プロジェクト: JadeCong/AvatarGame_Unity
        public void CalculateBoneRotations()
        {
            // Global Rotations
            for (int i = 0; i < 15; i++)
            {
                Rotations.Add(Quaternion.identity);
            }

            // TODO: make sure that the coordinate system will be the same(fixed to the bones) for every frame based on the human joint keypoints
            Rotations[0] = CalculateGlobalRotation(Positions[2] - Positions[6], Positions[7] - Positions[6], HumanToAvatarTransformRotations[0]);
            Rotations[1] = CalculateGlobalRotation(Positions[1] - Positions[2], Positions[0] - Positions[1], HumanToAvatarTransformRotations[1]);
            Rotations[2] = CalculateGlobalRotation(Positions[0] - Positions[1], Positions[2] - Positions[1], HumanToAvatarTransformRotations[2]);

            Rotations[3] = CalculateGlobalRotation(Positions[3] - Positions[6], Positions[6] - Positions[7], HumanToAvatarTransformRotations[3]);
            Rotations[4] = CalculateGlobalRotation(Positions[4] - Positions[3], Positions[5] - Positions[4], HumanToAvatarTransformRotations[4]);
            Rotations[5] = CalculateGlobalRotation(Positions[5] - Positions[4], Positions[3] - Positions[4], HumanToAvatarTransformRotations[5]);

            Rotations[6] = CalculateGlobalRotation(Positions[7] - Positions[6], Positions[3] - Positions[2], HumanToAvatarTransformRotations[6]);
            Rotations[7] = CalculateGlobalRotation(Positions[8] - Positions[7], Positions[6] - Positions[7], HumanToAvatarTransformRotations[7]);
            Rotations[8] = CalculateGlobalRotation(Positions[9] - Positions[8], Positions[13] - Positions[12], HumanToAvatarTransformRotations[8]);

            Rotations[9]  = CalculateGlobalRotation(Positions[12] - Positions[8], Positions[8] - Positions[7], HumanToAvatarTransformRotations[9]);
            Rotations[10] = CalculateGlobalRotation(Positions[11] - Positions[12], Positions[10] - Positions[11], HumanToAvatarTransformRotations[10]);
            Rotations[11] = CalculateGlobalRotation(Positions[10] - Positions[11], Positions[12] - Positions[11], HumanToAvatarTransformRotations[11]);

            Rotations[12] = CalculateGlobalRotation(Positions[13] - Positions[8], Positions[7] - Positions[8], HumanToAvatarTransformRotations[12]);
            Rotations[13] = CalculateGlobalRotation(Positions[14] - Positions[13], Positions[15] - Positions[14], HumanToAvatarTransformRotations[13]);
            Rotations[14] = CalculateGlobalRotation(Positions[15] - Positions[14], Positions[13] - Positions[14], HumanToAvatarTransformRotations[14]);

            // Local Rotations
            LocalRotations = Rotations.ToList();

            // construct the reference coordinate rotations
            var invRightHipBine = Quaternion.Inverse(Rotations[0]);
            var invRightThigh   = Quaternion.Inverse(Rotations[1]);

            var invLeftHipBone = Quaternion.Inverse(Rotations[3]);
            var invLeftThigh   = Quaternion.Inverse(Rotations[4]);

            var invWaist  = Quaternion.Inverse(Rotations[6]);
            var invCheset = Quaternion.Inverse(Rotations[7]);
            var invNeck   = Quaternion.Inverse(Rotations[8]);

            var invRightClavicle = Quaternion.Inverse(Rotations[9]);
            var invRigthUpperArm = Quaternion.Inverse(Rotations[10]);

            var invLeftClavicle = Quaternion.Inverse(Rotations[12]);
            var invLeftUpperArm = Quaternion.Inverse(Rotations[13]);

            // calculate the bone local roataions of human
            // TODO: make sure the inv on the left or the right
            LocalRotations[0] = LocalRotations[0] * invWaist;
            LocalRotations[1] = LocalRotations[1] * invRightHipBine;
            LocalRotations[2] = LocalRotations[2] * invRightThigh;

            LocalRotations[3] = LocalRotations[3] * invWaist;
            LocalRotations[4] = LocalRotations[4] * invLeftHipBone;
            LocalRotations[5] = LocalRotations[5] * invLeftThigh;

            // LocalRotations[6] = LocalRotations[6] * invWaist;
            LocalRotations[7] = LocalRotations[7] * invWaist;
            LocalRotations[8] = LocalRotations[8] * invCheset;

            LocalRotations[9]  = LocalRotations[9] * invNeck;
            LocalRotations[10] = LocalRotations[10] * invRightClavicle;
            LocalRotations[11] = LocalRotations[11] * invRigthUpperArm;

            LocalRotations[12] = LocalRotations[12] * invNeck;
            LocalRotations[13] = LocalRotations[13] * invLeftClavicle;
            LocalRotations[14] = LocalRotations[14] * invLeftUpperArm;
            // LocalRotations[0] = invWaist * LocalRotations[0];
            // LocalRotations[1] = invRightHipBine * LocalRotations[1];
            // LocalRotations[2] = invRightThigh * LocalRotations[2];

            // LocalRotations[3] = invWaist * LocalRotations[3];
            // LocalRotations[4] = invLeftHipBone * LocalRotations[4];
            // LocalRotations[5] = invLeftThigh * LocalRotations[5];

            // // LocalRotations[6] = invWaist * LocalRotations[6];
            // LocalRotations[7] = invWaist * LocalRotations[7];
            // LocalRotations[8] = invCheset * LocalRotations[8];

            // LocalRotations[9] = invNeck * LocalRotations[9];
            // LocalRotations[10] = invRightClavicle * LocalRotations[10];
            // LocalRotations[11] = invRigthUpperArm * LocalRotations[11];

            // LocalRotations[12] = invNeck * LocalRotations[12];
            // LocalRotations[13] = invLeftClavicle * LocalRotations[13];
            // LocalRotations[14] = invLeftUpperArm * LocalRotations[14];
        }
コード例 #13
0
 public void RemoveActiveRotation()
 {
     Rotations.RemoveAt(ActiveRotationIndex);
     ActiveRotationIndex = Math.Min(ActiveRotationIndex, Rotations.Count - 1);
 }
コード例 #14
0
 public Player(int _x, int _y, int _height, int _width, int _speed, Rotations _rotation) : base(_x, _y, _height, _width, _rotation)
 {
     Speed = _speed;
 }
コード例 #15
0
        public void ComputeProjection(double[] CenterOfMassCartesian)
        {   /*
             * rotation_matrix = yaw_rotation_matrix * pitch_rotation_matrix * roll_rotation_matrix;
             * world_matrix = translation_matrix * rotation_matrix;
             */
            ImagePoints = new ShapePoint2D[OriginalPoints.Length];

            #region Debug
#warning DEBUG
            //var TestVec = new double[] {-0.5, 0.5, 0.7071, 1};
            //RollAngle = 0;
            //PitchAngle = 45;
            //YawAngle = 45;
            //CenterOfMassCartesian = new double[] { 0, 50, 100 };

            #endregion

            //double[,] R_roll = Rotations.CreateRotationMatrixRoll(Rotations.ToRadians(RollAngle)); //Rx
            //double[,] R_pitch = Rotations.CreateRotationMatrixPitch(Rotations.ToRadians(PitchAngle)); //Ry
            //double[,] R_yaw = Rotations.CreateRotationMatrixYaw(Rotations.ToRadians(YawAngle)); //Rz

            //double[,] temp = BLAS.Multiply(R_roll, R_yaw);
            //double[,] R_Gen = BLAS.Multiply(R_pitch, temp);

            double[,] T_mat = Transltions.CreateTranslationMatrix(CenterOfMassCartesian);

            //R_Gen = Rotations.CreateRotationPsiThetaPhi(Rotations.ToRadians(YawAngle), Rotations.ToRadians(PitchAngle), Rotations.ToRadians(RollAngle));
            double[,] R_Gen = Rotations.CreateRotationThetaPsiPhi(Rotations.ToRadians(PitchAngle), Rotations.ToRadians(YawAngle), Rotations.ToRadians(RollAngle));

            double[,] World_mat = BLAS.Multiply(T_mat, R_Gen);

            /*
             * [u,v]= Cam_Project_mat*world_matrix*[x y z]
             */

            double[,] Cam_Project_mat  = Camera.CreateProjectionMatrix();
            double[,] Launch_to_Camera = Camera.CreateAxisTranformMatrix();
            double[,] FinalMat         = BLAS.Multiply(Cam_Project_mat, BLAS.Multiply(Launch_to_Camera, World_mat));

            #region Debug
#warning DEBUG
            //double[] Testtransf = BLAS.Multiply(FinalMat, TestVec);
            //Testtransf[0] /= Testtransf[2];
            //Testtransf[1] /= Testtransf[2];
            //Testtransf[2] /= Testtransf[2];
            #endregion


            SetLedSize(FinalMat);

            for (int ii = 0; ii < OriginalPoints.Length; ii++)
            {
                // Apply transformation to original position
                double[] vec           = new double[] { OriginalPoints[ii].X, OriginalPoints[ii].Y, OriginalPoints[ii].Z, 1 };
                double[] transf_camera = BLAS.Multiply(FinalMat, vec);


                transf_camera[0] /= transf_camera[2];
                transf_camera[1] /= transf_camera[2];
                transf_camera[2] /= transf_camera[2];

                double[] transfScaled = BLAS.Multiply(Scales.ScaleMat, transf_camera);
                if (transfScaled[0] > 0 && transfScaled[1] > 0 && transfScaled[0] < Camera.CameraSettings.SensorWidth && transfScaled[1] < Camera.CameraSettings.SensorHeight)
                {
                    ImagePoints[ii] = new ShapePoint2D(transfScaled[0], transfScaled[1], OriginalPoints[ii].isLED);
                }
                else
                {
                    ImagePoints[ii] = new ShapePoint2D(-10, -10, false);
                }
            }
        }
コード例 #16
0
        /// <summary>
        /// Create a connected point between 2 points with rigidity (motions, rotations) and plastic limits (forces, moments).
        /// </summary>
        public ConnectedPoints(FdPoint3d firstPoint, FdPoint3d secondPoint, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits, IEnumerable <EntityBase> references, string identifier = "CP")
        {
            GuidListType[]    refs     = references.Select(r => new GuidListType(r)).ToArray();
            RigidityDataType2 rigidity = new RigidityDataType2(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits);

            Initialize(firstPoint, secondPoint, rigidity, refs, identifier);
        }
コード例 #17
0
ファイル: Poses8.cs プロジェクト: JadeCong/AvatarGame_Unity
        // CalculateBoneRotations is called for calculating the bone rotations(global/local) in the method of joint angle mapping
        public void CalculateBoneRotations()
        {
            // calculate the Bone Global Rotations
            for (int i = 0; i < 16; i++)
            {
                Rotations.Add(Quaternion.identity); // initialize the Rotations
            }

            // check whether using absolute coordinate rotation and pick the different methods(aligning coordinates/relatively rotating) to calculate the bone rotations
            if (UseAbsoluteCoordinate)
            {
                // calculate the bone global rotations using the method of aligning bone coordinates(make sure that the coordinate system will be the same(fixed to the bones) for every frame based on the human joint keypoints)
                Rotations[0] = CalculateGlobalRotation(Positions[6] - Positions[7], Positions[3] - Positions[2], 3);                                                // rightHipBone(rotTypeFlag:3)
                Rotations[1] = CalculateGlobalRotation(Positions[2] - Positions[1], Positions[1] - Positions[0], 1);                                                // rightThigh(rotTypeFlag:1)
                Rotations[2] = CalculateGlobalRotation(Positions[1] - Positions[0], Positions[1] - Positions[2], 1);                                                // rightCalf(rotTypeFlag:1)

                Rotations[3] = CalculateGlobalRotation(Positions[6] - Positions[7], Positions[3] - Positions[2], 3);                                                // leftHipBone(rotTypeFlag:3)
                Rotations[4] = CalculateGlobalRotation(Positions[3] - Positions[4], Positions[4] - Positions[5], 1);                                                // leftThigh(rotTypeFlag:1)
                Rotations[5] = CalculateGlobalRotation(Positions[4] - Positions[5], Positions[4] - Positions[3], 1);                                                // leftCalf(rotTypeFlag:1)

                Rotations[6] = CalculateGlobalRotation(Positions[6] - Positions[7], Positions[3] - Positions[2], 3);                                                // waist(rotTypeFlag:3)
                Rotations[7] = CalculateGlobalRotation(Positions[7] - Positions[8], Positions[6] - Positions[7], 1);                                                // chest(rotTypeFlag:1)
                Rotations[8] = CalculateGlobalRotation(Positions[8] - Positions[9], Positions[7] - Positions[8], 1) * new Quaternion(0.0f, 0.0f, 0.342f, 0.940f);   // neck(rotTypeFlag:1)(correct the neck up for 40 degrees in z axis rotation direction)
                Rotations[9] = CalculateGlobalRotation(Positions[9] - Positions[10], Positions[8] - Positions[9], 1);                                               // head(rotTypeFlag:1)

                Rotations[10] = CalculateGlobalRotation(Positions[8] - Positions[13], Vector3.Cross(Positions[8] - Positions[13], Positions[8] - Positions[7]), 2); // rightClavicle(rotTypeFlag:2)
                Rotations[11] = CalculateGlobalRotation(Positions[13] - Positions[12], Positions[12] - Positions[11], 1);                                           // rightUpperArm(rotTypeFlag:1)
                Rotations[12] = CalculateGlobalRotation(Positions[12] - Positions[11], Positions[12] - Positions[13], 1);                                           // rightForearm(rotTypeFlag:1)

                Rotations[13] = CalculateGlobalRotation(Positions[8] - Positions[14], Vector3.Cross(Positions[8] - Positions[14], Positions[7] - Positions[8]), 2); // leftClavicle(rotTypeFlag:2)
                Rotations[14] = CalculateGlobalRotation(Positions[14] - Positions[15], Positions[15] - Positions[16], 1);                                           // leftUpperArm(rotTypeFlag:1)
                Rotations[15] = CalculateGlobalRotation(Positions[15] - Positions[16], Positions[15] - Positions[14], 1);                                           // leftForearm(rotTypeFlag:1)
            }
            else
            {
                // define the initial reference coordinate rotations
                var rotLeftForward = Quaternion.LookRotation(Vector3.left, Vector3.forward);
                var rotLeftBack    = Quaternion.LookRotation(Vector3.left, Vector3.back);
                var rotLeftDown    = Quaternion.LookRotation(Vector3.left, Vector3.down);
                var rotLeftUp      = Quaternion.LookRotation(Vector3.left, Vector3.up);

                // calculate the bone global rotations using the method of relatively rotating
                Rotations[0] = CalculateGlobalRotation(Positions[2] - Positions[6], Positions[7] - Positions[6], rotLeftDown);      // rightHipBone
                Rotations[1] = CalculateGlobalRotation(Positions[1] - Positions[2], Positions[0] - Positions[1], rotLeftForward);   // rightThigh
                Rotations[2] = CalculateGlobalRotation(Positions[0] - Positions[1], Positions[2] - Positions[1], rotLeftForward);   // rightCalf

                Rotations[3] = CalculateGlobalRotation(Positions[3] - Positions[6], Positions[6] - Positions[7], rotLeftDown);      // leftHipBone
                Rotations[4] = CalculateGlobalRotation(Positions[4] - Positions[3], Positions[5] - Positions[4], rotLeftForward);   // leftThigh
                Rotations[5] = CalculateGlobalRotation(Positions[5] - Positions[4], Positions[3] - Positions[4], rotLeftForward);   // leftCalf

                Rotations[6] = CalculateGlobalRotation(Positions[7] - Positions[6], Positions[3] - Positions[2], rotLeftDown);      // waist
                Rotations[7] = CalculateGlobalRotation(Positions[8] - Positions[7], Positions[6] - Positions[7], rotLeftDown);      // chest
                Rotations[8] = CalculateGlobalRotation(Positions[9] - Positions[8], Positions[13] - Positions[12], rotLeftDown);    // neck
                Rotations[9] = CalculateGlobalRotation(Positions[10] - Positions[9], Positions[8] - Positions[9], rotLeftDown);     // head

                Rotations[10] = CalculateGlobalRotation(Positions[13] - Positions[8], Positions[8] - Positions[7], rotLeftUp);      // rightClavicle
                Rotations[11] = CalculateGlobalRotation(Positions[12] - Positions[13], Positions[11] - Positions[12], rotLeftBack); // rightUpperArm
                Rotations[12] = CalculateGlobalRotation(Positions[11] - Positions[12], Positions[13] - Positions[12], rotLeftBack); // rightForearm

                Rotations[13] = CalculateGlobalRotation(Positions[14] - Positions[8], Positions[7] - Positions[8], rotLeftUp);      // leftClavicle
                Rotations[14] = CalculateGlobalRotation(Positions[15] - Positions[14], Positions[16] - Positions[15], rotLeftBack); // leftUpperArm
                Rotations[15] = CalculateGlobalRotation(Positions[16] - Positions[15], Positions[14] - Positions[15], rotLeftBack); // leftForearm
            }

            // calculate the Bone Local Rotations
            for (int j = 0; j < 16; j++)
            {
                LocalRotations.Add(Quaternion.identity); // initialize the LocalRotations
            }

            // check whether using local rotation of bones for driving avatar
            if (UseLocalRotation)
            {
                // calculate the bone local rotations using the method of relatively rotating
                LocalRotations[0] = CalculateLocalRotation(Rotations[6], Rotations[0]); // rightHipBone
                LocalRotations[1] = CalculateLocalRotation(Rotations[0], Rotations[1]); // rightThigh
                LocalRotations[2] = CalculateLocalRotation(Rotations[1], Rotations[2]); // rightCalf

                LocalRotations[3] = CalculateLocalRotation(Rotations[6], Rotations[3]); // leftHipBone
                LocalRotations[4] = CalculateLocalRotation(Rotations[3], Rotations[4]); // leftThigh
                LocalRotations[5] = CalculateLocalRotation(Rotations[4], Rotations[5]); // leftCalf

                // LocalRotations[6] = Rotations[6]; // waist
                LocalRotations[6] = CalculateLocalRotation(new Quaternion(-0.5f, 0.5f, 0.5f, 0.5f), Rotations[6]); // waist(relative rotation of pelvis to the world coordinate system)
                LocalRotations[7] = CalculateLocalRotation(Rotations[6], Rotations[7]);                            // chest
                LocalRotations[8] = CalculateLocalRotation(Rotations[7], Rotations[8]);                            // neck
                LocalRotations[9] = CalculateLocalRotation(Rotations[8], Rotations[9]);                            // head

                LocalRotations[10] = CalculateLocalRotation(Rotations[8], Rotations[10]);                          // rightClavicle
                LocalRotations[11] = CalculateLocalRotation(Rotations[10], Rotations[11]);                         // rightUpperArm
                LocalRotations[12] = CalculateLocalRotation(Rotations[11], Rotations[12]);                         // rightForearm

                LocalRotations[13] = CalculateLocalRotation(Rotations[8], Rotations[13]);                          // leftClavicle
                LocalRotations[14] = CalculateLocalRotation(Rotations[13], Rotations[14]);                         // leftUpperArm
                LocalRotations[15] = CalculateLocalRotation(Rotations[14], Rotations[15]);                         // leftForearm
            }
        }
コード例 #18
0
 /// <summary>
 /// Constructor by edge and rigidity. Used to create group for line support
 /// </summary>
 internal Group(Geometry.FdCoordinateSystem coordSystem, Motions motions, MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, RotationsPlasticLimits rotationsPlasticLimits)
 {
     this.CoordinateSystem = coordSystem;
     this.Rigidity         = new RigidityDataType3(motions, motionsPlasticLimits, rotations, rotationsPlasticLimits);
 }
コード例 #19
0
 public TreeIconAttribute(FontAwesome5Solid icon, Rotations rotate = Rotations.None)
 {
     Icon   = icon;
     Rotate = rotate;
 }
コード例 #20
0
 /// <summary>
 /// Constructor by vectors and rigidity. Used to create group for point support
 /// </summary>
 public Group(Geometry.FdVector3d localX, Geometry.FdVector3d localY, Motions motions, Rotations rotations)
 {
     this._localX  = localX;
     this._localY  = localY;
     this.Rigidity = new RigidityDataType3(motions, rotations);
 }
コード例 #21
0
        /// <summary>
        /// Translate a physical direction to a logical direction based on the rotation given
        /// </summary>
        /// <param name="direction">Physical direction</param>
        /// <param name="rotation">Rotation</param>
        /// <returns>Logical direction</returns>
        private Directions GetDirectionTranslated(Directions direction, Rotations rotation)
        {
            Directions retVal = Directions.up;

            switch (direction)
            {
            case Directions.up:
                switch (rotation)
                {
                case Rotations.norotation:
                    retVal = Directions.up;
                    break;

                case Rotations.degrees90:
                    retVal = Directions.right;
                    break;

                case Rotations.degreesminus90:
                    retVal = Directions.left;
                    break;

                case Rotations.degrees180:
                    retVal = Directions.down;
                    break;
                }
                break;

            case Directions.down:
                switch (rotation)
                {
                case Rotations.norotation:
                    retVal = Directions.down;
                    break;

                case Rotations.degrees90:
                    retVal = Directions.left;
                    break;

                case Rotations.degreesminus90:
                    retVal = Directions.right;
                    break;

                case Rotations.degrees180:
                    retVal = Directions.up;
                    break;
                }
                break;

            case Directions.left:
                switch (rotation)
                {
                case Rotations.norotation:
                    retVal = Directions.left;
                    break;

                case Rotations.degrees90:
                    retVal = Directions.up;
                    break;

                case Rotations.degreesminus90:
                    retVal = Directions.down;
                    break;

                case Rotations.degrees180:
                    retVal = Directions.right;
                    break;
                }
                break;

            case Directions.right:
                switch (rotation)
                {
                case Rotations.norotation:
                    retVal = Directions.right;
                    break;

                case Rotations.degrees90:
                    retVal = Directions.down;
                    break;

                case Rotations.degreesminus90:
                    retVal = Directions.up;
                    break;

                case Rotations.degrees180:
                    retVal = Directions.left;
                    break;
                }
                break;
            }
            return(retVal);
        }
コード例 #22
0
        public static LineSupport Define(Autodesk.DesignScript.Geometry.Curve curve, Motions motions, [DefaultArgument("MotionsPlasticLimits.Default()")] MotionsPlasticLimits motionsPlasticLimits, Rotations rotations, [DefaultArgument("RotationsPlasticLimits.Default()")] RotationsPlasticLimits rotationsPlasticLimits, [DefaultArgument("false")] bool movingLocal, [DefaultArgument("Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0,0,0)")] Autodesk.DesignScript.Geometry.Vector localY, [DefaultArgument("true")] bool orientLCS, [DefaultArgument("S")] string identifier)
        {
            Geometry.Edge edge = Geometry.Edge.FromDynamoLineOrArc1(curve);
            FemDesign.Supports.LineSupport obj = new LineSupport(edge, motions, motionsPlasticLimits, rotations, rotationsPlasticLimits, movingLocal, identifier);

            // set local y-axis
            if (!localY.Equals(Autodesk.DesignScript.Geometry.Vector.ByCoordinates(0, 0, 0)))
            {
                obj.Group.LocalY = FemDesign.Geometry.FdVector3d.FromDynamo(localY);
            }

            // else orient coordinate system to GCS
            else
            {
                if (orientLCS)
                {
                    obj.Group.OrientCoordinateSystemToGCS();
                }
            }

            return(obj);
        }
コード例 #23
0
    /// <summary>
    /// Rotate the targetOrientation with the movement assigned by parameter.
    /// IMPORTANT--> This function does not rotate the camera, this is done in the update function
    /// </summary>
    /// <param name="rotationDirection"></param>
    public void RotateTo(Rotations rotationDirection)
    {
        GameManager.gManager.PlaySound("rotate");

        //If the camera if moving, return immediatly
        if (actualRotation != Rotations.stop)
        {
            return;
        }

        timer = 0;

        startRotation            = transform.rotation;
        targetTransform.rotation = transform.rotation;

        //Assign the new direction
        actualRotation = rotationDirection;

        Axes targetAxe = Axes.yNeg;
        bool clockwise = true;

        //Select the vertex to rotate
        switch (rotationDirection)
        {
        case Rotations.lLeft: targetAxe = Lateral; break;

        case Rotations.lRight: targetAxe = Lateral; break;

        case Rotations.dLeftUp: targetAxe = DiagonalLeft; break;

        case Rotations.dLeftDown: targetAxe = DiagonalLeft; break;

        case Rotations.dRightUp: targetAxe = DiagonalRight; break;

        case Rotations.dRightDown: targetAxe = DiagonalRight; break;
        }

        //Selet if going clockwise or counterclockwise
        if (targetAxe == Axes.yPos || targetAxe == Axes.xPos || targetAxe == Axes.zPos)
        {
            if (rotationDirection == Rotations.lLeft || rotationDirection == Rotations.dLeftUp || rotationDirection == Rotations.dRightDown)
            {
                clockwise = true;
            }
            else
            {
                clockwise = false;
            }
        }
        else
        {
            if (rotationDirection == Rotations.lLeft || rotationDirection == Rotations.dLeftUp || rotationDirection == Rotations.dRightDown)
            {
                clockwise = false;
            }
            else
            {
                clockwise = true;
            }
        }

        //Rotate 90 degrees de target rotation
        switch (targetAxe)
        {
        case Axes.yPos:
            if (clockwise)
            {
                targetTransform.RotateAround(transform.position, Vector3.up, -90);
            }
            else
            {
                targetTransform.RotateAround(transform.position, Vector3.up, 90);
            }
            break;

        case Axes.yNeg:
            if (clockwise)
            {
                targetTransform.RotateAround(transform.position, Vector3.up, -90);
            }
            else
            {
                targetTransform.RotateAround(transform.position, Vector3.up, 90);
            }
            break;

        case Axes.xPos:
            if (clockwise)
            {
                targetTransform.RotateAround(transform.position, Vector3.right, -90);
            }
            else
            {
                targetTransform.RotateAround(transform.position, Vector3.right, 90);
            }
            break;

        case Axes.xNeg:
            if (clockwise)
            {
                targetTransform.RotateAround(transform.position, Vector3.right, -90);
            }
            else
            {
                targetTransform.RotateAround(transform.position, Vector3.right, 90);
            }
            break;

        case Axes.zPos:
            if (clockwise)
            {
                targetTransform.RotateAround(transform.position, Vector3.forward, -90);
            }
            else
            {
                targetTransform.RotateAround(transform.position, Vector3.forward, 90);
            }
            break;

        case Axes.zNeg:
            if (clockwise)
            {
                targetTransform.RotateAround(transform.position, Vector3.forward, -90);
            }
            else
            {
                targetTransform.RotateAround(transform.position, Vector3.forward, 90);
            }
            break;
        }

        //Change the assigned axes for the next rotations
        if (Lateral != targetAxe)
        {
            Lateral = ChangeAxis(Lateral, targetAxe, clockwise);
        }
        if (DiagonalRight != targetAxe)
        {
            DiagonalRight = ChangeAxis(DiagonalRight, targetAxe, clockwise);
        }
        if (DiagonalLeft != targetAxe)
        {
            DiagonalLeft = ChangeAxis(DiagonalLeft, targetAxe, clockwise);
        }
    }
コード例 #24
0
ファイル: EngineCurve.cs プロジェクト: llenroc/SimTelemetry
        public static double GetTorque(double RPM, double throttle, double boost)
        {
            int BaseEngineCurve = 0x00ADD94C; // TODO: MAP TO SIMULATOR MAPPING

            // get engine torque figures (at this engine RPM)
            // this is directly from memory based engine curves.
            double Rads   = (RPM);
            double Th_L   = 0;
            double Th_H   = 0;
            double Tl_L   = 0;
            double Tl_H   = 0;
            double R_L    = 0;
            double R_H    = 0;
            int    offset = 0;

            double Th_Prev = 0;
            double Tl_Prev = 0;
            double R_Prev  = 0;
            bool   Cached  = ((DoubleList.Count <= 25) ? false : true);

            if (!Cached)
            {
                lock (rf)
                {
                    if (DoubleList.Count > 25)
                    {
                        return(0);
                    }
                    bool rfOpen = false;
                    try
                    {
                        rf.ReadProcess = Process.GetProcessesByName(Telemetry.m.Sim.ProcessName)[0];
                        rf.Open();
                        rfOpen = true;
                        DoubleList.Clear();
                        for (offset = 0; offset < 500; offset++)
                        {
                            double curve_rpm = 0, Tl_Now = 0, Th_Now = 0;
                            // read rpm
                            // TOOD: RFACTOR ONLY
                            // TODO: these operations need to be moved to game DLL's!!!
                            curve_rpm = Rotations.Rads_RPM(rf.ReadDouble(new IntPtr(BaseEngineCurve + 0x8 * 3 * offset)));
                            Tl_Now    = rf.ReadDouble(new IntPtr(BaseEngineCurve + 0x8 * 1 + 0x8 * 3 * offset));
                            Th_Now    = rf.ReadDouble(new IntPtr(BaseEngineCurve + 0x8 * 2 + 0x8 * 3 * offset));

                            DoubleList.Add(curve_rpm);
                            DoubleList.Add(Tl_Now);
                            DoubleList.Add(Th_Now);
                        }
                        Cached = true;
                        offset = 0;
                    }
                    catch (Exception ex)
                    {
                        Cached = false;
                        DoubleList.Clear();
                    }
                    if (rfOpen)
                    {
                        rf.Close();
                    }
                }
            }

            while (Th_H == 0)
            {
                double curve_rpm, Tl_Now, Th_Now;
                curve_rpm = DoubleList[offset * 3];
                Tl_Now    = DoubleList[offset * 3 + 1];
                Th_Now    = DoubleList[offset * 3 + 2];


                if (curve_rpm >= Rads)
                {
                    Th_L = Th_Prev;
                    Th_H = Th_Now;

                    Tl_L = Tl_Prev;
                    Tl_H = Tl_Now;


                    R_H = curve_rpm;
                    R_L = R_Prev;
                    break;
                }

                R_Prev  = curve_rpm;
                Th_Prev = Th_Now;
                Tl_Prev = Tl_Now;
                offset++;
            }
            if (Th_H == 0)
            {
            }
            // calculate duty cycle and determine torque.
            double RPM_Part = (Rads - R_L) / (R_H - R_L); // factor in rpm curve.
            double TorqueH  = Th_L + RPM_Part * (Th_H - Th_L);
            double TorqueL  = Tl_L + RPM_Part * (Tl_H - Tl_L);

            //return TorqueH * throttle * boost + TorqueL * boost;
            return((TorqueH - TorqueL) * throttle * boost + TorqueL);
        }
コード例 #25
0
ファイル: Program.cs プロジェクト: llenroc/TelemetryVideo
        private static void DrawSlimGauges(TelemetryLogReader read, double alpha, int frameNumber, Point positionGauge, double sample, double time, double laptime, Graphics g, double rpm_max, double rpm_redline)
        {
            var Brush_PedalsBackground = GetBrush(alpha, 255, 100, 100, 100);
            var Brush_PedalsBrake      = GetBrush(alpha, 255, 200, 0, 0);
            var Brush_PedalsThrottle   = GetBrush(alpha, 255, 0, 100, 0);
            var BrushWhite             = GetBrush(alpha, 255, 255, 255, 255);
            var BrushRed        = GetBrush(alpha, 255, 255, 0, 0);
            var BrushTime       = GetBrush(1, 255, 255, 255, 255);
            var BrushGray       = GetBrush(alpha, 255, 200, 200, 200);
            var BrushBackground = GetBrush(alpha, 150, 0, 0, 0);

            var GaugeWhite3 = new Pen(BrushWhite, 3.0f);
            var GaugeWhite2 = new Pen(BrushWhite, 2.0f);
            var GaugeWhite1 = new Pen(BrushWhite, 1.0f);

            double throttle = 0, brake = 0, rpm = 0, speed = 0, rpm_min = 0, redline = 0;
            int    gear = 0;

            try
            {
                throttle = read.GetDouble(sample, "Driver.Throttle");
                throttle = Math.Max(throttle, read.GetDouble(sample, "Player.Pedals_Throttle"));
                brake    = read.GetDouble(sample, "Player.Pedals_Brake");
                rpm      = Rotations.Rads_RPM(read.GetDouble(sample, "Driver.RPM"));
                gear     = (int)read.Get(sample, "Driver.Gear");
                gear     = Math.Max(gear, (int)read.Get(sample, "Player.Gear"));
                speed    = read.GetDouble(sample, "Driver.Speed") * 3.6;

                // TMP:
                if (rpm_max >= 16000)
                {
                    if (frameNumber <= 115)
                    {
                        gear = 7;
                    }
                }

                rpm_min = 4000;

                rpm_max = 1000 * Math.Ceiling(1.05 * rpm_max / 1000.0);
                redline = (rpm - 17000) / 1000.0;
                if (redline < 0)
                {
                    redline = 0;
                }
                if (redline > 1)
                {
                    redline = 1;
                }
            }
            catch (Exception ex)
            {
            }
            var BrushGear = GetBrush(alpha, 255, 255, 255 - Convert.ToInt32(redline * 200), 255 - Convert.ToInt32(redline * 200));

            /******* gear etc. ******/
            GraphicsSlow(g);

            g.DrawString(gear.ToString(), new Font("Tahoma", 36, FontStyle.Bold), BrushGear, positionGauge.X, positionGauge.Y + 160);
            g.DrawString(Math.Floor(speed).ToString("000"), new Font("Tahoma", 30, FontStyle.Bold), BrushWhite, positionGauge.X + 50, positionGauge.Y + 165);
            g.DrawString("kmh", new Font("Tahoma", 16), BrushWhite, positionGauge.X + 140, positionGauge.Y + 185);

            /******** LAPTIME *******/
            var tijd    = Math.Min(laptime / 1000.0, time / 1000.0);
            var minutes = (tijd - (tijd % 60)) / 60;
            var seconds = Math.Floor(tijd - minutes * 60);
            var mills   = (tijd % 1.0) * 1000;
            var txt     = String.Format("{0:00}:{1:00}.{2:000}", minutes, seconds, mills);

            g.DrawString(txt + (sample / 1000).ToString(" 000.00"), new Font("Tahoma", 40), BrushTime, positionGauge.X, positionGauge.Y + 235);

            /****** tacho meter******/
            var rpm_size = 300.0f;

            var rpmColor1a = GetBrush(alpha, 220, 100, 100, 100).Color;
            var rpmColor2a = GetBrush(alpha, 220, 240, 240, 240).Color;
            var rpmColor1b = GetBrush(alpha, 220, 100, 0, 0).Color;
            var rpmColor2b = GetBrush(alpha, 220, 255, 0, 0).Color;
            var rpm_brushA = new LinearGradientBrush(new Point(0, 0), new Point(0, 40), rpmColor1a, rpmColor2a);
            var rpm_brushB = new LinearGradientBrush(new Point(0, 0), new Point(0, 40), rpmColor1b, rpmColor2b);

            var rpm_redline_x = rpm_size * Convert.ToSingle((rpm_redline - rpm_min) / (rpm_max - rpm_min));

            for (int r = (int)(rpm_min / 1000); r <= (rpm_max) / 1000; r++)
            {
                var draw = true;

                if (rpm_max > 10000)
                {
                    if (r % 2 != 0)
                    {
                        draw = false;
                    }
                }
                var   br = (r >= rpm_redline / 1000) ? BrushRed : BrushWhite;
                float x  = Convert.ToSingle((r - rpm_min / 1000) * rpm_size / (rpm_max / 1000 - rpm_min / 1000));
                x += positionGauge.X + 200 + 140 + 30;
                if (draw)
                {
                    g.DrawString(r.ToString(), new Font("Tahoma", 14.0f), br,
                                 x - 7 - ((r.ToString().Length == 2) ? 7 : 0), positionGauge.Y * 1.0f + 160.0f);
                }
                g.DrawLine(new Pen(br, 1.0f), x, positionGauge.Y * 1.0f + 180.0f, x, positionGauge.Y * 1.0f + 190.0f);
            }
            g.FillRectangle(rpm_brushA, positionGauge.X + 200 + 140 + 30, positionGauge.Y * 1.0f + 190.0f,
                            Convert.ToSingle(Math.Min(rpm_redline_x, rpm_size * (rpm - rpm_min) / (rpm_max - rpm_min))), 20);
            if (rpm > rpm_redline)
            {
                g.FillRectangle(rpm_brushB, positionGauge.X + 200 + 140 + 30 + rpm_redline_x, positionGauge.Y * 1.0f + 190.0f,
                                Convert.ToSingle(rpm_size * (rpm - rpm_min) / (rpm_max - rpm_min)) - rpm_redline_x, 20);
            }

            /******** PEDALS ********/
            g.FillRectangle(Brush_PedalsBackground, positionGauge.X + 200, positionGauge.Y + 170, 140, 20);
            g.FillRectangle(Brush_PedalsThrottle, positionGauge.X + 200, positionGauge.Y + 170, Convert.ToInt32(throttle * 140), 20);
            g.DrawString("Throttle", new Font("Tahoma", 11.0f, FontStyle.Bold), BrushWhite, positionGauge.X + 237, positionGauge.Y + 170);

            g.FillRectangle(Brush_PedalsBackground, positionGauge.X + 200, positionGauge.Y + 190, 140, 20);
            g.FillRectangle(Brush_PedalsBrake, positionGauge.X + 200, positionGauge.Y + 190, Convert.ToInt32(brake * 140), 20);
            g.DrawString("Brake", new Font("Tahoma", 11.0f, FontStyle.Bold), BrushWhite, positionGauge.X + 247, positionGauge.Y + 190);
        }
コード例 #26
0
ファイル: DijNode.cs プロジェクト: Timwi/KtaneMarbleTumble
 public override string ToString()
 {
     return(string.Format("Rotations: {0}; Marble: {1}", Rotations.JoinString(", "), Marble));
 }
コード例 #27
0
ファイル: Program.cs プロジェクト: llenroc/TelemetryVideo
        private static void DrawGauges(TelemetryLogReader read, double alpha, int frameNumber, Point positionGauge, double sample, Graphics g, Image imgTrack, TrackThumbnail TrackThumbnail)
        {
            var Brush_PedalsBackground = GetBrush(alpha, 255, 100, 100, 100);
            var Brush_PedalsBrake      = GetBrush(alpha, 255, 200, 0, 0);
            var Brush_PedalsThrottle   = GetBrush(alpha, 255, 0, 100, 0);
            var BrushWhite             = GetBrush(alpha, 255, 255, 255, 255);
            var BrushTime       = GetBrush(1, 255, 255, 255, 255);
            var BrushGray       = GetBrush(alpha, 255, 200, 200, 200);
            var BrushBackground = GetBrush(alpha, 100, 0, 0, 0);

            var GaugeWhite3 = new Pen(BrushWhite, 3.0f);
            var GaugeWhite2 = new Pen(BrushWhite, 2.0f);
            var GaugeWhite1 = new Pen(BrushWhite, 1.0f);

            double throttle = 0, brake = 0, rpm = 0, speed = 0, rpm_max = 0, rpm_min = 0, redline = 0;
            object gear = 0;

            try
            {
                throttle = read.GetDouble(sample, "Driver.Throttle");
                brake    = read.GetDouble(sample, "Player.Pedals_Brake");
                rpm      = Rotations.Rads_RPM(read.GetDouble(sample, "Driver.RPM"));
                gear     = read.Get(sample, "Driver.Gear");
                speed    = read.GetDouble(sample, "Driver.Speed") * 3.6;

                rpm_max = 18000;
                rpm_min = 6000;

                rpm_max = 1000 * Math.Ceiling(1.05 * rpm_max / 1000.0);
                redline = (rpm - 17000) / 1000.0;
                if (redline < 0)
                {
                    redline = 0;
                }
                if (redline > 1)
                {
                    redline = 1;
                }
            }
            catch (Exception ex)
            {
            }
            var BrushGear = GetBrush(alpha, 255, 255, 255 - Convert.ToInt32(redline * 200), 255 - Convert.ToInt32(redline * 200));

            /******** SPEEDO etc ********/

            g.DrawString(Math.Round(speed).ToString("000"), new Font("Tahoma", 36, FontStyle.Bold), BrushWhite, positionGauge.X + 200 - 50, positionGauge.Y + 200 + 35);
            g.DrawString("km/h", new Font("Tahoma", 14), BrushWhite, positionGauge.X + 200 - 20, positionGauge.Y + 200 + 90);

            g.DrawString(gear.ToString(), new Font("Tahoma", 48), BrushGear, positionGauge.X + 200 + 30, positionGauge.Y + 200 + 110);

            /******** LAPTIME *******/
            var tijd    = sample / 1000.0;
            var minutes = (tijd - (tijd % 60)) / 60;
            var seconds = Math.Floor(tijd - minutes * 60);
            var mills   = (tijd % 1.0) * 1000;
            var txt     = String.Format("{0:00}:{1:00}.{2:000}", minutes, seconds, mills);

            g.DrawString(txt, new Font("Tahoma", 48), BrushTime, positionGauge.X + 50, positionGauge.Y + 450);

            /******** RPM GAUGE ********/
            g.FillEllipse(BrushBackground, positionGauge.X, positionGauge.Y, 400, 400);
            g.DrawArc(GaugeWhite1, positionGauge.X + 45, positionGauge.Y + 45, 310, 310, 90, 270);
            g.DrawArc(GaugeWhite1, positionGauge.X + 50, positionGauge.Y + 50, 300, 300, 90, 270);
            g.DrawArc(GaugeWhite3, positionGauge.X + 55, positionGauge.Y + 55, 290, 290, 90, 270);

            for (int r = (int)(rpm_min / 1000); r <= (rpm_max) / 1000; r++)
            {
                var angle = (r * 1000 - rpm_min) / (rpm_max - rpm_min);
                angle *= 270;
                angle += 90;
                angle *= Math.PI;
                angle /= 180;
                var x1 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle) * 155.0f;
                var y1 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle) * 155.0f;

                var x2 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle) * 165.0f;
                var y2 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle) * 165.0f;

                var x3 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle) * 180.0f;
                var y3 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle) * 180.0f;

                g.DrawLine(GaugeWhite2, x1, y1, x2, y2);

                x3 -= 14;
                y3 -= 12;

                g.DrawString(r.ToString(), new Font("Tahoma", 16.0f, FontStyle.Bold), BrushWhite, x3, y3);
            }

            // NEEDLE
            g.FillEllipse(BrushWhite, positionGauge.X + 400 / 2 - 15, positionGauge.Y + 400 / 2 - 15, 30, 30);

            var angle_needle = 90 + 270 * (rpm - rpm_min) / (rpm_max - rpm_min);

            angle_needle *= Math.PI;
            angle_needle /= 180;

            // Tip of needle
            var nx1 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle) * 155.0f;
            var ny1 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle) * 155.0f;
            // Tip of needle
            var nx1a = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle - 0.5 / 180.0 * Math.PI) * 155.0f;
            var ny1a = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle - 0.5 / 180.0 * Math.PI) * 155.0f;

            // Tip of needle
            var nx1b = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle + 0.5 / 180.0 * Math.PI) * 155.0f;
            var ny1b = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle + 0.5 / 180.0 * Math.PI) * 155.0f;

            // Back (white)
            var nx2a = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle + 25.0 / 180 * Math.PI) * -25.0f;
            var ny2a = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle + 25.0 / 180 * Math.PI) * -25.0f;

            // Back (gray)
            var nx2b = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle - 25.0 / 180 * Math.PI) * -25.0f;
            var ny2b = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle - 25.0 / 180 * Math.PI) * -25.0f;

            // Middle (white)
            var nx3 = positionGauge.X + 400.0f / 2 + (float)Math.Cos(angle_needle) * -17.0f;
            var ny3 = positionGauge.Y + 400.0f / 2 + (float)Math.Sin(angle_needle) * -17.0f;

            var arr = new[] { new PointF(nx1, ny1), new PointF(nx1b, ny1b), new PointF(nx2b, ny2b), new PointF(nx3, ny3) };

            g.FillPolygon(BrushGray, arr);
            arr = new[] { new PointF(nx1, ny1), new PointF(nx1a, ny1a), new PointF(nx2a, ny2a), new PointF(nx3, ny3) };
            g.FillPolygon(BrushWhite, arr);

            /******** PEDALS ********/

            g.FillRectangle(Brush_PedalsBackground, positionGauge.X + 260, positionGauge.Y + 220, 140, 30);
            g.FillRectangle(Brush_PedalsThrottle, positionGauge.X + 260, positionGauge.Y + 220, Convert.ToInt32(throttle * 140), 30);
            g.DrawString("Throttle", new Font("Tahoma", 14.0f, FontStyle.Bold), BrushWhite, positionGauge.X + 290, positionGauge.Y + 225);

            g.FillRectangle(Brush_PedalsBackground, positionGauge.X + 260, positionGauge.Y + 260, 140, 30);
            g.FillRectangle(Brush_PedalsBrake, positionGauge.X + 260, positionGauge.Y + 260, Convert.ToInt32(brake * 140), 30);
            g.DrawString("Brake", new Font("Tahoma", 14.0f, FontStyle.Bold), BrushWhite, positionGauge.X + 302, positionGauge.Y + 265);
        }
コード例 #28
0
    public void States()
    {
        switch (info.npcStates)
        {
        case NPCStates.Idle:
            goto Ideling;

        case NPCStates.Moving:
            goto Move;

        case NPCStates.Rotating:
            goto Rotate;

        default:
            break;
        }

Ideling:
        if (reaction == false)
        {
            stateTimer -= Time.deltaTime;
            //Debug.Log("idle");
            if (stateTimer < 0.0f)
            {
                info.npcStates = (NPCStates)Random.Range(0, 3);
                rotations      = (Rotations)Random.Range(0, 2);
                stateTimer     = 3.0f;
            }
        }
        return;

Move:
        if (reaction == false)
        {
            stateTimer -= Time.deltaTime;
            rb.transform.Translate(Vector3.forward * info.movSpeed * Time.fixedDeltaTime); // Front movement
            //Debug.Log("move");
            if (stateTimer < 0.0f)
            {
                info.npcStates = (NPCStates)Random.Range(0, 3);
                rotations      = (Rotations)Random.Range(0, 2);
                stateTimer     = 3.0f;
            }
        }
        return;

Rotate:
        if (reaction == false)
        {
            stateTimer -= Time.deltaTime;

            Rotation();
            if (stateTimer < 0.0f)
            {
                info.npcStates = (NPCStates)Random.Range(0, 3);
                rotations      = (Rotations)Random.Range(0, 2);
                stateTimer     = 3.0f;
            }
        }
        return;
    }
コード例 #29
0
 public void RotationChanged(Rotations rotation)
 {
     RenderTargetManager.CorrentRotation = rotation;
 }
コード例 #30
0
 public static Image Rotate(Image Img, Rotations Rotation)
 {
     //TODO implement Rotate
     return Img;
 }
コード例 #31
0
ファイル: PDFActions.cs プロジェクト: handanlinzhang/pdfrider
        /// <summary>
        /// Rotates pages from a pdf file and saves them into a new file.
        /// </summary>
        /// <param name="pageStart">First page to rotate</param>
        /// <param name="pageEnd">Last page to rotate</param>
        /// <param name="interval">Page interval (all, even, odd)</param>
        /// <param name="rotation">Rotation type</param>
        /// <param name="outputFileName">Path of the new file</param>
        /// <returns></returns>
        public OperationStates RotatePages(PDFDocument document, int pageStart, int pageEnd, PageIntervals interval,
            Rotations rotation, ref string outputFileName)
        {
            OperationStates state = OperationStates.Ok;

            if ((pageStart < 1) || (pageStart > document.NumberOfPages) ||
                (pageEnd < 1) || (pageEnd > document.NumberOfPages))
            {
                state = OperationStates.PageRangeOutOfDocument;
                return state;
            }

            string s_rotation = "";
            switch (rotation)
            {
                case Rotations.North:
                    s_rotation += "N";
                    break;
                case Rotations.South:
                    s_rotation += "S";
                    break;
                case Rotations.East:
                    s_rotation += "E";
                    break;
                case Rotations.West:
                    s_rotation += "W";
                    break;
                case Rotations.Left:
                    s_rotation += "L";
                    break;
                case Rotations.Right:
                    s_rotation += "R";
                    break;
                case Rotations.Down:
                    s_rotation += "D";
                    break;
            }

            string range = "";

            if (pageStart > 1)
            {
                range += "1-" + (pageStart - 1).ToString() + " ";
            }

            /* pdftk rotates the pages using the "cat" option, which catenates pages from a pdf
             * into another pdf file. If I specify an odd or even range (e.g. 1-10odd) only odd
             * or even pages within that range are catenated in the output file, but that's not
             * what I want. I need ALL pages to be present in the new file and only odd or even
             * pages be rotated. To achieve this I need to break the interval like below. */
            switch (interval)
            {
                case PageIntervals.Even:
                    for (int i = pageStart; i <= pageEnd; i++)
                    {
                        range += i.ToString();
                        range += (i % 2 == 0) ? s_rotation + " " : " ";
                    }
                    break;
                case PageIntervals.Odd:
                    for (int i = pageStart; i <= pageEnd; i++)
                    {
                        range += i.ToString();
                        range += (i % 2 != 0) ? s_rotation + " " : " ";
                    }
                    break;
                case PageIntervals.All:
                    for (int i = pageStart; i <= pageEnd; i++)
                    {
                        range += i.ToString() + s_rotation + " ";
                    }
                    break;
            }

            if (pageEnd < document.NumberOfPages)
            {
                range += " " + (pageEnd + 1).ToString() + "-" + document.NumberOfPages.ToString();
            }

            GetValidOutputFileName(ref outputFileName, 1);

            string args = "\"" + document.FullName + "\" cat " +
                range + " output \"" + outputFileName + "\"";

            RunPdftk(args);

            return state;
        }