Make parallel lines

And make TODO for P2P
This commit is contained in:
ParkSuMin
2025-12-07 15:54:59 +03:00
parent 94761fecbc
commit 5c0e04df5b
7 changed files with 199 additions and 39 deletions

View File

@@ -250,6 +250,9 @@ public:
void clearByTag(int tagId, bool is_fixed_point = false);
int addConstraint(Constraint* constr);
void removeConstraint(Constraint* constr);
Constraint* get_last_constraint() {
return clist[clist.size() - 1];
}
// basic constraints
int addConstraintFixed(Point& p, int tagId = 0, bool driving = true);

View File

@@ -143,6 +143,33 @@ Line::Line(Point _p1, Point _p2, int _tag) {
tag = _tag;
}
void Line::set_tag(int _tag) {
tag = _tag;
p1.set_tag(_tag);
p2.set_tag(_tag);
}
// TODO
bool Line::contains(QPointF pos, qreal tol) const
{
double x1 = *p1.x, y1 = *p1.y;
double x2 = *p2.x, y2 = *p2.y;
double A = y1 - y2;
double B = x2 - x1;
double C = x1 * y2 - x2 * y1;
try {
double distance = abs(A * pos.x() + B * pos.y() + C) / sqrt(A * A + B * B);
return distance < tol;
}
catch (...) {
return false;
}
}
DeriVector2 Line::CalculateNormal(const Point& p, const double* derivparam) const
{
(void)p;

View File

@@ -227,11 +227,8 @@ public:
Line* Copy() override;
void draw(QPainter& p, bool highlight = false);
void set_tag(int _tag) {
tag = _tag;
p1.set_tag(_tag);
p2.set_tag(_tag);
}
void set_tag(int);
bool contains(QPointF, qreal tol = 10.0) const;
};
class Circle: public Curve