You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/03/30 19:58:21 UTC
[GitHub] mlampert commented on a change in pull request #947: Refactor/easing library
mlampert commented on a change in pull request #947: Refactor/easing library
URL: https://github.com/apache/mynewt-core/pull/947#discussion_r178365725
##########
File path: util/easing/src/easing.c
##########
@@ -69,125 +69,128 @@ static inline float quadratic_in(float step, float max_steps, float max_val)
{
float ratio = step / max_steps;
- return max_val * pow(ratio, 2);
+ return max_val * (ratio * ratio);
}
static inline float quadratic_out(float step, float max_steps, float max_val)
{
float ratio = step / max_steps;
- return -max_val * ratio * (ratio - 2.0);
+ return -max_val * ratio * (ratio - 2.0f);
}
static inline float quadratic_io(float step, float max_steps, float max_val)
{
- float ratio = step / (max_steps / 2.0);
+ float ratio = step / (max_steps / 2.0f);
if (ratio < 1)
- return max_val / 2.0 * pow(ratio, 2);
+ return max_val / 2.0f * (ratio * ratio);
- ratio = (step - (max_steps/2.0)) / (max_steps/2.0);
- return (max_val / 2.0) - (max_val / 2.0) * ratio * (ratio - 2.0);
+ ratio = (step - (max_steps/2.0f)) / (max_steps/2.0f);
+ return (max_val / 2.0f) - (max_val / 2.0f) * ratio * (ratio - 2.0f);
}
/* Cubic */
static inline float cubic_in(float step, float max_steps, float max_val)
{
float ratio = step / max_steps;
- return max_val * pow(ratio, 3);
+ return max_val * (ratio * ratio * ratio);
}
static inline float cubic_out(float step, float max_steps, float max_val)
{
- float ratio = step / (max_steps - 1.0);
+ float ratio = step / (max_steps - 1.0f);
- return max_val * (pow(ratio, 3) + 1);
+ return max_val * ((ratio * ratio * ratio) + 1);
}
static inline float cubic_io(float step, float max_steps, float max_val)
{
- float ratio = step / (max_steps / 2.0);
+ float ratio = step / (max_steps / 2.0f);
if (ratio < 1)
- return max_val / 2 * pow(ratio, 3);
+ return max_val / 2 * (ratio * ratio * ratio);
- return max_val / 2 * (pow(ratio - 2, 3) + 2);
+ ratio -= 2;
+ return max_val / 2 * ((ratio * ratio * ratio) + 2);
}
/* Quartic */
static inline float quartic_in(float step, float max_steps, float max_val)
{
float ratio = step / max_steps;
- return max_val * pow(ratio, 4);
+ return max_val * (ratio * ratio * ratio * ratio);
}
static inline float quartic_out(float step, float max_steps, float max_val)
{
- float ratio = (step / max_steps) - 1.0;
+ float ratio = (step / max_steps) - 1.0f;
- return max_val + max_val * pow(ratio, 5);
+ return max_val + max_val * (ratio * ratio * ratio * ratio * ratio);
}
static inline float quartic_io(float step, float max_steps, float max_val)
{
- float ratio = step / (max_steps / 2.0);
+ float ratio = step / (max_steps / 2.0f);
if (ratio < 1)
- return max_val / 2 * pow(ratio, 4);
+ return max_val / 2 * (ratio * ratio * ratio * ratio);
- return max_val + max_val / 2 * pow(ratio -2, 5);
+ ratio -= 2;
Review comment:
the weird identation comes from the original source code having tab characters in some places and github uses tabstop=8. I didn't clean up the tabs because it introduces a lot of noise into the code review but can certainly do that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services