From fe75efc6aaec589921dcaa0f44845956f331f2e4 Mon Sep 17 00:00:00 2001 From: Jonathan Westhues Date: Sat, 21 Jun 2008 23:32:50 -0800 Subject: [PATCH] Make the point-on-circle constraints work on the infinite cylinder, not the sphere; that's more logical behaviour out of plane. [git-p4: depot-paths = "//depot/solvespace/": change = 1803] --- constraint.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/constraint.cpp b/constraint.cpp index 1612841..34045ab 100644 --- a/constraint.cpp +++ b/constraint.cpp @@ -710,10 +710,21 @@ void Constraint::GenerateReal(IdList *l) { break; case PT_ON_CIRCLE: { + // This actually constrains the point to lie on the cylinder. Entity *circle = SS.GetEntity(entityA); - hEntity center = circle->point[0]; - Expr *radius = circle->CircleGetRadiusExpr(); - AddEq(l, Distance(workplane, ptA, center)->Minus(radius), 0); + ExprVector center = SS.GetEntity(circle->point[0])->PointGetExprs(); + ExprVector pt = SS.GetEntity(ptA)->PointGetExprs(); + Entity *normal = SS.GetEntity(circle->normal); + ExprVector u = normal->NormalExprsU(), + v = normal->NormalExprsV(); + + Expr *du = (center.Minus(pt)).Dot(u), + *dv = (center.Minus(pt)).Dot(v); + + Expr *r = circle->CircleGetRadiusExpr(); + + AddEq(l, + ((du->Square())->Plus(dv->Square()))->Minus(r->Square()), 0); break; }