some scratch blocks converted into desmos’s math notation.
move (n) steps |
(assuming d is the direction and P is the point to move) $$P\to P+n\left(\cos d,\sin d\right)$$ |
turn right (α) degrees |
$$d \to d - \alpha$$ |
turn left (α) degrees |
$$d \to d + \alpha$$ |
go to (random position v) |
$$P\to\left(20\operatorname{random}\left(\right)-10,20\operatorname{random}\left(\right)-10\right)$$ |
go to x: (X) y: (Y) |
$$P\to\left(X,Y\right)$$ |
glide (1) secs to (random position v) glide (1) secs to x: (0) y: (0) |
(animation is a little bit difficult to implement, use a ticker) |
point in direction (α) |
$$d\to\alpha$$scratch desmos 0 90 -90 ↻ 90 180 ↺ 0 180 270 |
change x by (dx) change y by (dy) |
$$P \to P + \left(d_x,d_y\right)$$ |
set x to (X) set y to (Y) |
$$P.x \to X$$ $$P.y \to Y$$ |
if on edge, bounce |
(desmos’s plane is practically edge-less) |
(x position) (y position) |
$$P.x$$ $$P.y$$ |
<(a) < (b)> <(a) > (b)> <(a) = (b)> |
$$\left\{a<b\right\}$$ $$\left\{a>b\right\}$$ $$\left\{a=b\right\}$$ |
<(a) and (b)> <(a) or (b)> |
$$\left\{\operatorname{total}\left(a,b\right)=\operatorname{count}\left(a,b\right)\right\}$$ $$\left\{\operatorname{total}\left(a,b\right)>0\right\}$$ |
<not (a)> |
$$\left\{a=1:\left\{1<1\right\},1\right\}$$ the {1<1} here is used as an “obviously false” inequality. |
((a) + (b)) ((a) - (b)) ((a) * (b)) ((a) / (d)) |
$$a+b$$ $$a-b$$ $$ab\text{ or }a\cdot b$$ $$\frac{a}{b}$$ |
pick random (a) to (b) |
the $\operatorname{random}\left(\right)$ function in desmos works differently enough (gives a number in $\left[0,1\right)$). a full port of scratch’s random block would be tedious. |
((a) mod (b)) |
$$\operatorname{mod}\left(a,b\right)$$ |
(round (a)) |
$$\operatorname{round}\left(a\right)$$ |
((abs v) of (a)) ((floor v) of (a)) ((ceiling v) of (a)) ((sqrt v) of (a)) ((sin v) of (a)) ((cos v) of (a)) ((tan v) of (a)) ((asin v) of (a)) ((acos v) of (a)) ((atan v) of (a)) ((ln v) of (a)) ((log v) of (a)) ((e ^ v) of (a)) ((10 ^ v) of (a)) |
$$\left|a\right|$$ $$\operatorname{floor}\left(a\right)$$ $$\operatorname{ceil}\left(a\right)$$ $$\sqrt{a}$$ $$\sin\left(a\right)$$ $$\cos\left(a\right)$$ $$\tan\left(a\right)$$ $$\arcsin\left(a\right)$$ $$\arccos\left(a\right)$$ $$\arctan\left(a\right)$$ $$\ln\left(a\right)$$ $$\log\left(a\right)$$ $$e^{a}$$ $$10^{a}$$ |
when this sprite clicked |
paste the needed commands in the “clickable” field in the point’s/line’s/polygon’s appearance properties. |
forever |
use the ticker. |
if (c) then a… :: grey else b… :: grey end |
$$\left\{c:a,b\right\}$$ |
(distance to (P1 v)) |
$$\left|P_{1}-P\right|$$ |
set [v v] to (w) |
$$v \to w$$ |
change [v v] by (w) |
$$v \to v + w$$ |
(v) |
$$v$$ |
add (j) to (l v) |
$$l \to \operatorname{join}\left(l, j\right)$$ |
delete (i) of (l v) |
$$l\to\operatorname{join}\left(l\left[0...i-1\right]\left[2...\right],l\left[i+1...\right]\right)\left[1...\operatorname{count}\left(l\right)-1\right]$$ |
delete all of (l v) |
$$l\to\left[\right]$$ |
insert (j) at (i) of (l v) |
$$l \to \left\{\left[1...\operatorname{count}\left(l\right)+1\right]<i:l,\left[1...\operatorname{count}\left(l\right)+1\right]>i:l\left[0...\right],j\right\}$$ |
replace item (i) of (l v) with (j) |
$$l \to \left\{\left[1...\operatorname{count}\left(l\right)\right]=i:j,l\right\}$$ |
(l :: list) |
$$l$$ |
(item (i) of (l v)) |
$$l\left[i\right]$$ |
(item # of (j) in (l v)) |
$$\left[1...\operatorname{count}\left(l\right)\right]\left[l=j\right]\left[1\right]$$ |
(length of (l v) :: list) |
$$\operatorname{count}\left(l\right)$$ |
define f (x) (y) (z…) … |
$$f\left(x,y,z\right)=...$$ |