//finds the intersection of the all lines //returns intersection coordinates via array void f_intersect(double *px, double *py, int pn, double *wx, double *wy, int wn, double *c) { int i, j; double yprime, xprime, wslope[100], pslope[100], c1, c2; getslope(px, py, pn, pslope); getslope(wx, wy, wn, wslope); for (i = 0; i < wn; i++) { for (j = 0; j < pn; j++) { c1 = py[j] - pslope[j] * px[j]; //y = mx + c -> c = y -mx c2 = wy[i] - wslope[i] * wx[i]; if ((pslope[j] - wslope[i]) == 0) { //prevents divison by 0 printf("Slope division = 0; ERROR!\n"); } else { xprime = (c2 - c1) / (pslope[j] - wslope[i]); //intersection of x yprime = pslope[j] * xprime + c1; //intersection of y if (pointincontainer(px[j], py[j], px[looper(j, pn)], py[looper(j, pn)], xprime, yprime) == 1 && pointincontainer(wx[i], wy[i], wx[looper(i, wn)], wy[looper(i, wn)], xprime, yprime ) == 1) { c[counter] = xprime; c[counter + 1] = yprime; counter += 2; } } } } }
double Foothold::resolvex(double x) const { return isfloor() ? vertical.first() : getslope() * (x - horizontal.first()) + vertical.first(); }