return nearest mon if point out of range

This commit is contained in:
vaxerski 2022-05-25 18:40:03 +02:00
parent 5635c6385f
commit 08d4d987cf
4 changed files with 37 additions and 18 deletions

View file

@ -140,4 +140,10 @@ int getWorkspaceIDFromString(const std::string& in, std::string& outName) {
}
return result;
}
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2) {
const float DX = std::max((double)0, std::max(p1.x - vec.x, vec.x - p2.x));
const float DY = std::max((double)0, std::max(p1.y - vec.y, vec.y - p2.y));
return DX * DX + DY * DY;
}

View file

@ -10,5 +10,6 @@ std::string removeBeginEndSpacesTabs(std::string);
bool isNumber(const std::string&);
bool isDirection(const std::string&);
int getWorkspaceIDFromString(const std::string&, std::string&);
float vecToRectDistanceSquared(const Vector2D& vec, const Vector2D& p1, const Vector2D& p2);
float getPlusMinusKeywordResult(std::string in, float relative);