Vector block

In this project you will find the following blocks:

Note: you can drag and drop those images in Snap! to get the blocks! after clicking "original image".
Blocks are listed in order of dependency. So, to import last block, you need to import the previous ones.


unwrapPosition(A): if it's a vector, does nothing. If it's a sprite, extract its position as vector,


midpoint(A,B) : compute midpoint of a vector or sprites positions


length(A): length of vector


normalize(A): normalize a vector (create a unit vector with same direction)


project(A,B): projects A onto B (shadow of A cast on B if sun rays normal to B)


vector(A,B): considers A and B as point and create a vector out of them (B-A)


orthogonal(A): creates an orthogonal vector with same length (norm)


rotatet(A, theta): rotates tethat degrees

Project link: https://snap.berkeley.edu/project?username=programaths&projectname=vectors

Could I suggest coloring the points (e.g. red,green and blue) to help clarify things a bit?

I colored the points. I don't see how much it clarifies, but it was quick.

Nice idea. It took me a little while to understand it because ordinarily LENGTH means something different in Snap!. :slight_smile:

P.S. When you make a smart script pic, it automatically includes the definitions of any procedures required by the script.

Thanks. Didn't knew.