Discuss Scratch

HTML-Fan
Scratcher
1000+ posts

Additional operator blocks

Hello!

Something that is sometimes really annoying is the lack of an atan2 and an a²+b²=c² function. Would blocks like this be possible:
([ atan2] of (a) and (b) :: operators)
([ sqrt(a²+b²)] of (a) and (b) :: operators)
I know that you can build them, but it's annoying and less understandable.

Last edited by HTML-Fan (June 26, 2020 19:08:14)

fdreerf
Scratcher
1000+ posts

Additional operator blocks

This would require a new block with two inputs, and at that point it becomes unclear what functions to put in it.
Do we put every function and equation with two inputs?
HTML-Fan
Scratcher
1000+ posts

Additional operator blocks

No, you don't need
([abs] of (x) or (y) :: operators)
, do you?
Oops, I made a mistake. I mean sqrt(a²+b²).
And atan and atan2 are different things.

Last edited by HTML-Fan (June 26, 2020 18:35:20)

HTML-Fan
Scratcher
1000+ posts

Additional operator blocks

Something like
(constrain (value) (min) (max) :: operators)
would also be really useful for collision detection between circles and rectangles.

Last edited by HTML-Fan (June 26, 2020 18:45:10)

Seth_Zaw
Scratcher
100+ posts

Additional operator blocks

I dunno what “atan2” means, but I have a workaround for the bottom block:
(((a)*(a)) + ((b)*(b)))
Seth_Zaw
Scratcher
100+ posts

Additional operator blocks

HTML-Fan wrote:

Something like
(constrain (value) (min) (max) :: operators)
would also be really useful for collision detection between circles and rectangles.
Why can't you use
<touching [rectangle v] ?>
HTML-Fan
Scratcher
1000+ posts

Additional operator blocks

Seth_Zaw wrote:

I dunno what “atan2” means, but I have a workaround for the bottom block:
(((a)*(a)) + ((b)*(b)))
atan2 is something like point to x: () y: () and you need about 8 blocks below each other to build it, so it looks kinda ugly.
Yes, a workaround, but I want it to be on hand when I need it, I don't want to build it.

Seth_Zaw wrote:

HTML-Fan wrote:

Something like
(constrain (value) (min) (max) :: operators)
would also be really useful for collision detection between circles and rectangles.
Why can't you use
<touching [rectangle v] ?>
That works with sprites. But I code pen engines, because I don't like sprites and their collision detection.

Last edited by HTML-Fan (June 26, 2020 19:07:31)

Seth_Zaw
Scratcher
100+ posts

Additional operator blocks

HTML-Fan wrote:

Seth_Zaw wrote:

I dunno what “atan2” means, but I have a workaround for the bottom block:
(((a)*(a)) + ((b)*(b)))
atan2 is something like point to x: () y: () and you need about 8 blocks below each other to build it, so it looks kinda ugly.
Yes, a workaround, but I want it to be on hand when I need it, I don't want to build it.

Seth_Zaw wrote:

HTML-Fan wrote:

Something like
(constrain (value) (min) (max) :: operators)
would also be really useful for collision detection between circles and rectangles.
Why can't you use
<touching [rectangle v] ?>
That works with sprites. But I code pen engines, because I don't like sprites and their collision detection.
Too bad! You'll just have to use sprites, because constrains are really confusing to beginner Scratchers.
HTML-Fan
Scratcher
1000+ posts

Additional operator blocks

Seth_Zaw wrote:

Too bad! You'll just have to use sprites, because constrains are really confusing to beginner Scratchers.
I could use
set [result v] to [value]
if <[result] < [min]> then
set [result v] to [min]
end
if <[result] > [max]> then
set [result v] to [max]
end
but for a rectangle you have to do this twice and that makes the collision detection code really long.
And why is it confusing? It just keeps the value between a min and a max value.

Last edited by HTML-Fan (June 26, 2020 19:17:00)

HTML-Fan
Scratcher
1000+ posts

Additional operator blocks

Maybe those operators with multiple inputs could be included in
([ v] of (9) :: operators)

Last edited by HTML-Fan (June 27, 2020 08:20:37)

HTML-Fan
Scratcher
1000+ posts

Additional operator blocks

*bump*
This isn't confusing. It's more confusing to see the lack of such a function.

Powered by DjangoBB