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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1287x 58x 1287x 1287x 1x 58x 58x 58x 58x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1229x 45x 1229x 1229x 1x 45x 45x 45x 45x 1x 1x 1x 1x 1x 1x | /*----------------------------------------------------------------------+
| Sector construction classes — extracted from Constructions.ts |
+----------------------------------------------------------------------*/
import {Construction, ConstructionSignature, SortedParams, AllConstructions,
SectorConstructions as SectorConstructionsEnum,
GeomElementsForUpdate} from "../Constructions";
import {GeomElement} from "../GeomElement";
import {PlaneElement} from "../plane/PlaneElement";
import {PointElement} from "../point/PointElement";
import {SectorElement} from "./SectorElement";
import {ArcElement} from "./ArcElement";
// sector — points A, B, C [, plane D = screen]
// 2D: 3 points, 0 elements — uses screen plane
// 3D: 3 points, 1 PlaneElement — uses explicit plane
// (Java: Slate.java sector case 0 — new SectorElement(A,B,C,plane))
export class SectorConstruction extends Construction {
constructionMethod: AllConstructions = SectorConstructionsEnum.sector;
signature: ConstructionSignature = { points: 3, elements: 0, integers: 0 };
public validateSignature(cm: AllConstructions, sp: SortedParams): boolean {
if (cm !== this.constructionMethod) return false;
return sp.P.length === 3 && sp.N.length === 0
&& (sp.E.length === 0 || (sp.E.length === 1 && sp.E[0] instanceof PlaneElement));
}
construct(screen: PlaneElement, P: PointElement[], E: GeomElement[], N: number[]): [GeomElementsForUpdate, GeomElement] {
let plane = E.length > 0 ? E[0] as PlaneElement : screen;
let g = new SectorElement({O:P[0], A:P[1], B:P[2], P: plane});
return [[g], g];
}
}
// sector — arc — points A, M, B [, plane D = screen]
// 2D: 3 points, 0 elements — uses screen plane
// 3D: 3 points, 1 PlaneElement — uses explicit plane
// (Java: Slate.java sector case 1 — new ArcElement(A,M,B,plane))
export class ArcConstruction extends Construction {
constructionMethod: AllConstructions = SectorConstructionsEnum.arc;
signature: ConstructionSignature = { points: 3, elements: 0, integers: 0 };
public validateSignature(cm: AllConstructions, sp: SortedParams): boolean {
if (cm !== this.constructionMethod) return false;
return sp.P.length === 3 && sp.N.length === 0
&& (sp.E.length === 0 || (sp.E.length === 1 && sp.E[0] instanceof PlaneElement));
}
construct(screen: PlaneElement, P: PointElement[], E: GeomElement[], N: number[]): [GeomElementsForUpdate, GeomElement] {
let plane = E.length > 0 ? E[0] as PlaneElement : screen;
let g = new ArcElement(P[0], P[1], P[2], plane);
return [[g], g];
}
}
export const sectorConstructions: Construction[] = [
new SectorConstruction(),
new ArcConstruction(),
];
|