Is there any way to calculate real-world distance walked/travelled in Unity 3d by accessing GPS?

There is functionality to access GPS data in Unity 3D. So, is there any way to use that functionality to calculate distance traveled by player/user in real-world?

physics – How do I calculate to and from a Non-Linear Acceleration?

I am looking at non-linear accelerations using the following values:

  • initial_acceleration
  • time_to_max_velocity
  • max_velocity
  • current_velocity

Initial_acceleration is the per frame acceleration we start with from 0 velocity. Over the course of “time_to_max,” the acceleration is supposed to follow an interpolation from this value to whatever it needs to be to be to hit max_velocity at the end of this time. I need code both to generate the velocity generated by this function at a given point in time, and code for an inverse function that gives me the time given a current velocity.

enter image description here

It sounds like what I want is a type of quadratic interpolation or spline, but I have been unable to work out the details. Above I’ve graphed some values:

  • Red shows the case where: initial_acceleration * time_to_max == max_velocity
  • Green shows the case where: initial_acceleration * time_to_max > max_velocity
  • Blue shows the case where: initial_acceleration * time_to_max < max_velocity

The speed curves I’ve tried in code chaining lerp operations together always end up doing weird things like curving over my max speed and then back down to max speed again. If anyone can supply code, or math, that could get me even halfway towards an answer, I would be very appreciative.

mathematical programming – How to write code to calculate partial derivative of several variable function in C++?

I already wrote the code to calculate the derivative of a single variable function at a point by making a class called “Der”. In class Der, I defined two private variables double f and double df and a print() function to print the values of f and df. Inside the class, I overloaded the operators +, -, *, /, ^ to calculate the derivative of the sum, difference, multiplication etc of functions. I can’t show the whole code because it’s very long but I will show some snippets to give an idea.

class Der{
private:
    double f;  // function value at x
    double df; // derivative of function at x
public:
    Der();
    Der(double);
    Der operator+(Der); // f + g
    Der operator-(Der); // f - g
    Der operator*(Der); // f * g
    Der operator/(Der); // f / g
       
    friend Der operator+(double, Der); //c+f
    friend Der operator-(double, Der); //c-f
    friend Der operator*(double, Der); //c*f
    friend Der operator/(double, Der); //c/f
    Der operator^(double); // f^c,  Where c is constant
   
    friend Der sin(Der);
    friend Der cos(Der);
    friend Der tan(Der);
    friend Der log(Der);
    friend Der exp(Der);
    
    void print();
};

Der :: Der(){}

Der :: Der(double x){
    this->f = x;
    this->df = 1;
}

Der Der :: operator+(Der g){
    Der h;
    h.f = this->f + g.f;
    h.df = this->df + g.df;
    return h;
}

Der sin(Der g){
    Der h;
    h.f = sin(g.f);
    h.df = cos(g.f)*g.df;
    return h;
}
void Der :: print(){
    cout<<"Derivative of function at a point : "<<df<<endl;
}

int main()
    {
        Der x(10), f;
        f = x^2+x^3;
        f.print();
    }

Now I want to use this derivative calculator to calculate the partial derivative of a several variable function and ultimately to calculate the gradient of that function. I have some vague ideas but I am not able to implement it in code. I am a beginner in C++ programming, so it would be helpful if you don’t use too many advanced topics.

Any kind of help would be highly appreciated. Thanks!

Edit: The program should take inputs of independent variables like x(2), y(4), z(5) and function like f(x,y,z)=x^2*y*z+log(x*y*z). Then, it will give the partial derivative of f w.r.t x, y, z at point (2, 4, 5) in the form of an array. I just need some idea on how to code the partial derivative calculator.

algorithm – How to calculate best move in Match-3 game?

I am having a hard time identifying how to approach this problem.

If you have a match 3 game and the objects can only be swapped horizontally and vertically, and only swapped if it will result in a match of 3 or more jewels, which will be removed, with each removed jewel adding +1 to the score.

