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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | 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 1x 1x 1x 1x 1x 1x 47x 47x 47x 47x 47x 47x 1x 1x 501x 501x 1x 1x 707x 707x 1x 1x 501x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 289x 1x 1x 501x 281x 281x 281x 281x 281x 281x 281x 281x 281x 281x 281x 281x 281x 281x 281x 281x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x 1x | /*----------------------------------------------------------------------+
| Title: SphereElement.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: 2024, Nelson Brown, brownnrl@gmail.com |
+----------------------------------------------------------------------*/
import {GeomElement, Align} from "../GeomElement"
import {SlateCanvas} from "../../Slate";
import {PointElement} from "../point/PointElement";
import {PlaneElement} from "../plane/PlaneElement";
export interface ISphereElementConstruction {
Center? : PointElement;
A? : PointElement; // radius is AB
B? : PointElement; // A assumed to be Center unless provided
}
export class SphereElement extends GeomElement {
protected _Center : PointElement;
protected _A : PointElement; // radius is AB
protected _B : PointElement;
get Center() : PointElement { return this._Center; }
constructor(ip? : ISphereElementConstruction) {
super();
this.dimension = 2;
this._Center = ip && ip.Center || new PointElement();
this._A = ip && ip.A || this._Center;
this._B = ip && ip.B || new PointElement();
}
public drawName(c: SlateCanvas) : void {
if(this.nameColor != null && this.name != null && this.defined()) {
this.drawString(Math.round(this._Center.x), Math.round(this._Center.y), c, Align.CENTRAL);
}
}
public defined() : boolean {
return true;
}
public drawEdge(c: SlateCanvas) : void {
if (this.edgeColor == null || !this.defined()) return;
let ctx = c.getContext("2d") as CanvasRenderingContext2D;
ctx.save();
ctx.strokeStyle = this.edgeColor;
let r = this.radius();
ctx.beginPath();
// ellipse() takes (centerX, centerY, radiusX, radiusY, ...)
ctx.ellipse(
this._Center.x,
this._Center.y,
r,
r,
0,
0,
2*Math.PI);
ctx.stroke();
ctx.restore();
}
public drawFace(c: SlateCanvas) : void {
if (this.faceColor == null || !this.defined()) return;
let ctx = c.getContext("2d") as CanvasRenderingContext2D;
ctx.save();
ctx.fillStyle = this.faceColor;
let r = this.radius();
ctx.beginPath();
ctx.ellipse(
this._Center.x,
this._Center.y,
r,
r,
0,
0,
2*Math.PI);
ctx.fill();
ctx.restore();
}
public radius() : number { return this._A.distance(this._B); }
public radius2() : number { return this._A.distance2(this._B); }
public drawVertex() {}
public update(): void {}
public translate(dx: number, dy: number): void {}
public rotate(pivot: PointElement, ac: number, as : number, plane?: PlaneElement) : void {
}
}
|