Skip to content

Instantly share code, notes, and snippets.

@underdoeg
Created August 14, 2011 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save underdoeg/1145079 to your computer and use it in GitHub Desktop.
Save underdoeg/1145079 to your computer and use it in GitHub Desktop.
math stuff
#include "mathPlaygroundApp.h"
ofVec2f v1;
ofVec2f v2;
ofVec2f between;
//--------------------------------------------------------------
void mathPlaygroundApp::setup(){
ofSetWindowTitle("mathPlaygroundApp");
ofBackground(0,0,0);
keyReleased(' ');
//v1.set(0, 200);
}
//--------------------------------------------------------------
void mathPlaygroundApp::update(){
v2.set(mouseX-ofGetWidth()*.5, mouseY-ofGetHeight()*.5);
between = v1.getPerpendicular();
between -= v2.getPerpendicular();
between.scale(400);
}
//--------------------------------------------------------------
void mathPlaygroundApp::draw(){
ofTranslate(ofGetWidth()*.5, ofGetHeight()*.5);
ofVec2f center(0,0);
ofSetColor(255);
ofLine(center, v1);
ofLine(center, v2);
ofSetColor(255, 0, 0);
ofLine(center, between);
}
//--------------------------------------------------------------
void mathPlaygroundApp::keyPressed(int key){
}
//--------------------------------------------------------------
void mathPlaygroundApp::keyReleased(int key){
v1.set(ofRandom(-500, 500), ofRandom(-500, 500));
}
//--------------------------------------------------------------
void mathPlaygroundApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void mathPlaygroundApp::mouseDragged(int x, int y, int button){
}
//--------------------------------------------------------------
void mathPlaygroundApp::mousePressed(int x, int y, int button){
}
//--------------------------------------------------------------
void mathPlaygroundApp::mouseReleased(int x, int y, int button){
}
//--------------------------------------------------------------
void mathPlaygroundApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void mathPlaygroundApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void mathPlaygroundApp::dragEvent(ofDragInfo dragInfo){
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment