11#include "include/collisions.h"
22
3-
43static int
5- pgCollision_LineLine (pgLineBase * A , pgLineBase * B ) {
4+ pgCollision_LineLine (pgLineBase * A , pgLineBase * B )
5+ {
66 double x1_m_x2 = A -> x1 - A -> x2 ;
77 double y3_m_y4 = B -> y1 - B -> y2 ;
88 double y1_m_y2 = A -> y1 - A -> y2 ;
99 double x3_m_x4 = B -> x1 - B -> x2 ;
10-
10+
1111 double den = x1_m_x2 * y3_m_y4 - y1_m_y2 * x3_m_x4 ;
1212
13- if (!den ) return 0 ;
13+ if (!den )
14+ return 0 ;
1415
1516 double x1_m_x3 = A -> x1 - B -> x1 ;
1617 double y1_m_y3 = A -> y1 - B -> y1 ;
@@ -25,7 +26,8 @@ pgCollision_LineLine(pgLineBase* A, pgLineBase* B) {
2526}
2627
2728static int
28- pgIntersection_LineLine (pgLineBase * A , pgLineBase * B , double * X , double * Y ) {
29+ pgIntersection_LineLine (pgLineBase * A , pgLineBase * B , double * X , double * Y )
30+ {
2931 double x1 = A -> x1 ;
3032 double y1 = A -> y1 ;
3133 double x2 = A -> x2 ;
@@ -39,10 +41,11 @@ pgIntersection_LineLine(pgLineBase* A, pgLineBase* B, double* X, double* Y) {
3941 double y3_m_y4 = y3 - y4 ;
4042 double y1_m_y2 = y1 - y2 ;
4143 double x3_m_x4 = x3 - x4 ;
42-
44+
4345 double den = x1_m_x2 * y3_m_y4 - y1_m_y2 * x3_m_x4 ;
4446
45- if (!den ) return 0 ;
47+ if (!den )
48+ return 0 ;
4649
4750 double x1_m_x3 = x1 - x3 ;
4851 double y1_m_y3 = y1 - y3 ;
@@ -54,29 +57,35 @@ pgIntersection_LineLine(pgLineBase* A, pgLineBase* B, double* X, double* Y) {
5457 double u = - (u1 / den );
5558
5659 if (t >= 0 && t <= 1 && u >= 0 && u <= 1 ) {
57- if (X ) * X = x1 + t * (x2 - x1 );
58- if (Y ) * Y = y1 + t * (y2 - y1 );
60+ if (X )
61+ * X = x1 + t * (x2 - x1 );
62+ if (Y )
63+ * Y = y1 + t * (y2 - y1 );
5964 return 1 ;
6065 }
6166 return 0 ;
6267}
6368
6469static int
65- pgCollision_LineCircle (pgLineBase * line , pgCircleBase * circle ) {
70+ pgCollision_LineCircle (pgLineBase * line , pgCircleBase * circle )
71+ {
6672 return 0 ;
6773}
6874
6975static int
70- pgCollision_CircleCircle (pgCircleBase * A , pgCircleBase * B ) {
76+ pgCollision_CircleCircle (pgCircleBase * A , pgCircleBase * B )
77+ {
7178 return 0 ;
7279}
7380
7481static int
75- pgCollision_RectLine (SDL_FRect * rect , pgLineBase * line ) {
82+ pgCollision_RectLine (SDL_FRect * rect , pgLineBase * line )
83+ {
7684 return 0 ;
7785}
7886
7987static int
80- pgCollision_RectCircle (SDL_FRect * rect , pgCircleBase * circle ) {
88+ pgCollision_RectCircle (SDL_FRect * rect , pgCircleBase * circle )
89+ {
8190 return 0 ;
8291}
0 commit comments