TurboWarp / extensions

User-contributed unsandboxed extension gallery for TurboWarp
https://extensions.turbowarp.org/
MIT License
107 stars 219 forks source link

NOname-awa/graphics2d: Use atan2 to get coord to coord angle #1460

Closed DNin01 closed 1 month ago

DNin01 commented 1 month ago

Changed the "direction of x1,y1 to x2,y2" function to use Math.atan2. It does the same thing but with less lines of code.

Tested pretty much everything I can think of, atan2(0, 0) is 0, output ranges from -180 to 180, atan2 already auto-converts strings to numbers.

Xeltalliv commented 1 month ago

Scratch.Cast.toNumber also convertes NaN to 0. As a result, all Scratch blocks treat NaN inputs as 0 instead of letting NaN propagate like they do in JS.

GarboMuffin commented 1 month ago

you need the Cast.toNumber still

DNin01 commented 1 month ago

Oh, ok!

DNin01 commented 1 month ago

@GarboMuffin

GarboMuffin commented 1 month ago

image

original gives 225, new ones gives -135. so they're both the same actual angle but I don't know if we want to be changing how this block works

GarboMuffin commented 1 month ago

sometimes we can have a v2 of the block and then keep the old one around but hidden if it makes sense

DNin01 commented 1 month ago

This ok, @GarboMuffin?