Three types of collision and a polygon class
This commit is contained in:
16
collision/aa.ts
Normal file
16
collision/aa.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { Point } from "../geometry/vector.ts";
|
||||
|
||||
export type axisAlignedBoundingBox = {
|
||||
w: number;
|
||||
h: number;
|
||||
} & Point;
|
||||
|
||||
export const axisAlignedCollision = (
|
||||
aa1: axisAlignedBoundingBox,
|
||||
aa2: axisAlignedBoundingBox,
|
||||
) => {
|
||||
return aa1.x < aa2.x + aa2.w &&
|
||||
aa1.x + aa1.w > aa2.x &&
|
||||
aa1.y < aa2.y + aa2.h &&
|
||||
aa1.y + aa1.h > aa2.y;
|
||||
};
|
Reference in New Issue
Block a user