/// <summary> /// Create a state vector x_v from its component parts. Puts the matrices r, q, v, omega into their right places. /// </summary> /// <param name="r"></param> /// <param name="q"></param> /// <param name="v"></param> /// <param name="omega"></param> /// <param name="xv"></param> public void compose_xv(ref Vector3D r, ref Quaternion q, ref Vector3D v, ref Vector3D omega, ref Vector xv) { xv.Update(r.GetVNL3(), 0); xv.Update(q.GetRXYZ(), 3); xv.Update(v.GetVNL3(), 7); xv.Update(omega.GetVNL3(), 10); }
public void UpdateSuccess() { var Old = new car() { UniqueId = 10, odometer = 1000, year = 2000, price = 5000 }; _cars.Plot(Old, out uniqueOut); car New = _cars.Get(uniqueOut) as car; New.price = 4500; Assert.IsTrue(_cars.Update(In: New)); Assert.AreEqual(uniqueOut, _cars.Get(uniqueOut).UniqueId); }
public void Update(GameTime gameTime) { if (CurrentAnimation != null) { Position.Update(X, Y); Bounds = new Rectangle(X, Y, CurrentAnimation.FrameWidth, CurrentAnimation.FrameHeight); CurrentAnimation.Update(gameTime); } }
public override void Update() { switch (m_State) { case ControlState.none: break; case ControlState.SetHardware: hardware.Update(); if (hardware.State == Hardware.HardwareState.Actionable) { m_State = ControlState.SetVector; } break; case ControlState.SetVector: hardware.Update(); vector.Update(hardware); if (vector.Procedure == Vector.SettingProcedure.Completed) { m_State = ControlState.Wait; DisplayActuatorVector(); } break; case ControlState.Wait: break; case ControlState.SetMotionProfile: motionProfile.Update(vector.TargetLenghsOfActuator); if (motionProfile.State == MotionProfile.MotionState.CompletedMotionProfile) { DisplayMotionProfileGraph(); m_State = ControlState.Actionable; } break; case ControlState.Actionable: break; } }
public Damager(int id, int direction, Entity source) { if (id == 0) { Vector sDir = source.gameObject.direction; Vector dir = new Vector(0, 0, 2); if (direction == 1) { dir.Update(sDir.r, sDir.c); } else if (direction == 2) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(1, -1); } else { dir.Update(-1, 1); } } else { if (sDir.c > 0) { dir.Update(1, 1); } else { dir.Update(-1, -1); } } } else if (direction == 3) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(1, 1); } else { dir.Update(-1, -1); } } else { if (sDir.c > 0) { dir.Update(-1, 1); } else { dir.Update(1, -1); } } } else if (direction == 4) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(0, -1); } else { dir.Update(0, 1); } } else { if (sDir.c > 0) { dir.Update(1, 0); } else { dir.Update(-1, 0); } } } else if (direction == 5) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(0, 1); } else { dir.Update(0, -1); } } else { if (sDir.c > 0) { dir.Update(-1, 0); } else { dir.Update(1, 0); } } } else if (direction == 6) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(-1, -1); } else { dir.Update(1, 1); } } else { if (sDir.c > 0) { dir.Update(1, -1); } else { dir.Update(-1, 1); } } } else if (direction == 7) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(-1, 1); } else { dir.Update(1, -1); } } else { if (sDir.c > 0) { dir.Update(-1, -1); } else { dir.Update(1, 1); } } } else if (direction == 8) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(-1, 0); } else { dir.Update(1, 0); } } else { if (sDir.c > 0) { dir.Update(0, -1); } else { dir.Update(0, 1); } } } else if (direction == 9) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(2, -1, 1); } else { dir.Update(-2, 1, 1); } } else { if (sDir.c > 0) { dir.Update(1, 2, 1); } else { dir.Update(-1, -2, 1); } } } else if (direction == 10) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(2, 1, 1); } else { dir.Update(-2, -1, 1); } } else { if (sDir.c > 0) { dir.Update(-1, 2, 1); } else { dir.Update(1, -2, 1); } } } else if (direction == 11) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(1, -2, 1); } else { dir.Update(-1, 2, 1); } } else { if (sDir.c > 0) { dir.Update(2, 1, 1); } else { dir.Update(-2, -1, 1); } } } else if (direction == 12) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(1, 2, 1); } else { dir.Update(-1, -2, 1); } } else { if (sDir.c > 0) { dir.Update(-2, 1, 1); } else { dir.Update(2, -1, 1); } } } else if (direction == 13) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(-1, -2, 1); } else { dir.Update(1, 2, 1); } } else { if (sDir.c > 0) { dir.Update(2, -1, 1); } else { dir.Update(-2, 1, 1); } } } else if (direction == 14) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(-1, 2, 1); } else { dir.Update(1, -2, 1); } } else { if (sDir.c > 0) { dir.Update(-2, -1, 1); } else { dir.Update(2, 1, 1); } } } else if (direction == 15) { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(-2, -1, 1); } else { dir.Update(2, 1, 1); } } else { if (sDir.c > 0) { dir.Update(1, -2, 1); } else { dir.Update(-1, 2, 1); } } } else { if (Math.Abs(sDir.r) > Math.Abs(sDir.c)) { if (sDir.r > 0) { dir.Update(-2, 1, 1); } else { dir.Update(2, -1, 1); } } else { if (sDir.c > 0) { dir.Update(-1, -2, 1); } else { dir.Update(1, 2, 1); } } } gameObject = new GameObject(2, new Position(source.gameObject.position.r + dir.r, source.gameObject.position.c + dir.c), "* ", 0, 15); gameObject.ChangeDirection(dir); lifeSpan = source.range * 2; } else { gameObject = new GameObject(3, source.gameObject.position, "/\\", 0, 8); lifeSpan = source.trail; } damage = source.damage; durability = source.piercing; alignment = source.alignment; }
public void Update(GameTime gameTime) { if (CurrentAnimation != null) { Position.Update(X, Y); if (MoveRoute && Alive) { switch (Route.Type) { case RouteType.Horizontal: if (X >= Route.XF) { State = 2; } if (X < Route.X) { State = 1; } if (State == 1) { CurrentAnimation = Animations[1]; CurrentAnimation.IsFliped = false; X += 5; } else if (State == 2) { CurrentAnimation = Animations[1]; CurrentAnimation.IsFliped = true; X -= 5; } break; case RouteType.Vertical: if (Y >= Route.YF) { State = 2; } if (Y < Route.Y) { State = 1; } if (State == 1) { CurrentAnimation = Animations[3]; Y += 5; } else if (State == 2) { CurrentAnimation = Animations[2]; Y -= 5; } break; } } Bounds = new Rectangle(X, Y, CurrentAnimation.FrameWidth, CurrentAnimation.FrameHeight); CurrentAnimation.Update(gameTime); } if (Alive == false) { Effect.Update(gameTime); } }
// Function to find a region in an image guided by current motion prediction // which doesn't overlap existing features public static bool FindNonOverlappingRegion(Scene_Single scene, Vector local_u, float delta_t, Partially_Initialised_Feature_Measurement_Model default_feature_type_for_initialisation, uint camera_width, uint camera_height, uint BOXSIZE, ref int init_feature_search_ustart, ref int init_feature_search_vstart, ref int init_feature_search_ufinish, ref int init_feature_search_vfinish, uint FEATURE_INIT_STEPS_TO_PREDICT, float FEATURE_INIT_DEPTH_HYPOTHESIS, Random rnd) { ThreeD_Motion_Model threed_motion_model = (ThreeD_Motion_Model)scene.get_motion_model(); Vector local_xv = new Vector(scene.get_xv()); for (uint i = 0; i < FEATURE_INIT_STEPS_TO_PREDICT; i++) { scene.get_motion_model().func_fv_and_dfv_by_dxv(local_xv, local_u, delta_t); local_xv.Update(scene.get_motion_model().get_fvRES()); } threed_motion_model.func_xp(local_xv); Vector local_xp = new Vector(threed_motion_model.get_xpRES()); threed_motion_model.func_r(local_xp); Vector3D rW = threed_motion_model.get_rRES(); threed_motion_model.func_q(local_xp); Quaternion qWR = threed_motion_model.get_qRES(); // yW = rW + RWR hR Vector3D hR = new Vector3D(0.0f, 0.0f, FEATURE_INIT_DEPTH_HYPOTHESIS); // Used Inverse + transpose because this was't compiling the normal way Vector3D yW = new Vector3D(rW + qWR.RotationMatrix() * hR); // Then project that point into the current camera position scene.get_motion_model().func_xp(scene.get_xv()); Fully_Initialised_Feature_Measurement_Model fully_init_fmm = (Fully_Initialised_Feature_Measurement_Model)(default_feature_type_for_initialisation.more_initialised_feature_measurement_model); Vector yWVNL = yW.GetVNL3(); fully_init_fmm.func_hi_and_dhi_by_dxp_and_dhi_by_dyi(yWVNL, scene.get_motion_model().get_xpRES()); // Now, this defines roughly how much we expect a feature initialised to move float suggested_u = fully_init_fmm.get_hiRES()[0]; float suggested_v = fully_init_fmm.get_hiRES()[1]; float predicted_motion_u = camera_width / 2.0f - suggested_u; float predicted_motion_v = camera_height / 2.0f - suggested_v; // So, the limits of a "safe" region within which we can initialise // features so that they end up staying within the screen // (Making the approximation that the whole screen moves like the // centre point) int safe_feature_search_ustart = (int)(-predicted_motion_u); int safe_feature_search_vstart = (int)(-predicted_motion_v); int safe_feature_search_ufinish = (int)(camera_width - predicted_motion_u); int safe_feature_search_vfinish = (int)(camera_height - predicted_motion_v); if (safe_feature_search_ustart < ((int)((BOXSIZE - 1) / 2) + 1)) { safe_feature_search_ustart = (int)((BOXSIZE - 1) / 2 + 1); } if (safe_feature_search_ufinish > (int)camera_width - ((int)((BOXSIZE - 1) / 2) + 1)) { safe_feature_search_ufinish = (int)(camera_width - (BOXSIZE - 1) / 2 - 1); } if (safe_feature_search_vstart < ((int)((BOXSIZE - 1) / 2) + 1)) { safe_feature_search_vstart = (int)((BOXSIZE - 1) / 2 + 1); } if (safe_feature_search_vfinish > (int)camera_height - ((int)((BOXSIZE - 1) / 2) + 1)) { safe_feature_search_vfinish = (int)(camera_height - (BOXSIZE - 1) / 2 - 1); } return(FindNonOverlappingRegionNoPredict(safe_feature_search_ustart, safe_feature_search_vstart, safe_feature_search_ufinish, safe_feature_search_vfinish, scene, ref init_feature_search_ustart, ref init_feature_search_vstart, ref init_feature_search_ufinish, ref init_feature_search_vfinish, rnd)); }
public void Update(GameTime gameTime) { if (CurrentAnimation != null) { switch (State) { case 0: //Idle //Cursor = MoveCursor; CurrentAnimation = Animations[0]; break; case 1: //Move //Cursor = MoveCursor; if (RightPress == true) { //P1 Move right CurrentAnimation = Animations[1]; CurrentAnimation.IsFliped = false; X += 3; } else if (LeftPress == true) { //P1 Move left CurrentAnimation = Animations[1]; CurrentAnimation.IsFliped = true; X -= 3; } else if (UpPress == true) { //P1 Move up CurrentAnimation = Animations[2]; CurrentAnimation.IsFliped = false; Y -= 3; } else if (DownPress == true) { //P1 Move down CurrentAnimation = Animations[3]; CurrentAnimation.IsFliped = false; Y += 3; } break; case 2: //Shoot //Cursor = Player.Cursor; CurrentAnimation = Animations[5]; break; } Position.Update(X, Y); Bounds = new Rectangle(X, Y, CurrentAnimation.FrameWidth, CurrentAnimation.FrameHeight); CurrentAnimation.Update(gameTime); FieldView.SetPoints((int)Position.X + CurrentAnimation.FrameWidth, (int)Position.Y); } if (Action) { Effect.Update(gameTime); } }