Fix should draw condition
This commit is contained in:
parent
9aef368324
commit
b6bef3c77d
2 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,13 +1,10 @@
|
|||
import { Typed } from '../transport/serializable';
|
||||
import { vec2 } from 'gl-matrix';
|
||||
|
||||
export class Rectangle extends Typed {
|
||||
export class Rectangle {
|
||||
public constructor(
|
||||
public topLeft: vec2 = vec2.create(),
|
||||
public size: vec2 = vec2.create()
|
||||
) {
|
||||
super();
|
||||
}
|
||||
) {}
|
||||
|
||||
public isInside(position: vec2): boolean {
|
||||
const translated = vec2.subtract(vec2.create(), position, this.topLeft);
|
||||
|
|
|
|||
Loading…
Reference in a new issue