Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added projectPoint
  • Loading branch information
elliotwoods committed Mar 3, 2012
1 parent dbc1f3e commit c9fe85c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ofxRay/ofProjector.cpp
Expand Up @@ -199,4 +199,11 @@ namespace ofxRay {
ofMatrix4x4 Projector::getViewProjectionMatrix() const {
return this->getViewMatrix() * this->getProjectionMatrix();
}

//----------
ofVec3f Projector::projectPoint(const ofVec3f& point) const {
ofVec4f point4(point.x, point.y, point.z, 1.0f);
point4 = point4 * this->getViewProjectionMatrix();
return ofVec3f(point4.x / point4.w, point4.y / point4.w, point4.z / point4.w);
}
}
2 changes: 2 additions & 0 deletions src/ofxRay/ofProjector.h
Expand Up @@ -51,6 +51,8 @@ namespace ofxRay {
ofMatrix4x4 getProjectionMatrix() const;
ofMatrix4x4 getViewProjectionMatrix() const;

ofVec3f projectPoint(const ofVec3f& point) const;

protected:
int width;
int height;
Expand Down

0 comments on commit c9fe85c

Please sign in to comment.