예제 #1
0
        /// <summary>
        /// Moves the figure based on the randomly generated translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in each direction. Translates and
        /// Rotates in all 3 axes.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_x = (float)(rand.NextDouble()) * xDir * TRANS_MULT;
            float trans_y = (float)(rand.NextDouble()) * yDir * TRANS_MULT;
            float trans_z = (float)(rand.NextDouble()) * zDir * TRANS_MULT;

            x += trans_x;
            y += trans_y;
            z += trans_z;
            if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0))
            {
                xDir *= -1;
            }
            if ((y >= LIMIT && yDir > 0) || (y < 0 && yDir < 0))
            {
                yDir *= -1;
            }
            if ((z >= LIMIT && zDir > 0) || (z < 0 && zDir < 0))
            {
                zDir *= -1;
            }

            fig.Translate(new Vector3(trans_x, trans_y, trans_z));

            float rot_x = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
            float rot_y = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
            float rot_z = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;

            fig.RotateX(rot_x);
            fig.RotateY(rot_y);
            fig.RotateZ(rot_z);
        }
예제 #2
0
        /// <summary>
        /// Moves the figure based on the fixed translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in both y and z directions. Translates
        /// in the y and z directions, leaving x intact. Rotates around the
        /// x-axis.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_y = (float)(y_dir * DIST);
            float trans_z = (float)(z_dir * DIST);

            y += trans_y;
            z += trans_z;
            if ((y >= LIMIT && y_dir > 0) || (y < 0 && y_dir < 0))
            {
                y_dir *= -1;
            }
            if ((z >= LIMIT && z_dir > 0) || (z < 0 && z_dir < 0))
            {
                z_dir *= -1;
            }

            fig.Translate(new Vector3(0.0f, trans_y, trans_z));
            fig.RotateX(ROTATE);
        }
예제 #3
0
        /// <summary>
        /// Moves the figure based on the fixed translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in both y and z directions. Translates 
        /// in the y and z directions, leaving x intact. Rotates around the 
        /// x-axis.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_y = (float)(y_dir * DIST);
             float trans_z = (float)(z_dir * DIST);

             y += trans_y;
             z += trans_z;
             if ((y >= LIMIT && y_dir > 0) || (y < 0 && y_dir < 0))
            y_dir *= -1;
             if ((z >= LIMIT && z_dir > 0) || (z < 0 && z_dir < 0))
            z_dir *= -1;

             fig.Translate(new Vector3(0.0f, trans_y, trans_z));
             fig.RotateX(ROTATE);
        }
예제 #4
0
        /// <summary>
        /// Moves the figure based on the randomly generated translation and
        /// rotation amounts. Uses a limit for the translations to keep the
        /// figure within a certain bound in each direction. Translates and
        /// Rotates in all 3 axes.
        /// </summary>
        /// <param name="fig"> the figure doing the movement </param>
        public override void Move(Figure fig)
        {
            float trans_x = (float)(rand.NextDouble()) * xDir * TRANS_MULT;
             float trans_y = (float)(rand.NextDouble()) * yDir * TRANS_MULT;
             float trans_z = (float)(rand.NextDouble()) * zDir * TRANS_MULT;

             x += trans_x;
             y += trans_y;
             z += trans_z;
             if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0))
            xDir *= -1;
             if ((y >= LIMIT && yDir > 0) || (y < 0 && yDir < 0))
            yDir *= -1;
             if ((z >= LIMIT && zDir > 0) || (z < 0 && zDir < 0))
            zDir *= -1;

             fig.Translate(new Vector3(trans_x, trans_y, trans_z));

             float rot_x = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
             float rot_y = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;
             float rot_z = ((float)(rand.NextDouble()) - 0.5f) * ROT_MULT;

             fig.RotateX(rot_x);
             fig.RotateY(rot_y);
             fig.RotateZ(rot_z);
        }