public InertiaBuilder(IApplicationBuilder applicationBuilder)
        {
            ApplicationBuilder = applicationBuilder ?? throw new ArgumentNullException(nameof(applicationBuilder));
            Inertia.Init(ApplicationBuilder.ResultFactory());

            ApplicationBuilder.UseWhen(IsNewVersion, RefreshVersion());
            ApplicationBuilder.UseWhen(IsNotRedirect, Redirect());
        }
        public IActionResult Index()
        {
            //return whatever you want.
            var data = new { Id = 1 };

            //return Inertia Result.
            return(Inertia.Render(_componentResolver.ResolveComponent(nameof(Index)), data));
        }
Example #3
0
 public IActionResult InertiaResultOrRedirect(string componentName, object props = null)
 {
     // if this is not an inertia request, redirect to do a full page load to initialize Inertia
     props ??= new { };
     return(IsInertiaRequest
         ? (IActionResult)Inertia.Render(componentName, props)
         : RedirectToAction("Index", new { redirectComponent = "Home/SampleApi" }));
 }
        public IActionResult Privacy()
        {
            //return whatever you want.
            var data = new { Id = 1 };
            //return Inertia Result.
            var result = Inertia.Render(_componentResolver.ResolveComponent(nameof(Privacy)), data);

            return(result);
        }
Example #5
0
        /// <summary>
        ///     Gets the hash code
        /// </summary>
        /// <returns>The int</returns>
        public override int GetHashCode()
        {
            int result = Area.GetHashCode();

            result = (result * 397) ^ Centroid.GetHashCode();
            result = (result * 397) ^ Inertia.GetHashCode();
            result = (result * 397) ^ Mass.GetHashCode();
            return(result);
        }
Example #6
0
        public Car Apply(Adjustment adjustment)
        {
            var inertia   = _inertia.Add(Inertia.DirectionFor(adjustment));
            var positionX = Position.x + inertia._x;
            var positionY = Position.y + inertia._y;
            var position  = new Position(positionX, positionY);

            return(new Car(inertia, position));
        }
Example #7
0
        /// <summary>
        /// Creates a new instance of Inertial with the inertial origin, mass and inertia specified.
        /// </summary>
        /// <param name="origin">The link's inertial reference frame. MUST NOT BE NULL</param>
        /// <param name="mass">The link's mass. MUST NOT BE NULL</param>
        /// <param name="inertia">The link's inertia matrix. MUST NOT BE NULL</param>
        public Inertial(Origin origin, Mass mass, Inertia inertia)
        {
            Preconditions.IsNotNull(origin, "Inertial origin property must not be null");
            Preconditions.IsNotNull(mass, "Inertial mass property must not be null");
            Preconditions.IsNotNull(inertia, "Inertial inertia property must not be null");

            this.Origin  = origin;
            this.Mass    = mass;
            this.Inertia = inertia;
        }
Example #8
0
    private Vector3 a      = Vector3.zero; // angular velocity

    private void Start()
    {
        mass    = 1.0f;
        massInv = 1.0f / mass;

        inertia    = Inertia.SolidBox(mass, 1.0f * Vector3.one);
        inertiaInv = inertia.Inverted;

        rLocal = 0.5f * Vector3.one;
    }
Example #9
0
        public static IApplicationBuilder UseInertia(this IApplicationBuilder app)
        {
            Inertia.Init(app.ResultFactory());

            app.UseWhen(IsNewVersion, RefreshVersion());

            app.UseWhen(IsNotRedirect, Redirect());

            return(app);
        }
Example #10
0
        public IActionResult Index()
        {
            //your js component file name.
            var componentName = "Counter";
            //return whatever you want.
            var data = new { initialValue = 0 };

            //return Inertia Result.
            return(Inertia.Render(componentName, data));
        }
Example #11
0
        public IActionResult Index()
        {
            //your js component file name.
            var componentName = "Welcome";
            //return whatever you want.
            var data = new { Id = 1 };

            //return Inertia Result.
            return(Inertia.Render(componentName, data));
        }
Example #12
0
        public void ConstructInertial()
        {
            Origin   origin   = new Origin();
            Mass     mass     = new Mass(1);
            Inertia  inertia  = new Inertia(0, 0, 0, 0, 0, 0);
            Inertial inertial = new Inertial(origin, mass, inertia);

            Assert.AreEqual(origin, inertial.Origin);
            Assert.AreEqual(mass, inertial.Mass);
            Assert.AreEqual(inertia, inertial.Inertia);
        }
