129 double rnorm = 0, snorm = 0, b, t, u;
132 double epsilon = sin(1/180.), close = 0.01;
137 for (i = 0; i <
dim; i++) {
138 r[i] = p2[i] - p1[i];
143 for (i = 0; i <
dim; i++) {
144 s[i] = q2[i] - q1[i];
150 if (fabs(b) <= epsilon*snorm*rnorm){
151 if (line_dist_close) {
156 for (i = 0; i <
dim; i++) qp[i] = q1[i] - p1[i];
159 if ((t >= 0 && t <= 1 && u >= 0 && u <= 1)
163 for (i = 0; i <
dim; i++){
166 res = rs/(rnorm*snorm);
168 if (p1[0] == q1[0] && p1[1] == q1[1]){
170 }
else if (p1[0] == q2[0] && p1[1] == q2[1]){
172 }
else if (p2[0] == q1[0] && p2[1] == q1[1]){
174 }
else if (p2[0] == q2[0] && p2[1] == q2[1]){