Dot Product

Scene.my.dotProduct := (a, b) => {
    a(0) * b(0) + a(1) * b(1);
};

Rotate Vector

scene.my.rotateVector := (vec, angle)=>{
	c := math.cos(angle);
	s := math.sin(angle);
	[vec(0) * c - vec(1) * s, vec(0) * s + vec(1) * c]
};

Lerp Angle

scene.my.lerpAngle := (a, b, t) => {
	diff := b - a;
	r := 0;
	na := a;
	nb := b;
	diff > math.pi ? {
		na = a + math.pi * 2;
		nb = b
	} : {
		diff < - math.pi ? {
			na = a;
			nb = b + math.pi * 2
		} : {}
	};
	r = math.lerp(na, nb, t);
	r > math.pi ? {
		r = r - math.pi * 2
	} : {};
	r
}

Abs

scene.my.abs := (x)=>{
	x < 0 ? { - x } : { x }
};

Invoke

scene.my.invoke := (time, func)=>{
	obj := scene.addCircle({
		pos := [0, 0];
		radius := 1;
		collideSet := 0;
		density := +inf;
		color := [0, 0, 0, 0];
		timeToLive := time;
		_code := func;
		onDie := (e)=>{
			_code(e)
		}
	});
}
© Lunnidoo 2025