Skip to content

Instantly share code, notes, and snippets.

View larsberg's full-sized avatar
💭
Big up to my github brethren

Lars Berg larsberg

💭
Big up to my github brethren
View GitHub Profile
@larsberg
larsberg / exportFBOImage
Created June 24, 2014 18:25
save OF fbo to image
void exportFbo(ofFbo& _fbo)
{
auto path = ofSystemSaveDialog("fbo.png", "save as");
ofShortPixels pixels;
_fbo.readToPixels(pixels);
ofSaveImage(pixels, path.getPath());
}
@larsberg
larsberg / ClosestPointOnLine for openframeworks
Last active May 19, 2021 00:28
closest point on line in OF.
//closest point on line
//http://paulbourke.net/geometry/pointlineplane/
ofVec3f closestPointOnLine(ofVec3f p, ofVec3f l0, ofVec3f l1 )
{
if(l0 == l1) return ofVec3f();
float u = (((p.x-l0.x) * (l1.x-l0.x)) + ((p.y-l0.y) * (l1.y-l0.y)) + ((p.z-l0.z) * (l1.z-l0.z))) / l1.distanceSquared( l0 );
if( u < 0.0f )
return l0;