mirror of
https://github.com/xibyte/jsketcher
synced 2026-04-02 03:24:47 +02:00
radius constraint
This commit is contained in:
parent
6c4c72cc56
commit
da18f09402
2 changed files with 55 additions and 0 deletions
|
|
@ -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',
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in a new issue