Í am trying to make a reactor which uses a curve to change the playback speed of a sound based on a temperature value, in a heartbeat function. There is one little problem, I have absolutely no idea how.
So far I have this which is nothing like what I am trying to achieve:
script.Parent.Core.Sound.PlaybackSpeed = game.Workspace.Game.Values.Reactor.RTemp.Value/1000*0.6
This is the kind of curve I am trying to achieve, let’s pretend it looks good, or atleast like a curve:
I could use if statements and lerp the numbers, but I’ve already done that and I feel like using curve fitting could be better.
I already found how it could possibly be, but I don’t understand how it works, I just know it does:
function CalculateBoilingPoint(pressure) -- pressure in Pa
pressure*=10
if pressure/10000000>20 then -- above this physics breaks
pressure=20*10000000
end
local temperature = 1.0002646407033929 * 10^2
+ 1.2485512687579338 * 10^( -05 ) * pressure
- 6.0865396119409739 * 10^( -13 ) * pressure^2
+ 1.8961630152963698 * 10^( -20 ) * pressure^3
- 3.4939669493500672 * 10^( -28 ) * pressure^4
+ 3.8256436415169860 * 10^( -36 ) * pressure^5
- 2.4385640912095220 * 10^( -44 ) * pressure^6
+ 8.3341353038170792 * 10^( -53 ) * pressure^7
- 1.1778965239174813 * 10^( -61 ) * pressure^8
return temperature -- temperature in degrees celsius
end
I would be very grateful if someone would send some code alongside with an explanation. Sorry if I wrote something confusing, I was in a hurry.