prepare for ellipse constraints

This commit is contained in:
Val Erastov (xibyte) 2020-03-10 19:46:49 -07:00
parent e7c25081e2
commit b1aabfed5c
4 changed files with 30 additions and 8 deletions

View file

@ -180,6 +180,27 @@ export const ConstraintDefinitions = {
},
PointOnEllipse: {
id: 'PointOnEllipse',
name: 'Point On Ellipse',
defineParamsScope: ([pt, ellipse], callback) => {
ellipse.visitParams(callback);
callback(new Param(0, 't'));
pt.visitParams(callback);
},
collectPolynomials: (polynomials, [p1x,p1y, p2x,p2y, r, t, px, py]) => {
const ellipsePoly = (p, t, p0, p1, p2, p3) => new Polynomial()
.monomial(-1);
polynomials.push(ellipsePoly());
polynomials.push(ellipsePoly());
},
},
PointInMiddle: {
id: 'PointInMiddle',
name: 'Middle Point',

View file

@ -1,10 +1,7 @@
import {Ref} from './ref'
import {SketchObject} from './sketch-object'
import {Constraints} from '../parametric'
import * as math from '../../math/math';
import {Circle} from "./circle";
import {EndPoint} from "./point";
import {Param} from "./param";
export class Ellipse extends SketchObject {
@ -14,9 +11,9 @@ export class Ellipse extends SketchObject {
this.ep2 = ep2;
this.addChild(this.ep1);
this.addChild(this.ep2);
this.r = new Ref(0);
this.r = new Param(0, 'R');
this.r.enforceVisualLimit = true;
this.r.set(this.radiusX * 0.5);
this.r.obj = this;
}
recoverIfNecessary() {

View file

@ -22,4 +22,8 @@ export class Param {
return this.debugSymbol + this.id;
}
visitParams(callback) {
callback(this);
}
}

View file

@ -111,7 +111,7 @@ export class EllipseTool extends Tool {
}
solveRequest(rough) {
this.solver = this.viewer.parametricManager.prepare([this.ellipse.r]);
this.solver.solve(rough, 1);
this.viewer.parametricManager.prepare([this.ellipse.r]);
this.viewer.parametricManager.solve(rough);
}
}