/// <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); }
/// <summary> /// Moves the figure based a sinusoidal translation. Creates a /// "wave" like movement. Rotates the figure during this translation /// in the around the y-axis. /// </summary> /// <param name="fig"> the figure doing the movement </param> public override void Move(Figure fig) { float trans_x = (float)(xDir * DIST); float trans_z = -(float)(xDir * DIST); float trans_y = (float)Math.Sin(x) * Y_DIST; x += trans_x; if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0)) { xDir *= -1; } fig.Translate(new Vector3(trans_x, trans_y, trans_z)); fig.RotateY(ROT_Y); }
/// <summary> /// Moves the figure based a sinusoidal translation. Creates a /// "wave" like movement. Rotates the figure during this translation /// in the around the y-axis. /// </summary> /// <param name="fig"> the figure doing the movement </param> public override void Move(Figure fig) { float trans_x = (float)(xDir * DIST); float trans_z = -(float)(xDir * DIST); float trans_y = (float)Math.Sin(x) * Y_DIST; x += trans_x; if ((x >= LIMIT && xDir > 0) || (x < 0 && xDir < 0)) xDir *= -1; fig.Translate(new Vector3(trans_x, trans_y, trans_z)); fig.RotateY(ROT_Y); }
/// <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); }