Example #13
0
    public void Init()
    {
        cif = new CockpitInterface();

        inp = new Inertia(plane.name);

        inp.SetBlock(0, new InertiaBlock("‹@‘Ì", plane.cg, plane.m0, plane.ixx_m0, plane.iyy_m0, plane.izz_m0, plane.ixy_m0, plane.iyz_m0, plane.izx_m0));

        pMotion = new PlaneMotion(inp, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
        atmos   = new Isa(pMotion.wpos.y);
    }
Example #14
0
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            if (context.Result == null && !context.ModelState.IsValid)
            {
                Controller controller = (Controller)context.Controller;
                var        validation = ValidateModel(context.ModelState);
                controller.TempData.TryAdd("errors", validation);

                context.Result = Inertia.RedirectBack();
            }
        }
Example #15
0
        public async Task <IActionResult> Login(string returnUrl = null)
        {
            returnUrl ??= Url.Content("~/");

            // Clear the existing external cookie to ensure a clean login process
            await HttpContext.SignOutAsync(IdentityConstants.ExternalScheme);

            return(Inertia.Render(_componentResolver.ResolveComponent(nameof(Login)), new
            {
                returnUrl
            }));
        }
        public void Calc_equation_of_motion(Inertia ip, Vector3D f, Vector3D t, double dt)
        {
            double u = vc.x;
            double v = vc.y;
            double w = vc.z;
            double p = omega.x;
            double q = omega.y;
            double r = omega.z;

            double mass = ip.m;
            double ixx  = ip.ixx;
            double iyy  = ip.iyy;
            double izz  = ip.izz;
            double izx  = ip.izx;
            double ixy  = ip.ixy;
            double iyz  = ip.iyz;

            double l = t.x;
            double m = t.y;
            double n = t.z;

            force.SetVec(f);
            torque.SetVec(t);

            d_vc_b.SetVec(d_vc);
            d_vc.x = (dg.x * 9.80655D + f.x / mass - q * w + r * v);
            d_vc.y = (dg.y * 9.80655D + f.y / mass - r * u + p * w);
            d_vc.z = (dg.z * 9.80655D + f.z / mass - p * v + q * u);

            d_omega_b.SetVec(d_omega);

            double a = l + izx * p * q - (izz - iyy) * q * r - ixy * r * p + iyz * (q * q - r * r);
            double b = m - iyz * p * q + ixy * q * r - (ixx - izz) * r * p - izx * (p * p + r * r);
            double c = n - (iyy - ixx) * p * q - izx * q * r + iyz * r * p + ixy * (p * p - q * q);

            d_omega = new Vector3D(a, b, c).MultMat(ip.InertiaInvMat);

            vc.x += 0.5D * (d_vc.x * 3.0D - d_vc_b.x) * dt;
            vc.y += 0.5D * (d_vc.y * 3.0D - d_vc_b.y) * dt;
            vc.z += 0.5D * (d_vc.z * 3.0D - d_vc_b.z) * dt;

            omega.x += 0.5D * (d_omega.x * 3.0D - d_omega_b.x) * dt;
            omega.y += 0.5D * (d_omega.y * 3.0D - d_omega_b.y) * dt;
            omega.z += 0.5D * (d_omega.z * 3.0D - d_omega_b.z) * dt;

            Calc_alpha_beta(dt);
            Convert_motion_rtol(ip.cg);
            base.Update(dt);

            SetGravityDirectionVector();
        }
Example #17
0
        /// <summary>
        /// Parses a URDF &lt;inertial&gt; element from XML.
        /// </summary>
        /// <param name="node">The XML node of a &lt;inertial&gt; element. MUST NOT BE NULL</param>
        /// <returns>A Inertial object parsed from the XML</returns>
        public override Inertial Parse(XmlNode node)
        {
            ValidateXmlNode(node);

            XmlElement originElement  = GetElementFromNode(node, UrdfSchema.ORIGIN_ELEMENT_NAME);
            XmlElement massElement    = GetElementFromNode(node, UrdfSchema.MASS_ELEMENT_NAME);
            XmlElement inertiaElement = GetElementFromNode(node, UrdfSchema.INERTIA_ELEMENT_NAME);

            Origin  origin  = ParseOrigin(originElement);
            Mass    mass    = ParseMass(massElement);
            Inertia inertia = ParseInertia(inertiaElement);

            return((origin != null) ? new Inertial(origin, mass, inertia) : new Inertial(mass, inertia));
        }
