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 | 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 112x 112x 112x 112x 112x 112x 112x 112x 112x 249x 249x 112x 1x 1x 499x 1096x 1096x 1096x 499x 1x 1x 3x 9x 9x 3x 1x 1x 3x 5x 5x 3x 1x | /*----------------------------------------------------------------------+
| Title: RegularPolygonElement.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 {PolygonElement} from "./PolygonElement";
import {PointElement} from "../point/PointElement";
import {PlaneElement} from "../plane/PlaneElement";
export class RegularPolygonElement extends PolygonElement {
private _cos: number;
private _sin: number;
private _P: PlaneElement;
constructor(A: PointElement, B: PointElement, plane: PlaneElement, n: number, d: number = 1) {
super();
this._P = plane;
const theta = Math.PI * d * (n - 2) / n;
this._cos = Math.cos(theta);
this._sin = Math.sin(theta);
this.V = new Array(n);
this.V[0] = A;
this.V[1] = B;
for (let i = 2; i < n; i++) {
this.V[i] = new PointElement({ AP: plane });
}
}
update(): void {
for (let i = 2; i < this.V.length; i++) {
this.V[i].to(this.V[i - 2]);
this.V[i].rotate(this.V[i - 1], this._cos, this._sin, this._P);
}
}
translate(dx: number, dy: number): void {
for (let i = 2; i < this.V.length; i++) {
this.V[i].translate(dx, dy);
}
}
rotate(pivot: PointElement, ac: number, as: number): void {
for (let i = 2; i < this.V.length; i++) {
this.V[i].rotate(pivot, ac, as, this._P);
}
}
}
|