Draw an additional projection line, when showing a point-line

projected distance constraint.

[git-p4: depot-paths = "//depot/solvespace/": change = 1712]
This commit is contained in:
Jonathan Westhues 2008-05-08 00:12:23 -08:00
parent e11da119f0
commit 018e8a0444
3 changed files with 26 additions and 0 deletions

View File

@ -151,6 +151,19 @@ void Constraint::DrawOrGetDistance(Vector *labelPos) {
LineDrawOrGetDistance(pt, closest); LineDrawOrGetDistance(pt, closest);
Vector ref = ((closest.Plus(pt)).ScaledBy(0.5)).Plus(disp.offset); Vector ref = ((closest.Plus(pt)).ScaledBy(0.5)).Plus(disp.offset);
DoLabel(ref, labelPos, gr, gu); DoLabel(ref, labelPos, gr, gu);
if(workplane.v != Entity::FREE_IN_3D.v) {
// Draw the projection marker from the closest point on the
// projected line to the projected point on the real line.
lAB = (lA.Minus(lB));
double t = (lA.Minus(closest)).DivPivoting(lAB);
Vector lA = SS.GetEntity(line->point[0])->PointGetNum();
Vector lB = SS.GetEntity(line->point[1])->PointGetNum();
Vector c2 = (lA.ScaledBy(1-t)).Plus(lB.ScaledBy(t));
DoProjectedPoint(&c2);
}
break; break;
} }

1
dsc.h
View File

@ -48,6 +48,7 @@ public:
Vector WithMagnitude(double s); Vector WithMagnitude(double s);
Vector ScaledBy(double s); Vector ScaledBy(double s);
Vector ProjectInto(hEntity wrkpl); Vector ProjectInto(hEntity wrkpl);
double DivPivoting(Vector delta);
}; };
class Point2d { class Point2d {

View File

@ -275,6 +275,18 @@ Vector Vector::ProjectInto(hEntity wrkpl) {
return p0.Plus((u.ScaledBy(up)).Plus(v.ScaledBy(vp))); return p0.Plus((u.ScaledBy(up)).Plus(v.ScaledBy(vp)));
} }
double Vector::DivPivoting(Vector delta) {
double m = max(fabs(delta.x), max(fabs(delta.y), fabs(delta.z)));
if(m == fabs(delta.x)) {
return x/delta.x;
} else if(m == fabs(delta.y)) {
return y/delta.y;
} else if(m == fabs(delta.z)) {
return z/delta.z;
} else oops();
}
Point2d Point2d::Plus(Point2d b) { Point2d Point2d::Plus(Point2d b) {
Point2d r; Point2d r;
r.x = x + b.x; r.x = x + b.x;