Skip to content

Instantly share code, notes, and snippets.

View alptugan's full-sized avatar

alp tuğan alptugan

View GitHub Profile
@xem
xem / readme.md
Last active July 14, 2024 10:15
Maths & trigonometry cheat sheet for 2D & 3D games

Conventions

  • A = [xA, yA] is a point on the 2D plane. Same for B, C, ...
  • lengths are in any unit (ex: pixels)
  • code snippets are in JavaScript

Degrees to radians

angleRad = angleDeg * Math.PI / 180;

@ofZach
ofZach / gist:787439f86753b7c6a8c6
Created November 26, 2014 05:09
singleton template
#include <stddef.h> // defines NULL
template <class T>
class Singleton{
public:
static T* Instance() {
if(!m_pInstance) m_pInstance = new T;
assert(m_pInstance != NULL);
return m_pInstance;
}
protected:
@ofZach
ofZach / gist:8829491
Created February 5, 2014 17:53
smooth line drawing input for openframeworks
#include "testApp.h"
// this can go in your h file;
ofPoint pts[5];
uint ctr;
ofPath path;
ofPolyline lineOrig;
@ofZach
ofZach / gist:5082043
Created March 4, 2013 12:48
median filter for arduino, uses bubble sort
// medianFilter filter;
// filter.addValue(5);
// filter.addValue(3);
// filter.addValue(2);
// filter.addValue(100);
// filter.addValue(9);
// Serial.println(filter.getMedian());
//
// filter.addValue(100);
// Serial.println(filter.getMedian());