View rect_clipper.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <SDL.h> | |
#define min(a,b) (((a)<(b))?(a):(b)) | |
#define max(a,b) (((a)>(b))?(a):(b)) | |
typedef int bool; | |
typedef struct{ |
View binary_search_VS_division.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Testing Binary tree searches against straight floating point multiplication | |
specifically for the purpose of placing coordinates into 'zones' (grid cells) | |
*/ | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
#include <math.h> | |
#include <string.h> |
View approximate_heading.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef struct vec2d_struct{ | |
double x, y; | |
} vec2d; | |
double v2d_rough_heading8(vec2d v){ | |
if( v.x > 0 ){ | |
if( v.y > 0 ){ | |
if( v.x < v.y ) return 1.1780972450961724;// 3/8 PI | |
else return 0.3926990816987241;// 1/8 PI; | |
} |
View mazes.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define UP 1 | |
#define RIGHT 2 | |
#define DOWN 4 | |
#define LEFT 8 | |
#define DEAD 16 | |
#define MASKED 32 | |
#define white 0xffffffff | |
#define black 0xff000000 | |
#define transparent 0x00000000 |
View Drawing_Order_Planets.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float theta; | |
boolean over; | |
void setup() { | |
size(400, 400); | |
theta = HALF_PI; | |
over = true; | |
} | |
void draw() { | |
background(0); |
View Binary_Clock.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Simple Binary Clock in Processing. | |
Relogio Binario simples em Processing. | |
*/ | |
float tx, ty, dx, dy; | |
void setup() { | |
size(400, 350); | |
tx = width / 9f; | |
ty = height / 3f; |
View input_event_monitor.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int Z, W; | |
String[] titles = { "frame", "mousePressed()", "mouseDragged()", "mouseReleased()", "mouseClicked()", "mouseWheel()", "keyPressed()", "keyReleased()", "keyTyped()" }; | |
float x, h, M; | |
float[] y; | |
void setup(){ | |
size(1200, 300); | |
x = 0; | |
for( int i = 0; i < titles.length; ++i ) if( textWidth( titles[i] ) > x ) x = textWidth( titles[i] ); |
View Grav.pde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArrayList<Particle> PS; //Here's our array of objects | |
IntList marked; | |
float G = 0.2, one_over_pi = 1/PI; | |
float cx, cy; | |
float torus_x, torus_y, torus_l, torus_b, torus_w, torus_h; // position and dimensions of the torus box. | |
byte background_mode = 0; | |
boolean record = false; //true; // |
View Basic Gravity.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void gravitate( Particle p ){ | |
PVector grav = new PVector(1,0); | |
grav.setMag( G*(p.area()) / sq( constrain(dist(pos.x, pos.y, p.pos.x, p.pos.y), 1, 100000) ) ); | |
grav.rotate(atan2(p.pos.y - pos.y, p.pos.x - pos.x )); | |
acc.add(grav); | |
} |
View Tori.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This creates a toroidal topology, | |
hence the name of the method and variables I used to accomplish this. | |
A torus is a doughnut shape, we say that these top-bottom and right-left | |
"warps" form a toroidal topology because | |
the only way to take a piece of paper and fold it such that | |
it actually connects those edges in that way | |
is to make a doughnut shape with it. |
NewerOlder