Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » power squared
- Lu_Li_49
-
Scratcher
100+ posts
power squared
hello, I would like to know if there is a block
(number) ² ::operatorsin scratch?
Last edited by Lu_Li_49 (Nov. 26, 2024 17:37:13)
- asdf1546
-
Scratcher
33 posts
power squared
To get x^2, just use
If you want to take any power, like x^y, try:
(((x)) * ((x)))
If you want to take any power, like x^y, try:
([e^ v] of (((y)) * ([ln v] of ((x))::operators))::operators)
- Lu_Li_49
-
Scratcher
100+ posts
power squared
I just wanted to know if there was a block
((number) squared ::operator)because in this code
([sqrt v] of (((([x v] of [Sprite1 v]) - ([x v] of [Sprite2 v])) * (([x v] of [Sprite1 v]) - ([x v] of [Sprite2 v]))) + ((([y v] of [Sprite1 v]) - ([y v] of [Sprite2 v])) * (([y v] of [Sprite1 v]) - ([y v] of [Sprite2 v]))))::operators)it's a bit long…
Last edited by Lu_Li_49 (Nov. 26, 2024 18:08:36)
- ametrine_
-
Scratcher
1000+ posts
power squared
I just wanted to know if there was a blockyou might be able to use the (number) * (number) method to get the squared value and put it in a variable, that way you won't have to use the block so many times((number) squared ::operator)because in this code([sqrt v] of (((([x v] of [Sprite1 v]) - ([x v] of [Sprite2 v])) * (([x v] of [Sprite1 v]) - ([x v] of [Sprite2 v]))) + ((([y v] of [Sprite1 v]) - ([y v] of [Sprite2 v])) * (([y v] of [Sprite1 v]) - ([y v] of [Sprite2 v]))))::operators)it's a bit long…
- medians
-
Scratcher
1000+ posts
power squared
Or sth like this to prevent repeating tooI just wanted to know if there was a blockyou might be able to use the (number) * (number) method to get the squared value and put it in a variable, that way you won't have to use the block so many times((number) squared ::operator)because in this code([sqrt v] of (((([x v] of [Sprite1 v]) - ([x v] of [Sprite2 v])) * (([x v] of [Sprite1 v]) - ([x v] of [Sprite2 v]))) + ((([y v] of [Sprite1 v]) - ([y v] of [Sprite2 v])) * (([y v] of [Sprite1 v]) - ([y v] of [Sprite2 v]))))::operators)it's a bit long…
define dist between (sprite 1) and (sprite 2)I have no idea why there isn't a report block yet, though you could also have:
set [delta x v] to (([x position v] of (sprite 1)) - ([x position v] of (sprite 2))
set [delta y v] to (([y position v] of (sprite 1)) - ([y position v] of (sprite 2))
set [result v] to ([sqrt v] of (((delta x) * (delta x)) + ((delta y) * (delta y)))
define square of (number)Also, there's already a distance to () blocks if you aren't aware, and the x and y should be “x position” and “y position”
set [result v] to ((number) * (number))
Last edited by medians (Nov. 26, 2024 20:29:33)
- THEIMPORTANT
-
Scratcher
100+ posts
power squared
i can do in 3 blocks
why didnt you just that?
go to [point 1]
set [distance] to (distance to [point2])
why didnt you just that?
- SpyCoderX
-
Scratcher
1000+ posts
power squared
i can do in 3 blocksDoesn’t work for distance to a point. (An x y position)go to [point 1]
set [distance] to (distance to [point2])
why didnt you just that?
- Discussion Forums
- » Help with Scripts
-
» power squared






