Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 2245x 1x 1x 17x 17x 17x 17x 17x 1x 1x 19034x 19034x 1x 1x 4462x 4462x 4462x 4462x 4462x 4462x 5x 5x 5x 4462x 4462x 4462x 4337x 4337x 4337x 4337x 4337x 4337x 1x | /*----------------------------------------------------------------------+
| Title: LineSlider.ts |
| A port of the software Geometry Applet by |
| Author: David E. Joyce |
| Department of Mathematics and Computer Science |
| Clark University |
| Worcester, MA 01610-1477 |
| U.S.A. |
| |
| http://aleph0.clarku.edu/~djoyce/home.html |
| djoyce@clarku.edu |
| |
| Date: February, 1996. Version 2.0.0 May, 1997. |
| TypeScript Port: 2019, Nelson Brown, brownnrl@gmail.com |
| https://www.nelsonbrown.net/ |
+----------------------------------------------------------------------*/
import {PointElement} from "./PointElement";
export class LineSlider extends PointElement {
_A : PointElement;
_B : PointElement;
_initx : number;
_inity : number;
_initz : number;
_segment : boolean;
constructor(A: PointElement, B: PointElement,
x: number, y: number, z: number, segment: boolean) {
super();
this.dimension = 0;
this.draggable = true;
this._A = A;
this._B = B;
this._x = x;
this._initx = x;
this._y = y;
this._inity = y;
this._z = z;
this._initz = z;
this._segment = segment;
if(this._A.AP == this._B.AP) this._AP = this._A.AP;
}
public reset() {
this._x = this._initx;
this._y = this._inity;
this._z = this._initz;
this.toLine(this._A, this._B, this._segment);
}
public update() {
this.toLine(this._A, this._B, this._segment);
}
public drag(tox: number, toy: number): boolean {
tox -= this._A.x;
toy -= this._A.y;
let dx : number = this._B.x - this._A.x;
let dy : number = this._B.y - this._A.y;
let factor : number = (tox*dx + toy*dy)/(dx*dx + dy*dy);
if (this._segment) {
if (factor < 0.0) factor = 0.0;
else if (factor > 1.0) factor = 1.0;
}
tox = this._A.x + dx*factor;
toy = this._A.y + dy*factor;
if ((tox-this._x)*(tox-this._x) + (tox-this._y)*(tox-this._y) < 0.5) return false;
// now drag this point
this._x = tox;
this._y = toy;
this._z = this._A.z + (this._B.z-this._A.z)*factor;
return true;
}
} |