Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lerp to Math #426

Closed
DartBot opened this issue Nov 11, 2011 · 4 comments
Closed

Add lerp to Math #426

DartBot opened this issue Nov 11, 2011 · 4 comments
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Nov 11, 2011

This issue was originally filed by [email protected]


Implementation something like

double lerp(double t, num min, num max) {
  return min + t * (max - min);
}

@DartBot
Copy link
Author

DartBot commented Nov 11, 2011

This comment was originally written by [email protected]


Removed Type-Defect label.
Added Type-Enhancement, Area-Library, Triaged labels.

@DartBot
Copy link
Author

DartBot commented Oct 19, 2012

This comment was originally written by [email protected]


i'm not sure what the libraries stance on validation is, but this method might want to:

assert(t >= 0 && t <= 1);

@DartBot
Copy link
Author

DartBot commented Apr 19, 2013

This comment was originally written by [email protected]


I'd prefer something more webgl glsl'y. So mix instead of lerp?

num mix(num min, num max, double a)
{
   return min + a * (max - min);
}

Float32x4 mix(Float32x4 min, Float32x4 max, double a)
{
   return min + (max - min).scale(a);
}

Maybe a few others?

double smoothstep(num edge0, num edge1, double val)
{
   double t = ((val - edge0) / (edge1 - edge0)).clamp(0.0, 1.0);
   return t * t * (3.0 - 2.0 * t);
}

Float32x4 smoothstep(Float32x4 edge0, Float32x4 edge1, double val)
{
   Float32x4 t = ((new Float32x4(val,val,val,val) - edge0) / (edge1 - edge0))
     .clamp(new Float32x4.zero(), new Float32x4(1.0,1.0,1.0,1.0);
   return t * t * (Float32x4(3.0,3.0,3.0,3.0) - t.scale(2.0));
}

not necessarily sure these should be in math as clamp and mod live on the datatypes Float32x4 and num (though there is no mod on Float32x4)

@floitschG
Copy link
Contributor

I think these fit better in a WebGl package. Potentially with other 3D primitives (like tools to work with Quaternions, ...).


Added NotPlanned label.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-not-planned Closed as we don't intend to take action on the reported issue type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

3 participants