public ConvertFilter(ITransponderReceiver receiver, ICompassCourse compassCourse, IVelocity velocity) { this._receiver = receiver; this._compassCourse = compassCourse; this._volocity = velocity; this._receiver.TransponderDataReady += ReceiverOnTransponderDataReady; }
/// <summary> /// Sets state /// </summary> /// <param name="baseFrame">Base frame</param> /// <param name="relative">Relative frame</param> public override void Set(ReferenceFrame baseFrame, ReferenceFrame relative) { base.Set(baseFrame, relative); IOrientation bo = baseFrame as IOrientation; IOrientation ro = relative as IOrientation; IVelocity bv = baseFrame as IVelocity; IVelocity rv = relative as IVelocity; IAngularVelocity oa = baseFrame as IAngularVelocity; IAngularVelocity ra = relative as IAngularVelocity; double[] vb = bv.Velocity; double[] vr = rv.Velocity; double[,] mb = bo.Matrix; double[,] m = ro.Matrix; double[] om = oa.Omega; double[] pos = relative.Position; Vector3D.StaticExtensionVector3D.VectorPoduct(om, pos, hv); for (int i = 0; i < 3; i++) { velocity[i] = vb[i]; for (int j = 0; j < 3; j++) { velocity[i] += mb[i, j] * (vr[j] + hv[j]); } } }
public float CheckGround() { if (jumpGroundCheckCooldown > Time.time - jumpedAt) { return(float.MaxValue); } Vector2[] origins = GetGroundCheckOrigins(); float distance = float.MaxValue; RaycastHit2D hit; foreach (var o in origins) { hit = Physics2D.Raycast(o, Vector2.down, groundCheckDistance, groundCheckMask); Debug.DrawRay(o, Vector3.down * groundCheckDistance); if (hit.transform != null && hit.distance < distance) { distance = hit.distance; groundVelocityReference = hit.collider.GetComponent <IVelocity>(); } } if (distance <= groundCheckDistance) { isGrounded = true; } else { isGrounded = false; groundVelocityReference = null; } return(distance); }
public void Setup() { _fakereceiver = Substitute.For <ITransponderReceiver>(); _fakevelocity = Substitute.For <IVelocity>(); _fakecompassCourse = Substitute.For <ICompassCourse>(); _uut = new ConvertFilter(_fakereceiver, _fakecompassCourse, _fakevelocity); }
public void Setup() { _uut = new Course(); _newTracks = new List <ITrackObject>(); _velocity = Substitute.For <IVelocity>(); _separation = Substitute.For <ISeparation>(); _distance = Substitute.For <IDistance>(); _listHandler = new ListHandler(_velocity, _uut, _separation, _distance); }
void IStarted.Start(double time) { double[] state = aggregate.State; Array.Copy(state, relative.Position, 3); IVelocity v = relative; Array.Copy(state, 3, v.Velocity, 0, 3); Array.Copy(state, 6, relative.Quaternion, 0, 4); IAngularVelocity av = relative; Array.Copy(state, 10, av.Omega, 0, 3); }
public ListHandler( IVelocity vel, ICourse cou, ISeparation separation, IDistance distance) { CurrentTracks = new List <ITrackObject>(); _velocity = vel; _course = cou; _separation = separation; _distance = distance; }
public void Setup() { _position = Substitute.For <IPosition>(); _inDateTime = new DateTime(); _uut = new TrackObject("123ABC", _position, "20181111111111111", _inDateTime); _newTracks = new List <ITrackObject>(); _velocity = Substitute.For <IVelocity>(); _course = Substitute.For <ICourse>(); _separation = Substitute.For <ISeparation>(); _distance = Substitute.For <IDistance>(); _listHandler = new ListHandler(_velocity, _course, _separation, _distance); }
public void Setup() { _testCalculateVelocity = new Velocity(); _distance = new Distance(); /**************************** * // THIS MUST BE SUB - NEED FIX - ELSE OK *****************************/ _oldObj = Substitute.For <ITrackObject>(); _newObj = Substitute.For <ITrackObject>(); }
/// <summary> /// Initialization of prediction /// </summary> public void InitializePrediction(double forecastTime) { if (!(frame is IVelocity)) { throw new Exception("Frame does not support velocity"); } if (!(frame is IAngularVelocity)) { throw new Exception("Frame does not support angular velocity"); } velocity = frame as IVelocity; angularVelocity = frame as IAngularVelocity; }
/* private object sd() * { * return result[9, 1]; * } * * private object md() * { * return result[10, 1]; * } * * private object nd() * { * return result[11, 1]; * } * * private object od() * { * return result[12, 1]; * } * * private object ld() * { * return result[13, 1]; * }*/ #endregion private void SetRelative() { ReferenceFrame relative = Relative; Array.Copy(relativePosition, relative.Position, 3); IVelocity v = relative as IVelocity; // Array.Copy(relativeVelocity, v.RevativeVelocity, 3); Array.Copy(relativeQuaternion, relative.Quaternion, 3); IOrientation or = relative as IOrientation; Array.Copy(relativeQuaternion, or.Quaternion, 4); relative.SetMatrix(); }
/// <summary> /// Sets aliases /// </summary> private void SetAliases() { ReferenceFrame own = Own; IVelocity v = own as IVelocity; IOrientation o = own as IOrientation; IAngularVelocity av = own as IAngularVelocity; aln.SetAliases(0, own.Position, 0, 3); aln.SetAliases(3, v.Velocity, 0, 3); aln.SetAliases(6, o.Quaternion, 0, 4); aln.SetAliases(10, av.Omega, 0, 3); aln.SetAliases(13, relativeVelocity, 0, 3); aln.SetAliases(16, omega, 0, 3); }
bool CreateConside() { if (!(target is IReferenceFrame)) { if (target is IPosition) { UpdateAll = UpdateCoinDistance; measurements = new IMeasurement[] { new Measurement(GetDistance, names[3]) }; } return(false); } IReferenceFrame f = target as IReferenceFrame; ReferenceFrame o = f.Own; ReferenceFrame p = ReferenceFrame.GetOwnFrame(source); if (p == o) { return(false); } UpdateAll = UpdateCoinDistance; if ((source is IVelocity) & (target is IVelocity)) { vSource = source as IVelocity; UpdateAll += UpdateCoinVelocity; } if (oTarget != null) { UpdateAll += UpdateOrientationCoordinates; } if (oTarget != null) { UpdateAll += UpdateOrientationVelocity; } if (aTarget != null) { UpdateAll += AddAngularVelocity; } if ((oSource != null) & (oTarget != null)) { UpdateAll += UpdateQuaternion; } return(true); }
private void PostCreateFrame() { try { frame = this.GetFrame(); acc = frame.GetSimpleObject <IAcceleration>("Object should have acceleration"); angvel = frame.GetSimpleObject <IAngularVelocity>("Object should have angular velocity"); vel = frame.GetSimpleObject <IVelocity>("Object should have velocity"); angacc = frame.GetSimpleObject <IAngularAcceleration>("Object should have angular acceleration"); } catch (Exception e) { e.ShowError(10); IPosition p = this; p.Parent = null; throw e; } }
/// <summary> /// Sets state /// </summary> /// <param name="baseFrame">Base frame</param> /// <param name="relative">Relative frame</param> public override void Set(ReferenceFrame baseFrame, ReferenceFrame relative) { base.Set(baseFrame, relative); IAcceleration ab = baseFrame as IAcceleration; IAcceleration ar = relative as IAcceleration; IAngularAcceleration arn = relative as IAngularAcceleration; IVelocity vb = baseFrame as IVelocity; IVelocity vr = relative as IVelocity; IAngularVelocity anb = baseFrame as IAngularVelocity; IAngularVelocity anr = relative as IAngularVelocity; double[] rp = Position; double[,] m = Matrix; double[] omr = anr.Omega; StaticExtensionVector3D.VectorPoduct(omr, vr.Velocity, tempV); double om2 = StaticExtensionVector3D.Square(omr); double[] eps = arn.AngularAcceleration; StaticExtensionVector3D.VectorPoduct(eps, rp, temp); for (int i = 0; i < 3; i++) { tempV[i] *= 2; tempV[i] += om2 * rp[i] + relativeAcceleration[i] + temp[i]; } RealMatrix.Multiply(m, tempV, acceleration); double[] omb = anb.Omega; IOrientation orr = relative as IOrientation; double[,] mrr = orr.Matrix; RealMatrix.Multiply(omb, mrr, temp); StaticExtensionVector3D.VectorPoduct(temp, omr, tempV); for (int i = 0; i < 3; i++) { temp[i] = eps[i] + tempV[i]; } RealMatrix.Multiply(temp, m, angularAcceleration); }
void GetParameters(IPosition p, ref IVelocity velocity, ref IOrientation orientation, ref IAngularVelocity om) { velocity = null; orientation = null; om = null; IPosition pa = p; if (p is IReferenceFrame) { IReferenceFrame f = p as IReferenceFrame; pa = f.Own; } if (pa is IVelocity) { velocity = pa as IVelocity; } else { velocity = null; } if (pa is IOrientation) { orientation = pa as IOrientation; } else { orientation = null; } if (pa is IAngularVelocity) { om = pa as IAngularVelocity; } else { om = null; } }
private void Start() { _animator = animatorTarget.GetComponent <Animator>(); _velocity = GetComponent <IVelocity>(); }
void IDifferentialEquationSolver.CalculateDerivations() { Normalize(aggregate); foreach (AggregableWrapper aw in aggrWrappres) { IAggregableMechanicalObject obj = aw.Aggregate; if (obj is Diagram.UI.IUpdatableObject) { Diagram.UI.IUpdatableObject uo = obj as Diagram.UI.IUpdatableObject; if (uo.Update != null) { uo.Update(); } } } Solve(); int n = 0; int kv = 0; for (int i = 0; i < aggrWrappres.Length; i++) { AggregableWrapper wrapper = aggrWrappres[i]; IAggregableMechanicalObject agg = wrapper.Aggregate; Motion6DAcceleratedFrame frame = wrapper.OwnFrame; IVelocity vel = frame; IAcceleration acc = frame; IPosition pos = frame; double[] state = agg.State; double[] p = pos.Position; double[] v = vel.Velocity; for (int j = 0; j < 3; j++) { p[j] = state[j]; derivations[n + j, 0] = state[j]; double a = state[j + 3]; v[j] = a; derivations[n + j, 1] = a; derivations[n + 3 + j, 0] = a; derivations[n + 3 + j, 1] = vector[kv]; ++kv; } IOrientation or = frame; double[] q = or.Quaternion; for (int j = 0; j < 4; j++) { double a = state[j + 6]; quater[j] = a; q[j] = a; } IAngularVelocity av = frame; double[] om = av.Omega; for (int j = 0; j < 3; j++) { double a = state[j + 10]; omega[j] = a; om[j] = a; } StaticExtensionVector3D.CalculateQuaternionDerivation(quater, omega, der, auxQuaternion); for (int j = 0; j < 4; j++) { derivations[n + 6 + j, 0] = quater[j]; derivations[n + 6 + j, 1] = der[j]; } for (int j = 0; j < 3; j++) { derivations[n + 10 + j, 0] = omega[j]; derivations[n + 10 + j, 1] = vector[kv]; ++kv; } int kk = n + 13; int stk = kk; int stv = 6; int sk = 13; for (int j = 13; j < agg.Dimension; j++) { derivations[kk, 0] = state[sk]; double a = state[sk + 1]; derivations[kk, 1] = a; ++kk; ++stk; ++sk; derivations[kk, 0] = a; derivations[kk, 1] = vector[kv]; ++sk; ++kv; ++stv; ++kk; ++j; } n += agg.Dimension; } }
/// <summary> /// Updates itself /// </summary> public override void Update() { try { this.FullReset(); IDataConsumer cons = this; cons.UpdateChildrenData(); ReferenceFrame relative = Relative; IPosition p = relative; double[] x = p.Position; ReferenceFrame parent = this.GetParentFrame(); for (int i = 0; i < 3; i++) { x[i] = (double)measurements[i].Parameter(); } if (relative is IVelocity) { IVelocity vel = relative as IVelocity; double[] v = vel.Velocity; for (int i = 0; i < 3; i++) { IDerivation d = measurements[i] as IDerivation; v[i] = Measurement.GetDouble(d.Derivation); } } double[] qua = relative.Quaternion; for (int i = 0; i < qua.Length; i++) { IMeasurement m = measurements[i + 3]; qua[i] = (double)m.Parameter(); } relative.SetMatrix(); if (relative is IAngularVelocity) { IAngularVelocity av = relative as IAngularVelocity; double[] om = av.Omega; IOrientation or = relative as IOrientation; for (int i = 0; i < 4; i++) { IDerivation d = measurements[i + 3] as IDerivation; der[i] = Measurement.GetDouble(d.Derivation); } Vector3D.StaticExtensionVector3D.CalculateDynamics(or.Quaternion, der, om, qd); } if (relative is IAcceleration) { IAcceleration acc = relative as IAcceleration; IAngularAcceleration anc = relative as IAngularAcceleration; double[] linacc = acc.RelativeAcceleration; for (int i = 0; i < linacc.Length; i++) { linacc[i] = Measurement.GetDouble(secondDeriM[i]); } for (int i = 0; i < 4; i++) { angsec[i] = Measurement.GetDouble(secondDeriM[i + 3]); } IAngularVelocity av = relative as IAngularVelocity; double[] om = av.Omega; IOrientation or = relative as IOrientation; double[] angacc = anc.AngularAcceleration; Vector3D.StaticExtensionVector3D.CalculateAcceleratedDynamics(or.Quaternion, der, om, qd, angsec, angacc); } base.Update(); } catch (Exception exception) { exception.ShowError(10); //!!! OLD this.Throw(ex); } }
/// <summary> /// Builds a bullet type using a default velocity and sprite /// </summary> /// <param name="defaultSprite">The default sprite that the sprite will use.</param> /// <param name="velocity">The default velocity that the sprite will use. (To make the bullet positioned relative to the gun, use 1 for all variables).</param> public BulletTemplate(Sprite defaultSprite, IVelocity defaultVelocity, Bullet defaultBullet) { this._DefaultVelocity = defaultVelocity; this._DefaultSprite = defaultSprite; this._DefaultBullet = defaultBullet; }