radius constraint

This commit is contained in:
Val Erastov (xibyte) 2020-03-03 00:26:21 -08:00
parent 6c4c72cc56
commit da18f09402
2 changed files with 55 additions and 0 deletions

View file

@ -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',

View file

@ -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',