Fix should draw condition
This commit is contained in:
parent
9aef368324
commit
b6bef3c77d
1 changed files with 54 additions and 15 deletions
15
frontend/src/scripts/math/circle.ts
Normal file
15
frontend/src/scripts/math/circle.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
import { vec2 } from 'gl-matrix';
|
||||
|
||||
export class Circle {
|
||||
public constructor(public center: vec2, public radius: number) {}
|
||||
|
||||
public isInside(position: vec2): boolean {
|
||||
const distance = vec2.distance(this.center, position);
|
||||
return distance < this.radius;
|
||||
}
|
||||
|
||||
public areIntersecting(other: Circle): boolean {
|
||||
const distance = vec2.distance(this.center, other.center);
|
||||
return distance < this.radius + other.radius;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue