mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-09 18:02:50 +01:00
make constraints for arcs applicable to circle
This commit is contained in:
parent
f4b203d96c
commit
7e663d037e
2 changed files with 9 additions and 9 deletions
|
|
@ -25,20 +25,20 @@ TCAD.TWO.ParametricManager.prototype._fetchPoints = function(objs) {
|
|||
});
|
||||
}
|
||||
if (points.length == 0) {
|
||||
throw "Illegal Argument. Constraint requires at least 1 point/line/arc."
|
||||
throw "Illegal Argument. Constraint requires at least 1 point/line/arc/circle."
|
||||
}
|
||||
return points;
|
||||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype._fetchArcs = function(objs, min) {
|
||||
TCAD.TWO.ParametricManager.prototype._fetchArkCirc = function(objs, min) {
|
||||
var arcs = [];
|
||||
for (var i = 0; i < objs.length; ++i) {
|
||||
if (objs[i]._class == 'TCAD.TWO.Arc') {
|
||||
if (objs[i]._class === 'TCAD.TWO.Arc' || objs[i]._class === 'TCAD.TWO.Circle') {
|
||||
arcs.push(objs[i]);
|
||||
}
|
||||
}
|
||||
if (arcs.length < min) {
|
||||
throw "Illegal Argument. Constraint requires at least " + min + " arcs."
|
||||
throw "Illegal Argument. Constraint requires at least " + min + " arcs/circles."
|
||||
}
|
||||
return arcs;
|
||||
};
|
||||
|
|
@ -62,13 +62,13 @@ TCAD.TWO.ParametricManager.prototype._fetchPointAndLine = function(objs) {
|
|||
return [point, line];
|
||||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype._fetchArcAndLine = function(objs) {
|
||||
TCAD.TWO.ParametricManager.prototype._fetchArcCircAndLine = function(objs) {
|
||||
|
||||
var arc = null;
|
||||
var line = null;
|
||||
|
||||
for (var i = 0; i < objs.length; ++i) {
|
||||
if (objs[i]._class == 'TCAD.TWO.Arc') {
|
||||
if (objs[i]._class === 'TCAD.TWO.Arc' || objs[i]._class === 'TCAD.TWO.Circle') {
|
||||
arc = objs[i];
|
||||
} else if (objs[i]._class == 'TCAD.TWO.Segment') {
|
||||
line = objs[i];
|
||||
|
|
|
|||
|
|
@ -43,14 +43,14 @@ TCAD.TWO.ParametricManager.prototype.perpendicular = function(objs) {
|
|||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype.tangent = function(objs) {
|
||||
var al = this._fetchArcAndLine(objs);
|
||||
var al = this._fetchArcCircAndLine(objs);
|
||||
var arc = al[0];
|
||||
var line = al[1];
|
||||
this.add(new TCAD.TWO.Constraints.P2LDistanceV( arc.c, line, arc.r ));
|
||||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype.rr = function(objs) {
|
||||
var arcs = this._fetchArcs(objs, 2);
|
||||
var arcs = this._fetchArkCirc(objs, 2);
|
||||
var prev = arcs[0].r;
|
||||
for (var i = 1; i < arcs.length; ++i) {
|
||||
this.system.push(new TCAD.TWO.Constraints.Equal(prev, arcs[i].r));
|
||||
|
|
@ -99,7 +99,7 @@ TCAD.TWO.ParametricManager.prototype.p2pDistance = function(objs, promptCallback
|
|||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype.radius = function(objs, promptCallback) {
|
||||
var arcs = this._fetchArcs(objs, 1);
|
||||
var arcs = this._fetchArkCirc(objs, 1);
|
||||
var radius = arcs[0].r.get();
|
||||
var promptDistance = promptCallback("Enter the radius value", radius.toFixed(2));
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue