Discuss Scratch
- ScolderCreations
-
Scratcher
1000+ posts
Lerp Block
Let's remove all the text from the blocks and replace them with numbers, and just wait for all the questions to flood in about which block is which. That would be “hilarious”.I like this block and I think it would be very useful. However, I'm sure there's a better way to word it. Most people aren't going to understand what that means, so perhaps pick a name that makes it clear what it's doing?But lerp is funnier, and they can just ask about it to another Scratcher or in QAS
Last edited by ScolderCreations (Aug. 21, 2022 18:42:46)
- -WhoAsked-
-
Scratcher
79 posts
Lerp Block
What does “lerp” mean in this context, and how can it be used?Lerp is just linear interpolation, it pretty much is used to get a percentage in between 2 numbers,
so lerp(5,10,50%) = 5, lerp(5,10,100%) = 10, lerp(5,10,0%) = 5
- OnTheCode99
-
Scratcher
500+ posts
Lerp Block
I like this block and I think it would be very useful. However, I'm sure there's a better way to word it. Most people aren't going to understand what that means, so perhaps pick a name that makes it clear what it's doing?But lerp is funnier, and they can just ask about it to another Scratcher or in QAS
Keep in mind that scratch has tons of beginner coders in it. New Scratchers probably won’t understand what that means unless they are an expert at math.
- PayPayFriday
-
Scratcher
48 posts
Lerp Block
“lerp” is short for linear interpolation.
It's basically blending between two numbers
Here's a definition (not optimized):define (lerp from (a::custom) to (b::custom) % (percentage::custom) :: operators
return ((((1) - ((percentage::custom) / (100))) * (a::custom)) + (((percentage::custom) / (100)) * (b::custom))) :: custom
Examples:
At 0%, number a is returned
At 100%, number b is returned
At 50%, the number halfway between a and b is returned
At 25%, the number 1/4 of the way from a to b is returned
Usually instead of 0% to 100% a number between 0 and 1 is used, but this could also work.
“lerp” is short for linear interpolation.ima try to make this in Snap!
It's basically blending between two numbers
Here's a definition (not optimized):define (lerp from (a::custom) to (b::custom) % (percentage::custom) :: operators
return ((((1) - ((percentage::custom) / (100))) * (a::custom)) + (((percentage::custom) / (100)) * (b::custom))) :: custom
Examples:
At 0%, number a is returned
At 100%, number b is returned
At 50%, the number halfway between a and b is returned
At 25%, the number 1/4 of the way from a to b is returned
Usually instead of 0% to 100% a number between 0 and 1 is used, but this could also work.
- medians
-
Scratcher
1000+ posts
Lerp Block
Shouldn't this just go in the Operators category though (it was originally called Numbers but was renamed because string handling blocks were implemented in Scratch 1.4), instead of a new category?
Anyway, Scratchers, especially newer ones, might not know or understand what lerp means and/or does.
Anyway, Scratchers, especially newer ones, might not know or understand what lerp means and/or does.
waitWell, this is a suggestion for adding the block into Scratch.
cant i just use snap?
Last edited by medians (June 9, 2023 13:19:17)
- chriscreators14
-
Scratcher
500+ posts
Lerp Block
“lerp” is short for linear interpolation.Then say “number ___ % from _ to _”
It's basically blending between two numbers
Here's a definition (not optimized):define (lerp from (a::custom) to (b::custom) % (percentage::custom) :: operators
return ((((1) - ((percentage::custom) / (100))) * (a::custom)) + (((percentage::custom) / (100)) * (b::custom))) :: custom
Examples:
At 0%, number a is returned
At 100%, number b is returned
At 50%, the number halfway between a and b is returned
At 25%, the number 1/4 of the way from a to b is returned
Usually instead of 0% to 100% a number between 0 and 1 is used, but this could also work.