Example #18
0
        public void ParseInertiaMissingAttribute()
        {
            string xml = "<inertia ixx='1' ixy='1' ixz='1' iyy='1' iyz='1'/>"; // No izz attribute

            this.xmlDoc.Load(XmlReader.Create(new StringReader(xml)));
            Inertia inertia = this.parser.Parse(this.xmlDoc.DocumentElement);

            Assert.AreEqual(1, inertia.Ixx);
            Assert.AreEqual(1, inertia.Ixy);
            Assert.AreEqual(1, inertia.Ixz);
            Assert.AreEqual(1, inertia.Iyy);
            Assert.AreEqual(1, inertia.Iyz);
            Assert.AreEqual(InertiaParser.DEFAULT_VALUE, inertia.Izz);
        }
Example #19
0
        public IActionResult Index(string redirectComponent)
        {
            var component = redirectComponent.IsEmpty()
                ? "Home/Index"
                : redirectComponent;

            var model = new Page {
                Component = component, Url = component
            };

            return(!IsInertiaRequest
                ? (IActionResult)View(model)
                : Inertia.Render("Home/Index", new { }));
        }
Example #20
0
        public void EqualsAndHash()
        {
            Inertia inertia = new Inertia(1, 2, 3, 4, 5, 6);
            Inertia same    = new Inertia(1, 2, 3, 4, 5, 6);
            Inertia diff    = new Inertia(7, 7, 7, 7, 7, 7);

            Assert.IsTrue(inertia.Equals(inertia));
            Assert.IsFalse(inertia.Equals(null));
            Assert.IsTrue(inertia.Equals(same));
            Assert.IsTrue(same.Equals(inertia));
            Assert.IsFalse(inertia.Equals(diff));
            Assert.AreEqual(inertia.GetHashCode(), same.GetHashCode());
            Assert.AreNotEqual(inertia.GetHashCode(), diff.GetHashCode());
        }
Example #21
0
        public object Clone()
        {
            var result = new PlayerModel((Coordinates)CurPosition.Clone(), PlayerName)
            {
                PrevPosition      = (Coordinates)PrevPosition.Clone(),
                Inertia           = (Coordinates)Inertia.Clone(),
                CurLap            = CurLap,
                IsAlive           = IsAlive,
                IsWinner          = IsWinner,
                LastWayPoint      = LastWayPoint,
                NumberOfMovements = NumberOfMovements
            };

            return(result);
        }
Example #22
0
        public void ConstructInertialNoOrigin()
        {
            Mass     mass     = new Mass(1);
            Inertia  inertia  = new Inertia(0, 0, 0, 0, 0, 0);
            Inertial inertial = new Inertial(mass, inertia);

            Assert.AreEqual(mass, inertial.Mass);
            Assert.AreEqual(inertia, inertial.Inertia);
            Assert.AreEqual(0, inertial.Origin.Xyz.X);
            Assert.AreEqual(0, inertial.Origin.Xyz.Y);
            Assert.AreEqual(0, inertial.Origin.Xyz.Z);
            Assert.AreEqual(0, inertial.Origin.Rpy.R);
            Assert.AreEqual(0, inertial.Origin.Rpy.P);
            Assert.AreEqual(0, inertial.Origin.Rpy.Y);
        }
Example #23
0
        public void ConstructInertia()
        {
            double  ixx     = 1;
            double  ixy     = 2;
            double  ixz     = 3;
            double  iyy     = 4;
            double  iyz     = 5;
            double  izz     = 6;
            Inertia inertia = new Inertia(ixx, ixy, ixz, iyy, iyz, izz);

            Assert.AreEqual(ixx, inertia.Ixx);
            Assert.AreEqual(ixy, inertia.Ixy);
            Assert.AreEqual(ixz, inertia.Ixz);
            Assert.AreEqual(iyy, inertia.Iyy);
            Assert.AreEqual(iyz, inertia.Iyz);
            Assert.AreEqual(izz, inertia.Izz);
        }
Example #24
0
        public IActionResult Index()
        {
            var rng      = new Random();
            var forecast = Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date         = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary      = Summaries[rng.Next(Summaries.Length)]
            })
                           .ToArray();

            //your js component file name.
            var componentName = "Forecast";
            //return whatever you want.
            var data = new { forecast };

            //return Inertia Result.
            return(Inertia.Render(componentName, data));
        }
Example #25
0
        public void ParseInertia()
        {
            double ixx = 1;
            double ixy = 2;
            double ixz = 3;
            double iyy = 4;
            double iyz = 5;
            double izz = 6;

            string xml = String.Format(FORMAT_STRING, ixx, ixy, ixz, iyy, iyz, izz);

            this.xmlDoc.Load(XmlReader.Create(new StringReader(xml)));
            Inertia inertia = this.parser.Parse(this.xmlDoc.DocumentElement);

            Assert.AreEqual(ixx, inertia.Ixx);
            Assert.AreEqual(ixy, inertia.Ixy);
            Assert.AreEqual(ixz, inertia.Ixz);
            Assert.AreEqual(iyy, inertia.Iyy);
            Assert.AreEqual(iyz, inertia.Iyz);
            Assert.AreEqual(izz, inertia.Izz);
        }
