public void VerifyAllEnums()
 {
     var acceleration = new Acceleration(1, AccelerationUnit.BaseUnit);
     var angle = new Angle(1, AngleUnit.BaseUnit);
     var angularAcceleration = new AngularAcceleration(1, AngularAccelerationUnit.BaseUnit);
     var area = new Area(1, AreaUnit.BaseUnit);
     var density = new MassDensity(1, MassDensityUnit.BaseUnit);
     var electricCurrent = new ElectricCurrent(1, ElectricCurrentUnit.BaseUnit);
     var electricResistance = new ElectricResistance(1, ElectricResistanceUnit.BaseUnit);
     var electricVoltage = new ElectricPotential(1, ElectricPotentialUnit.BaseUnit);
     var energy = new Energy(1, EnergyUnit.BaseUnit);
     var force = new Force(1, ForceUnit.BaseUnit);
     var frequency = new Frequency(1, FrequencyUnit.BaseUnit);
     var jerk = new Jerk(1, JerkUnit.BaseUnit);
     var length = new Length(1, LengthUnit.BaseUnit);
     var mass = new Mass(1, MassUnit.BaseUnit);
     var massFlowRate = new MassFlowRate(1, MassFlowRateUnit.BaseUnit);
     var momentum = new Momentum(1, MomentumUnit.BaseUnit);
     var numeric = new Numeric(1, NumericUnit.BaseUnit);
     var power = new Power(1, PowerUnit.BaseUnit);
     var pressure = new Pressure(1, PressureUnit.BaseUnit);
     var speed = new Speed(1, SpeedUnit.BaseUnit);
     var temperature = new Temperature(1, TemperatureUnit.BaseUnit);
     var time = new Time(1, TimeUnit.BaseUnit);
     var torque = new Torque(1, TorqueUnit.BaseUnit);
     var volume = new Volume(1, VolumeUnit.BaseUnit);
     var volumetricFlowRate = new VolumetricFlowRate(1, VolumetricFlowRateUnit.BaseUnit);
 }
 public void OpAddition()
 {
     var force1 = new Force(9.81, ForceUnit.Newtons);
     var force2 = new Force(1, ForceUnit.KilogramForce);
     var expected = new Force(19.62, ForceUnit.Newtons);
     (force1 + force2).ShouldEqual(expected);
     (force2 + force1).ShouldEqual(expected);
 }
