CodingTrain / CodingTrain/Suggestion-Box
Multiple Interpolations using a loop
- Dominant language
- No language data
- Stars
- 570
- Forks
- 85
- PR merge metrics
- No merged PRs in 30d
Description
Hello Mr. Shiffman. Thank you for your wonderful videos. My question is how to create multiple interpolations in P5 js and call each in a for loop. I tried to re-create Ben Fry's Integrator class in P5 js and use it to do what I desire but that did not succeed. I hope you can help me with this or at least give me a hint. Thank you. Here is what I have done :
```
function Integrator(value, damping, attraction)
{
this.DAMPING=0.5;
this.ATTRACTION=0.2;
this.value;
this.vel;
this.accel;
this.force;
this.mass=1;
this.damping=this.DAMPING;
this.attraction=this.ATTRACTION;
this.targeting; //boolean
this.target;
this.value=value;
this.damping=damping;
this.attraction=attraction;
this.set =function(v)
{
this.value=v;
}
this.update = function()
{
if(this.targeting)
{
this.force +=this.attraction *(this.target-this.value);
}
this.accel = this.force/this.mass;
this.vel = (this.vel+this.accel)*this.damping;
this.value +=this.vel;
this.force=0;
}
this.target = function(t)
{
this.targeting=true;
this.target=t;
}
this.noTarget = function()
{
this.targeting = false;
}
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.