- Home /
A math issue.
Hey Guys,
I need to calculate a special value. It goes like that: If "velocityX" == 0.1 than the variable "smoothTime" should be == 0.01. And if "velocityX" == 4.0 than the variable "smoothTime" should be == 0.001. The "velocityX" is a dynamic value and the "smoothTime" should have a relation to it but within a special range. It's a shame but I've no Idea how to calculate relation, do you?
Answer by designico · Nov 21, 2013 at 05:56 PM
Hey guys thanks for your help...
I guess you was right, it was the lineare funktion: y = mx + f. Because of having a issue with understanding your answers I watched some back in the days school math tutorials. It helped me to build my script out of this:
m = (y2-y2)/(x2-x1) --> (y point two - y point one) / (x point two - x point one)
t = y - m*x
x = ( y - t )/m
x = smoothTime
y = finalVelocityX
I calculated m & t with the help of a calculater.
float smoothTime = (finalVelocityX) - 2.222f)/(-22.222f);
(now the value is differnet from my first posting(!))
Answer by Dracorat · Nov 18, 2013 at 05:58 PM
Assuming it's linear progression:
if(velocityX < 0.1f || velocityX > 4.0f) throw new ArgumentException("velocityX out of range.");
percentAlong = 1f - ((4.0f - velocityX) / (4.0f - 0.1f));
smoothTime = (0.01f - 0.001f) * percentAlong + 0.01f;
Answer by smallbit · Nov 18, 2013 at 06:13 PM
If you have more sample data you can use linear regression to find the equation for that in for instance excel, feed data to cells insert lineal chart, than click on the line -> format tread-line and mark option "display equation". lets say X is velocity Y is smoothTime and you will endup with somthing Y = Ax + c or something to calculate smoothTime basing on velocity.
Your answer
Follow this Question
Related Questions
How I can increase num 1 to num 2 in x time? 1 Answer
Rotate Center Pivot based Object like a Draw Bridge 2 Answers
Math.Abs slows down on time.timescale 0 Answers
Why is there no Mathf.Truncate? 2 Answers
[Math] Why is this possible ? 1 Answer