Пример #3
0
	// Use this for initialization
	void Start () {
	
		// gets the force
		forceObj = GameObject.Find("Force");
		theForce = forceObj.GetComponent("Force") as Force;
		
		// gets the player controller
		playerController = this.GetComponent("ThirdPersonController") as ThirdPersonController;
	}
        public void OpDivision()
        {
            var force1 = new Force(19.62, ForceUnit.Newtons);
            var force2 = new Force(2, ForceUnit.KilogramForce);
            (force1 / force2).ShouldBeWithinEpsilonOf(1);
            (force2 / force1).ShouldBeWithinEpsilonOf(1);

            (force1 / 2).ShouldEqual(new Force(9.81, ForceUnit.Newtons));
            (force2 / 2).ShouldEqual(new Force(1, ForceUnit.KilogramForce));
        }
 public void OpGreaterThanOrEqual()
 {
     var force1 = new Force(9.81, ForceUnit.Newtons);
     var force2 = new Force(1, ForceUnit.KilogramForce);
     var force3 = new Force(2, ForceUnit.KilogramForce);
     (force1 >= force3).ShouldBeFalse();
     (force3 >= force1).ShouldBeTrue();
     (force1 >= force2).ShouldBeTrue();
     (force2 >= force1).ShouldBeTrue();
 }
 public void OpInverseEquals()
 {
     var force1 = new Force(9.81, ForceUnit.Newtons);
     var force2 = new Force(1, ForceUnit.KilogramForce);
     var force3 = new Force(2, ForceUnit.KilogramForce);
     (force1 != force2).ShouldBeFalse();
     (force2 != force1).ShouldBeFalse();
     (force1 != force3).ShouldBeTrue();
     (force3 != force1).ShouldBeTrue();
 }
 public void OpEquals()
 {
     var force1 = new Force(9.81, ForceUnit.Newtons);
     var force2 = new Force(1, ForceUnit.KilogramForce);
     var force3 = new Force(2, ForceUnit.KilogramForce);
     (force1 == force2).ShouldBeTrue();
     (force2 == force1).ShouldBeTrue();
     (force1 == force3).ShouldBeFalse();
     (force3 == force1).ShouldBeFalse();
     force1.Equals(force2)
           .ShouldBeTrue();
     force1.Equals((object)force2)
           .ShouldBeTrue();
     force2.Equals(force1)
           .ShouldBeTrue();
     force2.Equals((object)force1)
           .ShouldBeTrue();
 }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            DataReady = false;
            Kinematics k = new Kinematics();
            dataGridView1.DataSource = null;
            Force PIDCorrection = new Force();

            k.Forces.Add(PIDCorrection);
            PIDLoop pid = new PIDLoop(k);

            Force Disturbance = new Force();
            k.Forces.Add(Disturbance);

            k.mass = 1;
            Data.Clear();
            Double RunningTime = 0;
            k.XPosition = 0;
            k.XVelocity = -20;
            for (int i = 0; i < 10000; i++)//sim loop
            {
                RunningTime+= k.time;

                if (i > 50 && i< 3000)
                {
                    Disturbance.X = -100;
                    PIDCorrection.X = pid.calculateCorrection(50);
                }
                else if (i >= 3000)
                {
                    PIDCorrection.X = pid.calculateCorrection(25);
                }
                k.CalculateKinematics();
                DataRow newRow = Data.NewRow();
                newRow["time"] = RunningTime;
                newRow["position"] = k.XPosition;
                Data.Rows.Add(newRow);

            }
            DataReady = true;
            dataGridView1.DataSource = Data;
            this.Invalidate();
        }
Пример #9
0
    public bool Calc( Vector3 cur, Vector3 birdDir, Collider cld, out Force force )
    {
      var pointOnBounds = MathTools.CalcPointOnBounds( cld, cur );
      var revDir = cur - pointOnBounds;
      var dist = revDir.magnitude;

      if( dist <= MathTools.epsilon )
      {
        //Let's setup the direction to outside of colider
        revDir = (pointOnBounds - cld.transform.position).normalized;

        //and distance to N percent of OptDistance
        dist = 0.1f * optDistance;
      }
      else
        revDir /= dist;

      //Force depends on direction of bird: no need to turn a bird if it is flying in opposite direction
      force.dir = revDir * ( CalcImpl(dist) * MathTools.AngleToFactor(revDir, birdDir) );
      force.pos = pointOnBounds;
      return true;
    }
 public void OpMultiplicationScaler()
 {
     var force = new Force(1, ForceUnit.KilogramForce);
     var expected = new Force(2, ForceUnit.KilogramForce);
     (force * 2).ShouldEqual(expected);
     (2 * force).ShouldEqual(expected);
 }
 public void OpSubtraction()
 {
     var force1 = new Force(19.62, ForceUnit.Newtons);
     var force2 = new Force(1, ForceUnit.KilogramForce);
     (force1 - force2).ShouldEqual(new Force(9.81, ForceUnit.Newtons));
     (force2 - force1).ShouldEqual(new Force(-1, ForceUnit.KilogramForce));
 }
Пример #12
0
    void JumpDone(Force f)
    {
        Force jumpMomentum = GetForce("JumpMomentum");

        IsJumping = false;
        RemoveForce("Jump");
        RemoveForce("JumpMomentum");

        if ((!HasGround || !CurrentGround.IsTouching) && jumpMomentum != null)
        {
            AddForce("FallMomentum", jumpMomentum.From, Vector3.zero, 1f);
        }
    }
 /// <summary>
 /// Determine whether a given force is being applied to this object.
 /// </summary>
 /// <param name="force">Force to test.</param>
 /// <returns>True if force is being applied.</returns>
 public bool HasForce(Force force)
 {
     for (int i = 0; i < Count; i++)
         if (_forces[i] == force)
             return true;
     return false;
 }
