mirror of
https://git.coom.tech/drummyfish/raycastlib.git
synced 2024-11-20 20:19:57 +01:00
Fix distance
This commit is contained in:
parent
bb09c50496
commit
4ed686ea81
1 changed files with 7 additions and 3 deletions
10
raycastlib.h
10
raycastlib.h
|
@ -193,9 +193,13 @@ uint16_t sqrtInt(uint32_t value)
|
|||
|
||||
Unit dist(Vector2D p1, Vector2D p2)
|
||||
{
|
||||
Unit dx = p2.x - p1.x;
|
||||
Unit dy = p2.y - p1.y;
|
||||
return sqrtInt((dx * dx) + (dy * dy));
|
||||
int32_t dx = p2.x - p1.x;
|
||||
int32_t dy = p2.y - p1.y;
|
||||
|
||||
dx = dx * dx;
|
||||
dy = dy * dy;
|
||||
|
||||
return sqrtInt(((uint32_t) dx) + ((uint32_t) dy));
|
||||
}
|
||||
|
||||
int8_t pointIsLeftOfRay(Vector2D point, Ray ray)
|
||||
|
|
Loading…
Reference in a new issue