Here are two videos on the reference site: how is the differentiation in game mathematics different from mathematics?
Regarding 8:22
of the Unity engine video, I would like to know the following:
I looked at how to solve the differential in the video of the try, but I don't understand the meaning of the func(float x)
function. Why do I need a function that takes the square of X?
Also, I would like to know the difference between the use of differential in game mathematics and mathematics.
I looked up how to solve differentials online.
Unity differential video
Try Movie
Refer to differentiation method ([Differentiation method] derivative formula)
using System;
public static class program
{
static float func (float x)
{
return x*x;
}
static float derivative (float x)
{
const flow = 0.1;
return(func(x+h)-func(x))/h;
}
public static void Main()
{
Console.WriteLine (derivative (3.0));
}
}
There is no particular difference between mathematics and ordinary mathematics in making games.You may want to approximate continuously changing values on your computer.
Consider a function f that returns a real number when given a real number x.As described in various explanations, the function f' obtained by differentiating this function f by x can be defined by the following formula:
Now, mathematically, the definition of differentiation requires a limit, but if you want to program this definition, you have to calculate the limit somewhere in the program.
We can't do that in a common programming language, so we'll try to approximate it in a different way.In the video that the questioner referred to this time, the differential value is approximated by using a very small value as h
and calculating the fraction on the right.Actually, I want to know the limit when h
is close to 0
, but I can't do that, so I'm replacing it with a value as close to 0
.
Now, we are choosing f(x)=x2 as an example to confirm the approximation of this differential, probably because it is easy to understand.This method can be used for more functions in the same way, so you don't have to stick to f(x)=x2.
© 2024 OneMinuteCode. All rights reserved.