Discuss Scratch

ScolderCreations
Scratcher
1000+ posts

Lerp Block

Sliverus wrote:

ScolderCreations wrote:

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
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”.

Last edited by ScolderCreations (Aug. 21, 2022 18:42:46)

-WhoAsked-
Scratcher
79 posts

Lerp Block

Za-Chary wrote:

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
PayPayFriday
Scratcher
48 posts

Lerp Block

wait
cant i just use snap?
OnTheCode99
Scratcher
500+ posts

Lerp Block

Sliverus wrote:

ScolderCreations wrote:

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

SpinningCube wrote:

“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.

SpinningCube wrote:

“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.
ima try to make this in Snap!
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.

PayPayFriday wrote:

wait
cant i just use snap?
Well, this is a suggestion for adding the block into Scratch.

Last edited by medians (June 9, 2023 13:19:17)

VedanshS933
Scratcher
1000+ posts

Lerp Block

I can't understand the concept
chriscreators14
Scratcher
500+ posts

Lerp Block

SpinningCube wrote:

“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.
Then say “number ___ % from _ to _”

Powered by DjangoBB