/* ----------------------------------------------------------------------------- * * Copyright (c) 2022 Alexis Naveros. * Feel free to use however you want. * * Highly accurate intersection point between two int64_t line segments * Input must be within the [-INT64_MAX/2,INT64_MAX/2] range * * ----------------------------------------------------------------------------- */ /* Check line intersection: yes */ /* Return non-zero if line segments intersect, don't compute the intersection point */ int mathLineLine_Check( int64_t l0p0x, int64_t l0p0y, int64_t l0p1x, int64_t l0p1y, int64_t l1p0x, int64_t l1p0y, int64_t l1p1x, int64_t l1p1y ); /* Check line intersection: yes */ /* Get intersection hit point: yes */ /* Return non-zero if line segments intersect, intersection point stored in hitpt */ int mathLineLine_CheckHit( int64_t *hitpt, int64_t l0p0x, int64_t l0p0y, int64_t l0p1x, int64_t l0p1y, int64_t l1p0x, int64_t l1p0y, int64_t l1p1x, int64_t l1p1y ); /* Check line intersection: no */ /* Get intersection hit point: yes */ /* Accurate intersection outside lines: no */ /* SIGFPE protection: yes */ /* Overflow checking: no */ /* Return non-zero on success, intersection point stored in hitpt */ /* This function does NOT check against integer overflow, if the intersection point is out of numerical range */ /* Use only when you know the intersection point is in the neighborhood of the two segments */ int mathLineLine_HitSafe( int64_t *hitpt, int64_t l0p0x, int64_t l0p0y, int64_t l0p1x, int64_t l0p1y, int64_t l1p0x, int64_t l1p0y, int64_t l1p1x, int64_t l1p1y ); /* Check line intersection: no */ /* Get intersection hit point: yes */ /* Accurate intersection outside lines: yes */ /* SIGFPE protection: yes */ /* Overflow checking: yes */ /* Return non-zero on success, intersection point stored in hitpt */ /* Return zero if parallel or intersection point outside of numerical range */ int mathLineLine_HitAnySafeRobust( int64_t *hitpt, int64_t l0p0x, int64_t l0p0y, int64_t l0p1x, int64_t l0p1y, int64_t l1p0x, int64_t l1p0y, int64_t l1p1x, int64_t l1p1y );