Skip to content

Instantly share code, notes, and snippets.

View jaycody's full-sized avatar

Jason Stephens jaycody

View GitHub Profile
@jaycody
jaycody / pro.arcTangentToDetermineAngle.pde
Created March 11, 2014 18:00
arcTangentToDetermineAngle
// Determine THETA between 2 points with arcTangent atan2() function
int x, y;
void setup() {
size(500, 500);
x = width/2;
y = height/2;
textSize(20);
textAlign(CENTER, CENTER);
@jaycody
jaycody / py.openInteractiveShell
Created March 11, 2014 18:08
py.openInteractiveShell
# Opens interactive shell upon execution.
import code;code.interact(local=locals())
@jaycody
jaycody / .bash-prompt
Last active November 8, 2017 02:34
.bash-prompt
'''
____________COMMAND LINE PROMPT______________________
\d: Date
\h: Host computers name (eg NewTron.local)
\n: Newline
\t: Time
\u: Username
\W: Current working directory
\w: Full path to current directory
'''
@jaycody
jaycody / pro-timeStamp
Created March 12, 2014 00:07
pro-timeStamp
String timestamp;
void setup() {
timestamp = year() + nf(month(),2) + nf(day(),2) + "-" + nf(hour(),2) + nf(minute(),2) + nf(second(),2);
println(timestamp);
exit();
}
@jaycody
jaycody / .bash-colors
Created March 12, 2014 00:57
.bash-colors
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
@jaycody
jaycody / pro.KeyPressToggleSwitch
Created March 12, 2014 07:06
pro.KeyPressToggleSwitch
// KeyPress SpaceBar Toggle Switch
void keyPressed() {
if (key == ' '){
showVectors = !showVectors;
}
}
@jaycody
jaycody / pro.FlowField-Perlin
Created March 12, 2014 07:09
pro.FlowField-Perlin
//////////////////////////////////////////////////////
// Create a Perlin Noise Field
void initPerlinField() {
// Reseed Noise
noiseSeed((int)random(10000));
//TODO: make the x,y noise offset a PVector
float xOffSetNoise = 0;
// Iterate through the 2D array of PVectors
for (int i = 0; i < flowFieldCols; ++i) {
@jaycody
jaycody / pro.Vector-CalculateLength
Created March 12, 2014 07:11
pro.Vector-CalculateLength
// Calc length of vector and scale it
float lenOfSpecificVector = specificVector.mag()*scayl;
@jaycody
jaycody / pro.Polar->Cartesian-Conversion
Created March 12, 2014 07:14
pro.Polar->Cartesian-Conversion
// Convert Polar to Cartesian
// according to SOHCAHTOA, cos(theta)=1 and sin(theta) = 0 when theta = 0 (aka (1,0))
vector = new PVector(cos(theta), sin(theta));
@jaycody
jaycody / pro_NOISE-IncrementAndConvertToTHETA.pde
Last active August 29, 2015 13:57
Perlin Noise: Convert 2D perlin noise into vector field THETA
// Incrementing Noise to THETA
for (int i = 0; i < flowFieldCols; ++i) {
float yOffSetNoise = 0;
for (int j = 0; j < flowFieldRows; ++j) {
float theta = map(noise(xOffSetNoise, yOffSetNoise), 0 ,1 ,0 ,TWO_PI);
// Convert from Polar to Cartesian
// according to SOHCAHTOA, cos(theta)=1 and sin(theta) = 0 when theta = 0 (aka (1,0))
vectorField[i][j] = new PVector(cos(theta), sin(theta));