mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
add type to Point.dist and fix error
This commit is contained in:
parent
1599a765c5
commit
d0e82c10cd
@ -114,7 +114,7 @@ class Point {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Functions
|
// Functions
|
||||||
dist() { return Math.sqrt(this.x * this.x + this.y * this.y); }
|
dist(): number { return Math.sqrt(this.x * this.x + this.y * this.y); }
|
||||||
|
|
||||||
// Static members
|
// Static members
|
||||||
static origin = new Point(0, 0);
|
static origin = new Point(0, 0);
|
||||||
@ -137,9 +137,9 @@ class Point3D extends Point {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Overwrite
|
// Overwrite
|
||||||
dist() {
|
dist(): number {
|
||||||
let d = super.dist();
|
let d = super.dist();
|
||||||
return Math.sqrt(d() * d() + this.z * this.z);
|
return Math.sqrt(d * d + this.z * this.z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user