Determining the coordinates of the corners of an ofxRay::Plane addon

hello there,
I have created a plane in 3d space using @elliotwoods ofxRay::Plane addon.
The plane is described by a normal vector N, the center point C which lies on the plane. Both are in world coordinates.

The plane is not infinite so it is really more like a orthogonal box rather than a plane, which stretches in 2 dimensions determined by the stretch(xstretch,ystretch,1) “S” operation. x & y stretches are dimensionless wrt a coordinate system on the plane.

Overall, the finite plane is therefore described by N,C and S.

I wonder if I am able to determine the world coordinates of the corners from the available data.
Additionally, I wonder what do the up and forward vectors do, which exist in the class. Could I use perhaps those to aid in finding the corners?

Thank you in advance for your help

I don’t know about elliot’s class (and not sure if this is helpful), but I personally find ofNode very useful, since you can move things in a relative coordinate system and then get global information out (and it works well for nested nodes). For example, here’s a center point with 4 corners, defining a plane:

in h file:

    ofNode center;
    ofNode corners[4];

in .cpp file:

void ofApp::setup(){

    for (int i = 0; i < 4; i++){
    corners[0].setPosition(-200, -200, 0);
    corners[1].setPosition(200, -200, 0);
    corners[2].setPosition(200, 200, 0);
    corners[3].setPosition(-200, 200, 0);

void ofApp::update(){

    center.rotate(1, 0, 1, 1);

void ofApp::draw(){

    for (int i = 0; i < 4; i++){
    for (int i = 0; i < 4; i++){
        ofPoint pt = corners[i].getGlobalPosition();
        ofDrawBitmapStringHighlight( ofToString(pt), pt + ofPoint(50,0,0));

hi @zach .
thank you for the suggestion. .i’m not sure if ofNode would be suitable in may case.

you see I create my plane from 4 other points. these are located roughly i n the corners of where the plane will come to be , but not exactly. these points are on world coordinates as returned with the ofxHeadPoseEstimator.

now I take the average of the 4 points to find my C point and I calculate the vectors between the original points on order to calculate the normal toto my plane.

finally I use the average distance between almost parallel vectors to determine the length of the sides of my plane.

what I’m saying is that once have my plane. the original points don’t matter so much anymore. unless you tell Me I could use them along with ofnode somehow. .

  • you can get the corner positions by taking them from the rays returned by ofPlane:: getCornerRaysTo
  • an infinite plane is defined by a point on the plane and a normal vector
  • a finite plane also needs: an ofVec2f scale, an ‘up vector’ which is parallel to the plane, and a ‘right vector’ which is perpendicular to the up vector but parallel to the plane
  • using the point on the plane (the center), the up and right vectors, and the scale, it’s possible to determine the corners (that’s how ‘getCornerRaysTo’ works)

Hi @elliotwoods
thank you for the reply. to declare a finite plane I seem to need to determine the up vector on my own.
Using definition

`Plane::Plane(ofVec3f center, ofVec3f normal, ofVec3f up, ofVec2f scale)`

How can I do that? correct me if i’m wrong, but I think that if i take any random vector V and the cross product to the normal vector, I will end up with a vector that is parallel to the plane (actually on the plane) , but this vector will not necessarily be looking “up” - its orientation may be pointing anywhere. Thus, it will not intersect the (arbitrary) upper border of the finite plane perpendicularly.
So how can I get the “up” vector?

I see that if I use the other constructor

`Plane::Plane(ofVec3f center, ofVec3f normal)`

up is calculated directly from the normal provided in a weird recursive looking fashion

`this->up = this->up - this->up * this->>normal)`

so up = up - up * ??!?!?! (line 163 in plane.cpp. looking into branch 0.8.0)

In any case, can I use the latter constructor and then plane::setInfinite(false) and I should be fine?
If not, can (and should) I set “up” vector arbitrarily to something like ofVec3f(0,1,0) ?

thank you!

up = up - up *

this appears to be a bug. it was intended to remove the component of the up vector which is parallel to the normal. it should read:

up = up - normal * up.getNormalized().dot(normal)

i’ll change now.

and yes, the answer to your question is to use the Plane’s up vector