// < 0 слева. z координата векторного произведени¤ float TEdge::onWhichSide( Vector2f _point ) { Vector2f a = this->getEdgeVector(); Vector2f b(_point.getX() - _p2.getX(), _point.getY() - _p2.getY()); return (a.getX() * b.getY() - a.getY() * b.getX()); }
float Vector2f::zCrossProduct( Vector2f a, Vector2f b, Vector2f c ) { Vector2f ab = b - a; Vector2f bc = c - b; return (ab.getX() * bc.getY() - ab.getY() * bc.getX()); }
void Vector2f::Rotate( Vector2f pivotPoint, float angle ) { float newX, newY; newX = pivotPoint.getX() + (_x - pivotPoint.getX()) * cos(angle) + (_y - pivotPoint.getY()) * sin(angle); newY = pivotPoint.getY() + (_y - pivotPoint.getY()) * cos(angle) - (_x - pivotPoint.getX()) * sin(angle); _x = newX; _y = newY; }
float Vector2f::squareDistanceBetween( Vector2f p1, Vector2f p2 ) { float distance; Vector2f p1p2Vector; p1p2Vector.setX(p2.getX() - p1.getX()); p1p2Vector.setY(p2.getY() - p1.getY()); distance = p1p2Vector.getX() * p1p2Vector.getX() + p1p2Vector.getY() * p1p2Vector.getY(); return fabs(distance); }
float Vector2f::getCrossProduct(const Vector2f &v) const { float vx = v.getX(); float vy = v.getY(); return (x * vy) - (y * vx); }
void PopupMenu::topBar_Dragged(const Vector2f &v) { assert(modelview != NULL); position.translateX(v.getX() / modelview->getXScale()); position.translateY(v.getY() / modelview->getYScale()); }
void toggleFullscreen(void) { HWND hWnd; if(screenMode == MINIMISED || screenMode == FULLSCREEN_1) { glutSetWindow(screenMode == MINIMISED ? interfaceWindow : outputWindow); glutPositionWindow(0, 0); glutReshapeWindow(glutGet(GLUT_SCREEN_WIDTH), glutGet(GLUT_SCREEN_HEIGHT)); hWnd = FindWindow(GLUT_CLASS, screenMode == MINIMISED ? INTERFACE_WINDOW_NAME : OUTPUT_WINDOW_NAME); WIN32Utils::setWindowBorder(hWnd, false); glutSetWindow(screenMode == MINIMISED ? outputWindow : interfaceWindow); Vector2f secondMonitorBounds = WIN32Utils::getSecondMonitorBounds(); glutPositionWindow(glutGet(GLUT_SCREEN_WIDTH), 0); glutReshapeWindow(secondMonitorBounds.getX(), secondMonitorBounds.getY()); hWnd = FindWindow(GLUT_CLASS, screenMode == MINIMISED ? OUTPUT_WINDOW_NAME : INTERFACE_WINDOW_NAME); WIN32Utils::setWindowBorder(hWnd, false); screenMode = (screenMode == MINIMISED ? FULLSCREEN_1 : FULLSCREEN_2); } else { glutSetWindow(interfaceWindow); glutPositionWindow(10, 25); glutReshapeWindow(DEFAULT_WIDTH, DEFAULT_HEIGHT); hWnd = FindWindow(GLUT_CLASS, INTERFACE_WINDOW_NAME); WIN32Utils::setWindowBorder(hWnd, true); glutSetWindow(outputWindow); glutPositionWindow(10, 25); glutReshapeWindow(DEFAULT_WIDTH, DEFAULT_HEIGHT); hWnd = FindWindow(GLUT_CLASS, OUTPUT_WINDOW_NAME); WIN32Utils::setWindowBorder(hWnd, true); screenMode = MINIMISED; } }
float Vector2f::getDotProduct(const Vector2f &v) const { return (x * v.getX()) + (y * v.getY()); }
Vector2f Vector2f::operator-( const Vector2f &other ) const { return Vector2f(_x - other.getX(), _y - other.getY()); }
Vector2f Vector2f::operator+( const Vector2f &other ) const { return Vector2f(_x + other.getX(), _y + other.getY()); }
void Point2f::translate(const Vector2f &tv) { translateX(tv.getX()); translateY(tv.getY()); }