extensions icon indicating copy to clipboard operation
extensions copied to clipboard

graphics2d: Use atan2 to get coord to coord angle

Open DNin01 opened this issue 1 year ago • 7 comments

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.

DNin01 avatar May 11 '24 02:05 DNin01

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.

Xeltalliv avatar May 11 '24 12:05 Xeltalliv

you need the Cast.toNumber still

GarboMuffin avatar May 11 '24 16:05 GarboMuffin

Oh, ok!

DNin01 avatar May 11 '24 17:05 DNin01

@GarboMuffin

DNin01 avatar May 12 '24 00:05 DNin01

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 avatar May 13 '24 01:05 GarboMuffin

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

GarboMuffin avatar May 13 '24 01:05 GarboMuffin

This ok, @GarboMuffin?

DNin01 avatar May 13 '24 02:05 DNin01