PointF2D.ts 525 B

1234567891011121314151617181920
  1. // Represent a point on a plane, with (x,y) coordinates
  2. export class PointF2D {
  3. public x: number = 0;
  4. public y: number = 0;
  5. constructor(x: number = 0, y: number = 0) {
  6. this.x = x;
  7. this.y = y;
  8. }
  9. public static get Empty(): PointF2D {
  10. return new PointF2D();
  11. }
  12. public static pointsAreEqual(p1: PointF2D, p2: PointF2D): boolean {
  13. return (p1.x === p2.x && p1.y === p2.y);
  14. }
  15. public ToString(): string {
  16. return "[" + this.x + ", " + this.y + "]";
  17. }
  18. }