Example #26
0
        public void ParseInertiaUnorderedAttributes()
        {
            double ixx = 1;
            double ixy = 2;
            double ixz = 3;
            double iyy = 4;
            double iyz = 5;
            double izz = 6;

            string xml = String.Format("<inertia ixx='{0}' izz='{5}' ixy='{1}' iyz='{4}' iyy='{3}' ixz='{2}'/>",
                                       ixx, ixy, ixz, iyy, iyz, izz);

            this.xmlDoc.Load(XmlReader.Create(new StringReader(xml)));
            Inertia inertia = this.parser.Parse(this.xmlDoc.DocumentElement);

            Assert.AreEqual(ixx, inertia.Ixx);
            Assert.AreEqual(ixy, inertia.Ixy);
            Assert.AreEqual(ixz, inertia.Ixz);
            Assert.AreEqual(iyy, inertia.Iyy);
            Assert.AreEqual(iyz, inertia.Iyz);
            Assert.AreEqual(izz, inertia.Izz);
        }
        public PlaneMotion(Inertia ip, double xIn, double yIn, double zIn, double rollIn, double pitchIn, double yawIn, double u, double v, double w, double p, double q, double r)
            : base(xIn, yIn, zIn, rollIn, pitchIn, yawIn, 0.0D, 0.0D, 0.0D)
        {
            vcDash    = new Vector3D();
            vc        = new Vector3D();
            d_vc      = new Vector3D();
            omega     = new Vector3D();
            d_omega   = new Vector3D();
            dg        = new Vector3D();
            d_vc_b    = new Vector3D();
            d_omega_b = new Vector3D();
            force     = new Vector3D(0.0D, 0.0D, 0.0D);
            torque    = new Vector3D(0.0D, 0.0D, 0.0D);

            pos_integral_mode = 1;

            vc.SetVec(u, v, w);

            omega.SetVec(p, q, r);

            Convert_motion_rtol(ip.cg);
            Update(0.0D);
            wv_b.SetVec(wv);
            dpitch_b = dpitch;
            dyaw_b   = dheading;
            droll_b  = droll;

            d_vc.SetVec(0.0D, 0.0D, 0.0D);
            d_vc_b.SetVec(0.0D, 0.0D, 0.0D);

            d_omega.SetVec(0.0D, 0.0D, 0.0D);
            d_omega_b.SetVec(0.0D, 0.0D, 0.0D);

            alpha   = (alpha_b = Jp.Maker1.Sim.Tools.Tool.CalcAlpha(vc));
            beta    = Jp.Maker1.Sim.Tools.Tool.CalcBeta(vc);
            d_alpha = 0.0D;

            SetGravityDirectionVector();
        }
Example #28
0
    /**
     * \brief	Fires bullets.
     * \param	void
     * \return	void
     */
    void Fire()
    {
        if (Time.timeScale != 0.0f)
        {
            GameObject bullet = Instantiate(bulletPrefab);

            bullet.transform.position = transform.position;
            bullet.transform.rotation = transform.rotation;
            bullet.GetComponentInParent <SphereTraveller>().Rotation = st.Rotation;
            Inertia inertia = bullet.GetComponentInParent <Inertia>();

            // get standard velocity
            float stdSpeed = bullet.GetComponentInParent <SphereTraveller>().speed;
            float stdAngle = turretTransform.localRotation.eulerAngles.y;
            inertia.StdVelocity = TrigPhysics.GetVelocity(stdAngle + Random.Range(-spread, spread), stdSpeed);

            // get inherited velocity
            inertia.InheritedVelocity = st.LastDirection;

            // get angle
            inertia.Angle = stdAngle;
        }
    }
Example #29
0
 public Inertial(XElement node)
 {
     origin  = (node.Element("origin") != null) ? new Origin(node.Element("origin")) : null; // optional
     mass    = (double)node.Element("mass").Attribute("value");                              // required
     inertia = new Inertia(node.Element("inertia"));                                         // required
 }
Example #30
0
 /// <summary>
 /// Creates a new instance of Inertial with the mass and inertia specified.
 /// </summary>
 /// <param name="mass">The link's mass. MUST NOT BE NULL</param>
 /// <param name="inertia">The link's inertia matrix. MUST NOT BE NULL</param>
 public Inertial(Mass mass, Inertia inertia) : this(Origin.DEFAULT_ORIGIN, mass, inertia)
 {
     // Invoke overloaded constructor.
 }