Skip to content

Instantly share code, notes, and snippets.

@alaeddine-13
alaeddine-13 / main.ino
Last active October 26, 2020 18:06
Tunirobots 2018 (robotics competition) Autonomous robot code. The robot is based on a PID controller + optic encoders to control distance and orientation, Serial to read instructions, EEPROM to store and load instructions and servo motors + stepper motor to do actions.
#include <EEPROM.h>
#include <Servo.h>
Servo servo1, servo2, servo3, servo4, servo5, servo6, servo7;
///////////////////////
//EEPROM variables
#define mode 1
#define test_mode 0
#define EEPROM_mode 1
@alaeddine-13
alaeddine-13 / quadtree.js
Created October 26, 2020 13:50
Quadtree implementation that was used to optimize crashy.io. Quadtree is used to optimize collision detection and reduce the time complexity for checks from O(n²) to O(n log (n))
//******************* QuadTree Implementation *******************
var getX = function(item){
return item.x - item.width/2;
}
var getY = function(item){
return item.y - item.height/2;
}
function QuadTree(bounds, pointQuad, maxDepth, maxChildren) {
var node;
if (pointQuad) {