Skip to content

Instantly share code, notes, and snippets.

@patriciogonzalezvivo
Created September 20, 2013 12:52
Show Gist options
  • Save patriciogonzalezvivo/6637016 to your computer and use it in GitHub Desktop.
Save patriciogonzalezvivo/6637016 to your computer and use it in GitHub Desktop.
void rotateTo(ofPoint _dir){
ofVec3f newTarget = _dir;
newTarget.normalize();
ofVec3f up( 0, -1, 0 );
ofVec3f axis = up.crossed( newTarget );
axis.normalize();
float angle = up.angle( newTarget );
ofRotate( angle, axis.x, axis.y, axis.z );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment