From da18f0940218fbf64dd1303fd2fafd5cc09f5d5f Mon Sep 17 00:00:00 2001 From: "Val Erastov (xibyte)" Date: Tue, 3 Mar 2020 00:26:21 -0800 Subject: [PATCH] radius constraint --- web/app/sketcher/actions/constraintActions.js | 32 +++++++++++++++++++ web/app/sketcher/constr/ANConstraints.js | 23 +++++++++++++ 2 files changed, 55 insertions(+) diff --git a/web/app/sketcher/actions/constraintActions.js b/web/app/sketcher/actions/constraintActions.js index 468c06af..0dca9d31 100644 --- a/web/app/sketcher/actions/constraintActions.js +++ b/web/app/sketcher/actions/constraintActions.js @@ -263,6 +263,38 @@ export default [ } }, + { + id: 'RadiusLength', + shortName: 'RadiusLength', + description: 'Radius Length', + selectionMatcher: (selection) => { + for (let obj of selection) { + if (!(isInstanceOf(obj, Circle) || isInstanceOf(obj, Arc))) { + return false; + } + } + return true; + }, + + invoke: ctx => { + const {viewer} = ctx; + + const [firstCircle, ...others] = viewer.selected; + + const firstConstr = new AlgNumConstraint(ConstraintDefinitions.RadiusLength, [firstCircle]); + firstConstr.initConstants(); + + editConstraint(ctx, firstConstr, () => { + const pm = viewer.parametricManager; + pm._add(firstConstr); + for (let other of others) { + pm._add(new AlgNumConstraint(ConstraintDefinitions.RadiusLength, [other], {...firstConstr.constants})); + } + pm.commit(); + }); + } + }, + { id: 'DistancePL', shortName: 'Point to Line Distance', diff --git a/web/app/sketcher/constr/ANConstraints.js b/web/app/sketcher/constr/ANConstraints.js index 1b3dabd3..596f0603 100644 --- a/web/app/sketcher/constr/ANConstraints.js +++ b/web/app/sketcher/constr/ANConstraints.js @@ -369,6 +369,29 @@ export const ConstraintDefinitions = { } }, + + RadiusLength: { + id: 'RaduisLength', + name: 'Raduis Length', + constants: { + length: { + type: 'number', + description: 'length of the raduis', + initialValue: ([c]) => { + return c.r.get(); + }, + }, + }, + defineParamsScope: ([c], callback) => { + callback(c.r); + }, + + collectPolynomials: (polynomials, [r], {length}) => { + polynomials.push(new Polynomial(-length).monomial(1).term(r, POW_1_FN)); + }, + + }, + Polar: { id: 'Polar', name: 'Polar Coordinate',