How would I find the best possible move? I’m confused at where to start and been searching for a while now and getting nowhere.

  • Board 6×6 or 8×8
  • Matches = 3 or more of same kind
  • write function to find best swap for maximum score.

Any help would be greatly appreciated !

EDIT: So I could iterate through the entire board with a nested for loop for the rows and columns, but im not sure what approach to take from here.

For example, say I start with top left which is “red” and I want to test if swapping this will result in a match. How would I go about searching and identifying all possibilities that would result in swapping this left equaling a match and score of 5.

**If I am being really unclear I apologies and will remove my question and possible reword.

Colour block example

derivations – Calculate a number raised to the power of a rational number without calculator

so I was asking myself whether you could calculate a number raised to the power of a rational number, e.g. 3^2.5, without a calculator.

My motiviation comes from looking at my calculator and what all those functions like sin, square root… look like. I like it when I know the background off all these. Let’s me understand them better if you know what I mean.

I’m thanking for your answers in advance!!!

How to calculate totalActivity and LastAcitivity in sql server?

I have table record and have two fields definitions namely; TotalActivity datatype DateTime on sql query, LastActivity datatype decimal, My problem is how do i calculate these on that record? I have tried to use this data format. How do i use this on my query for that record?enter image description here

SELECT REPLACE(convert(varchar,getdate(),100),year(getdate()),’at’)

SELECT substring(convert(varchar,getdate(),114),0,8)

integration – Calculate the Euler-Lagrange for a functional with two nested integrals?

I’ve been reading papers about a fairly unknown topic in quantum mechanics called the quantum backflow effect. And in many of the papers they find an eigen value problem corresponding to the maximal amount of backflow. I understand all of the proof except from the last step in which they find the Euler-Lagrange of a functional ($I(phi)$) to maximise it.

$$I(phi) = int^infty_0{int^infty_0{phi^*(p)K(p,q)phi(q)dp}dq} – lambdaint^infty_0{phi^*(p)phi(p)dp}$$

Is the functional to be maximised and the Euler-Lagrange is

$$int^infty_0{K(p,q)phi(q)dq} = lambdaphi(p).$$

Although none of the papers explain why this is the case and I’ve been searching the internet for how to solve a problem in this form for days and can’t seem to find anything. If anyone knows why this is the Euler-Lagrange of $I(phi)$ any help would be greatly appreciated. Thanks in advance.

How do I get my variables to calculate when obtaining an output

Basically I just want to know what I need to do to get it so that a b c and d come out as values. I’m really new to mathematica and I don’t get how a lot of things work yet and I have almost no programming experience.
The code I'm trying to fix

How to calculate a price of a product with custom size?

Using price modifier is likely the simplest way without changing your whole catalog:

In a custom module, you need in the etc folder a di.xml with the content below:

<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoUiDataProviderModifierPool">
        <arguments>
            <argument name="modifiers" xsi:type="array">
                <item name="custom-pricing" xsi:type="array">
                    <item name="class" xsi:type="string">MbsPriceWidgetModelPriceModifier</item>
                    <item name="sortOrder" xsi:type="number">90</item>
                </item>
            </argument>
        </arguments>
    </type>
</config>

then the class will be called for all your products (so be careful your calculations do not create overhead), but then if you only apply your customisation when standard dimensions has a value, you may have something working quickly.

<?php

namespace MbsPriceWidgetModel;

use MagentoCatalogModelProduct;
use MagentoCatalogModelProductPriceModifierInterface;

class PriceModifier implements PriceModifierInterface
{
    private static $chargeForRange600_2000 = 23;

    public function modifyPrice($price, Product $product)
    {
        if ($product->getStandardDimensions() === '600 x 2000') {
            return $price + self::$chargeForRange600_2000;
        }

        return $product->getPrice();
    }
}

Bayesian Inference-how to calculate posibility of p(y|x,z) if x and y are not conditionally independent

Assume random variables $x$, $y$ are independent, however not conditionally independent; we know that $p(z)=6z(1-z)$ and $p(x|z)=p(y|z)=1-z$,
how can we calculate $p(y|x,z)$ ?