/** * @return true is this vector is within the given range. */ bool RS_Vector::isInWindow(const RS_Vector& firstCorner, const RS_Vector& secondCorner) const { RS_Vector vLow( std::min(firstCorner.x, secondCorner.x), std::min(firstCorner.y, secondCorner.y)); RS_Vector vHigh( std::max(firstCorner.x, secondCorner.x), std::max(firstCorner.y, secondCorner.y)); return isInWindowOrdered(vLow,vHigh); }
bool RS_Line::hasEndpointsWithinWindow(const RS_Vector& firstCorner, const RS_Vector& secondCorner) { RS_Vector vLow( std::min(firstCorner.x, secondCorner.x), std::min(firstCorner.y, secondCorner.y)); RS_Vector vHigh( std::max(firstCorner.x, secondCorner.x), std::max(firstCorner.y, secondCorner.y)); return data.startpoint.isInWindowOrdered(vLow, vHigh) || data.endpoint.isInWindowOrdered(vLow, vHigh); }
/** * Stretches the given range of the entity by the given offset. */ void RS_Line::stretch(const RS_Vector& firstCorner, const RS_Vector& secondCorner, const RS_Vector& offset) { RS_Vector vLow( std::min(firstCorner.x, secondCorner.x), std::min(firstCorner.y, secondCorner.y)); RS_Vector vHigh( std::max(firstCorner.x, secondCorner.x), std::max(firstCorner.y, secondCorner.y)); if (getStartpoint().isInWindowOrdered(vLow, vHigh)) { moveStartpoint(getStartpoint() + offset); } if (getEndpoint().isInWindowOrdered(vLow, vHigh)) { moveEndpoint(getEndpoint() + offset); } }