Skip to content

Instantly share code, notes, and snippets.

View bvisness's full-sized avatar

Ben Visness bvisness

View GitHub Profile
@bvisness
bvisness / ship.c
Created June 15, 2019 04:11
Quick matrix transformation demo
Mat4 RotationMatrix(float radians)
{
Mat4 result;
// assuming column-major order (first index is column, second is row)
result[0][0] = Math.Cos(radians);
result[0][1] = -Math.Sin(radians);
result[1][0] = Math.Sin(radians);
result[1][1] = Math.Cos(radians);
@bvisness
bvisness / PathBot.java
Last active October 27, 2018 16:51
Example implementation of pure-pursuit path following for NXT robots
import lejos.nxt.Button;
import lejos.nxt.addon.GyroSensor;
import lejos.nxt.SensorPort;
import lejos.nxt.NXTMotor;
import lejos.nxt.MotorPort;
import javax.microedition.lcdui.Graphics;
/**
* This program makes an NXT robot drive a predetermined path. It uses the wheel tachometers (encoders) and
* a gyro sensor to keep track of the robot's position and heading, then uses a basic "pure pursuit" algorithm
@bvisness
bvisness / frequency.py
Created April 7, 2017 03:04
Music note to its frequency
import re
def frequency(note):
aFreqs = {
-1: 13.75,
0: 27.5,
1: 55.0,
2: 110.0,
3: 220.0,
4: 440.0,
@bvisness
bvisness / HandmadeMathInclude.cpp
Last active August 23, 2016 23:28
"Test" for Handmade Math
/*
* This file actually includes the implementations from HandmadeMath.h so the
* main test can link with them.
*/
#define HANDMADE_MATH_NO_INLINE
#define HANDMADE_MATH_IMPLEMENTATION
#define HANDMADE_MATH_CPP_MODE
#include "HandmadeMath.h"
@bvisness
bvisness / verbal-expression-arrays.js
Last active August 18, 2016 04:22
Verbal Expressions made better
//
// Chaining functions is kind of annoying, and seems unnecessary. Let's try
// building verbal expressions using arrays instead.
//
// (Plus let's throw some new features in, because regexes can do a lot!)
//
//
// Simple stuff can be done like this:
//