Skip to content

Commit

Permalink
fix: added get cross point from direction - fix #42 (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
pagoru authored Dec 10, 2024
1 parent 3ff78c1 commit eb03cb3
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/utils/direction.utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Point3d } from "../types/main.ts";
import { Direction } from "../enums/main.ts";
import { CrossDirection, Direction } from "../enums/main.ts";

export const getDirection = (
currentPoint: Point3d,
Expand Down Expand Up @@ -43,3 +43,20 @@ export const getPointFromDirection = (direction: Direction): Point3d => {
return { x: 0, y: 0, z: 0 };
}
};

export const getPointFromCrossDirection = (
direction: CrossDirection,
): Point3d => {
switch (direction) {
case CrossDirection.NORTH:
return { x: 0, y: 0, z: 1 };
case CrossDirection.SOUTH:
return { x: 0, y: 0, z: -1 };
case CrossDirection.EAST:
return { x: 1, y: 0, z: 0 };
case CrossDirection.WEST:
return { x: -1, y: 0, z: 0 };
default:
return { x: 0, y: 0, z: 0 };
}
};

0 comments on commit eb03cb3

Please sign in to comment.