Пример #14
0
 private void internal_add_force(Vector2D force, int index)
 {
     Force my_force = new Force();
     my_force._force = force;
     my_force._index = index;
     _add_forces.Enqueue(my_force);
 }
Пример #15
0
    public void AddForce(string name, Vector3 from, Vector3 to, float time, Action<Force> onDone)
    {
        if (!String.IsNullOrEmpty(name))
        {
            forces[name] = new Force { From = from, To = to, Time = time, Elapsed = 0, OnDone = onDone };

            // We need to remove any pending expires on this force
            expiredForces.Remove(name);
        }
    }
Пример #16
0
 public ComBall(Ball b, Force f, Control c)
 {
     this.b = b;
     this.f = f;
     this.c = c;
 }
Пример #17
0
            public GeneralTrusses(double x, double y, double tension_compression)
            {
                //two types--- 0 tension_compression is unknown
                this.x = x;
                this.y = y;
                this.tension_compression = tension_compression;
                this.alpha = Math.Atan(y / x);
                if (tension_compression != 0)
                {

                    this._known_unknown = true;
                    this._ResultantForce = new Force(tension_compression * Math.Cos(this.alpha), tension_compression * Math.Sin(this.alpha));

                }
                else
                {
                    this._known_unknown = false;
                    //if postive
                    //doesn't handle zeros; if term is non zero, use this method.
                    //if it is zero, ignore?
                    this._ResultantForce = new Force(SignSelector(x,Math.Cos(alpha)), SignSelector(y,Math.Sin(alpha)));
                }
            }
 public void OpLessThan()
 {
     var force1 = new Force(9.81, ForceUnit.Newtons);
     var force2 = new Force(1, ForceUnit.KilogramForce);
     var force3 = new Force(2, ForceUnit.KilogramForce);
     (force1 < force3).ShouldBeTrue();
     (force3 < force1).ShouldBeFalse();
     (force1 < force2).ShouldBeFalse();
     (force2 < force1).ShouldBeFalse();
 }
 protected void SetScalarValue(DependencyProperty property, Force? quantity)
 {
     // we set this flag to prevent from setting scalar value changing quantity values.
     this.isUpdatingScalarValue = true;
     var value = quantity != null
         ? this.Unit.GetScalarValue(quantity.Value)
         : (double?)null;
     this.SetCurrentValue(property, value);
     this.isUpdatingScalarValue = false;
 }
Пример #20
0
public bool Equals(Force obj) 
{
    if (obj == null) return false;
    return (obj.swigCPtr.Handle == this.swigCPtr.Handle);
}
Пример #21
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Force obj) {
   return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
        protected void _SetupForce(Force force, ref ForceInstance fi)
        {
            Assert.Fatal(SceneObject != null, "Cannot set up force before adding to scene");

            SceneObject.RegisterInterface(this, fi._strength);
            fi._strength.Value = force.InitialStrength;

            if (force.LinkName != null && force.LinkName != String.Empty)
            {
                fi._linkPosition = SceneObject.Components.GetInterface<ValueInterface<Vector2>>("vector2", force.LinkName);
                fi._linkRotation = SceneObject.Components.GetInterface<ValueInterface<float>>("float", force.LinkName);
            }
        }
 /// <summary>
 /// Get strength of given force, scaled between Force.MinStrength and Force.MaxStrength.
 /// </summary>
 /// <param name="force">Force to query.</param>
 /// <returns>Raw strength of force.</returns>
 public float GetRawForceStrength(Force force)
 {
     for (int i = 0; i < Count; i++)
         if (_forces[i] == force)
             return GetRawForceStrength(i);
     return 0.0f;
 }
        protected void _GetForceData(Force force, ForceInstance fi, out Vector2 offset, out Vector2 direction)
        {
            offset = SceneObject.GetWorldLinkPosition(fi._linkPosition, fi._linkRotation, force.Offset) - SceneObject.Position;

            float dirRot;
            if (force.UseLinkDirection)
            {
                dirRot = SceneObject.GetWorldLinkRotation(fi._linkRotation, force.RotationOffset);
            }
            else
            {
                dirRot = force.ConstantDirection;
                if (!force.ConstantDirectionIsWorldSpace)
                    dirRot += SceneObject.Rotation;
                dirRot = (dirRot + force.RotationOffset) % 360.0f;
            }

            direction = T2DVectorUtil.VectorFromAngle(dirRot);
        }
Пример #25
0
 public double Magnitude(Force a)
 {
     return Math.Sqrt(i * i + j * j);
 }
 /// <summary>
 /// Remove an existing force.  If force is not currently being applied then this method
 /// returns false.
 /// </summary>
 /// <param name="force">Force to remove.</param>
 /// <returns>True if force was being applied.</returns>
 public bool RemoveForce(Force force)
 {
     for (int i = 0; i < Count; i++)
         if (_forces[i] == force)
         {
             _TeardownForce(i);
             return true;
         }
     return false;
 }
Пример #27
0
        private void Form1_Load(object sender, EventArgs e)
        {
            bExVisible = false;
            tmrFlash.Enabled = true;
            SetVisibilityOfLabels();
            InitializeSysVars();
            pbGalaxy.Dock = DockStyle.Fill;
            pbGalaxy.BackColor = Color.Black;
            pbGalaxy.Paint += new System.Windows.Forms.PaintEventHandler(this.pbGalaxy_Paint);
            int iDiam = 235;
            Ball bTmp = new Ball(new double[2] { 0,0}, new double[2] { 0, 0 }, new double[2] { 0, 0 },mySysVars.fEarthMass, iDiam, Color.Green, Color.Green, false, false, new Timer(), 0);
            Force fTmp = new Force(new double[2] { 0, 0 }, new double[2] { 0, 0 }, new double[2] { 0, 0 }, new double[2] { 0, 0 }, new double[2] { 0, 0 },0);
            Control cTmp = new Control();
            ComBall Earth = new ComBall(bTmp, fTmp, cTmp);
            myBalls.Add(Earth);

            LoadEarthImage();
            LoadMushImage();
            tmrDraw.Enabled = true;
        }
 /// <summary>
 /// Add a new force to this object.  Force will continue to be applied until RemoveForce
 /// is called for the force.
 /// </summary>
 /// <param name="force">Force to applye.</param>
 public void AddForce(Force force)
 {
     _forces.Add(force);
     ForceInstance fi = new ForceInstance();
     fi._strength = new ValueInPlaceInterface<float>();
     if (SceneObject != null)
         _SetupForce(force, ref fi);
     _forceInstances.Add(fi);
 }
Пример #29
0
        private void pbGalaxy_Click(object sender, EventArgs e)
        {
            int iDiam = 20;
            Point screenCoordinates = this.PointToScreen(new Point(0, 0));
            Timer tmr = new Timer();

            tmr.Interval = 4000;
            tmr.Tick += new System.EventHandler(this.tmrBeforeDelete_Tick);
            Ball bTmp = new Ball(new double[2] { ((MousePosition.X - screenCoordinates.X) - ((pbGalaxy.Width) / 2)), ((screenCoordinates.Y - MousePosition.Y) + (pbGalaxy.Height / 2))}, new double[2] { 0, 0 }, new double[2] { 0, 0 }, 1, iDiam, Color.White, Color.White, false, false, tmr, 0);
            Force fTmp = new Force(new double[2] { 0, 0 }, new double[2] { 0, 0 }, new double[2] { 0, 0 }, new double[2] { 0, 0 }, new double[2] { 0, 0 }, 0);
            Control cTmp = new Control(System.DateTime.Now, System.DateTime.Now, 0, 0, 0, false, false, false);
            ComBall moon = new ComBall(bTmp, fTmp, cTmp);
            myBalls.Add(moon);
        }
 protected virtual void OnMaxValueChanged(Force? oldValue, Force? newValue)
 {
     this.SetScalarValue(ScalarMaxValueProperty, newValue);
 }