Using Visual Studio 2017 and OpenFrameworks
I've drawn a triangle as follows:
ofDrawTriangle(ofPoint(0, -fHigh / 2, 0),
ofPoint(fWide / 2, fHigh / 2, 0),
ofPoint(-fWide / 2, fHigh / 2, 0));
it is drawn, translated and rotated within:
ofPushMatrix();
ofTranslate(ofVec3f(fPT.x, fPT.y, 0));
ofRotateDeg(fRotate);
ofScale(fScale);
ofDrawTriangle(ofPoint(0, -fHigh/2, 0),
ofPoint(fWide/2, fHigh/2, 0),
ofPoint(-fWide/2, fHigh/2, 0));
ofPopMatrix();
Then I want to determine if the mouse is inside this triangle. I tried this:
ofPoint pt = ofPoint(ix, iy, 0);
res = insideTriangleArea(pt, ofPoint(0,-fHigh/2, 0),
ofPoint(fWide/2, fHigh/2, 0),
ofPoint(-fWide/2, fHigh/2, 0));
[the insideTriangleArea function applies the formula for pt being within the area defined by the 3 points supplied and works for a static triangle (where the corner points are known and do not change dynamically).]
..... both within the ofPushMatrix/ofPopMatrix scope and without it which works, except, the sensitive area is in the upper left corner rather than centered at the fPT point and it does not rotate according to the value of the fRotate variable.
What have I missed?