mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
Point in the middle
This commit is contained in:
parent
e4f0ccd251
commit
bf6df958cb
3 changed files with 52 additions and 0 deletions
|
|
@ -157,6 +157,10 @@ TCAD.App2D = function() {
|
|||
app.viewer.parametricManager.pointOnArc(app.viewer.selected);
|
||||
});
|
||||
|
||||
this.registerAction('pointInMiddle', "Point In the Middle", function () {
|
||||
app.viewer.parametricManager.pointInMiddle(app.viewer.selected);
|
||||
});
|
||||
|
||||
this.registerAction('llAngle', "Angle Between 2 Lines", function () {
|
||||
app.viewer.parametricManager.llAngle(app.viewer.selected, prompt);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -216,6 +216,11 @@ TCAD.TWO.ParametricManager.prototype.p2lDistance = function(objs, promptCallback
|
|||
}
|
||||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype.pointInMiddle = function(objs) {
|
||||
var pl = this._fetchPointAndLine(objs);
|
||||
this.add(new TCAD.TWO.Constraints.PointInMiddle(pl[0], pl[1]));
|
||||
};
|
||||
|
||||
TCAD.TWO.ParametricManager.prototype.pointOnArc = function(objs) {
|
||||
var points = this._fetch(objs, ['TCAD.TWO.EndPoint'], 1);
|
||||
var arcs = this._fetch(objs, ['TCAD.TWO.Arc', 'TCAD.TWO.Circle'], 1);
|
||||
|
|
@ -1169,6 +1174,48 @@ TCAD.TWO.Constraints.PointOnArc.prototype.getObjects = function() {
|
|||
|
||||
// ------------------------------------------------------------------------------------------------------------------ //
|
||||
|
||||
/** @constructor */
|
||||
TCAD.TWO.Constraints.PointInMiddle = function(point, line) {
|
||||
this.point = point;
|
||||
this.line = line;
|
||||
this.length = new TCAD.TWO.Ref(TCAD.math.distanceAB(line.a, line.b) / 2);
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.PointInMiddle.prototype.NAME = 'PointInMiddle';
|
||||
TCAD.TWO.Constraints.PointInMiddle.prototype.UI_NAME = 'Point In the Middle';
|
||||
|
||||
TCAD.TWO.Constraints.PointInMiddle.prototype.getSolveData = function() {
|
||||
var params1 = [];
|
||||
var params2 = [];
|
||||
|
||||
this.line.a.collectParams(params1);
|
||||
this.point.collectParams(params1);
|
||||
params1.push(this.length);
|
||||
|
||||
this.line.b.collectParams(params2);
|
||||
this.point.collectParams(params2);
|
||||
params2.push(this.length);
|
||||
|
||||
return [
|
||||
['P2PDistanceV', params1, []],
|
||||
['P2PDistanceV', params2, []]
|
||||
];
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.PointInMiddle.prototype.serialize = function() {
|
||||
return [this.NAME, [this.point.id, this.line.id]];
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.Factory[TCAD.TWO.Constraints.PointInMiddle.prototype.NAME] = function(refs, data) {
|
||||
return new TCAD.TWO.Constraints.PointInMiddle(refs(data[0]), refs(data[1]));
|
||||
};
|
||||
|
||||
TCAD.TWO.Constraints.PointInMiddle.prototype.getObjects = function() {
|
||||
return [this.point, this.line];
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------------------------ //
|
||||
|
||||
/** @constructor */
|
||||
TCAD.TWO.Constraints.Angle = function(p1, p2, p3, p4, angle) {
|
||||
this.p1 = p1;
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@
|
|||
<button class="btn rbtn act-lockConstraint" ><i class="fa fa-lock"></i></button>
|
||||
<button class="btn rbtn act-pointOnLine" >PL</button>
|
||||
<button class="btn rbtn act-pointOnArc" >PA</button>
|
||||
<button class="btn rbtn act-pointInMiddle" >MID</button>
|
||||
<button class="btn rbtn act-llAngle" >A</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue