All files / src/elements/point Layoff.ts

100% Statements 55/55
100% Branches 4/4
100% Functions 2/2
100% Lines 55/55

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 561x 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 1x 1x 1x 1x 1859x 1859x 1859x 1859x 1859x 1859x 1859x 1859x 1859x 1859x 1859x 1859x 1607x 1607x 1859x 1x 1x 14836x 14836x 14836x 14836x 1x 1x  
/*----------------------------------------------------------------------+
|    Title:	Layoff.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 Layoff extends PointElement {
 
    // Lay off a line AB with endpoint A given, so that AB is parallel to CD
    // and equal to EF.  (this is B)
 
    protected _A : PointElement;
    protected _C : PointElement;
    protected _D : PointElement;
    protected _E : PointElement;
    protected _F : PointElement;
 
 
    constructor(A: PointElement,
                C: PointElement,
                D: PointElement,
                E: PointElement,
                F: PointElement) {
        super();
        this.dimension = 0;
        this._A = A;
        this._C = C;
        this._D = D;
        this._E = E;
        this._F = F;
        if (A.AP == C.AP && A.AP == D.AP) {
            this._AP = A.AP;
        }
    }
 
    public update() {
        let factor : number = this._E.distance(this._F) / this._C.distance(this._D);
        this.to(this._D).minus(this._C);
        this.times(factor).plus(this._A);
    }
 
}