int ret3(int a, int b) { return a + b + ret2(); }
/** * @return One or two intersection points between given entities. */ RS_VectorSolutions RS_Information::getIntersectionLineEllipse(RS_Line* line, RS_Ellipse* ellipse) { RS_VectorSolutions ret; if (line==NULL || ellipse==NULL) { return ret; } // rotate into normal position: double ang = ellipse->getAngle(); double rx = ellipse->getMajorRadius(); double ry = ellipse->getMinorRadius(); RS_Vector center = ellipse->getCenter(); RS_Vector a1 = line->getStartpoint().rotate(center, -ang); RS_Vector a2 = line->getEndpoint().rotate(center, -ang); RS_Vector origin = a1; RS_Vector dir = a2-a1; RS_Vector diff = origin - center; RS_Vector mDir = RS_Vector(dir.x/(rx*rx), dir.y/(ry*ry)); RS_Vector mDiff = RS_Vector(diff.x/(rx*rx), diff.y/(ry*ry)); double a = RS_Vector::dotP(dir, mDir); double b = RS_Vector::dotP(dir, mDiff); double c = RS_Vector::dotP(diff, mDiff) - 1.0; double d = b*b - a*c; if (d < 0) { RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 0"); } else if ( d > 0 ) { double root = sqrt(d); double t_a = (-b - root) / a; double t_b = (-b + root) / a; /*if ( (t_a < 0 || 1 < t_a) && (t_b < 0 || 1 < t_b) ) { if ( (t_a < 0 && t_b < 0) || (t_a > 1 && t_b > 1) ) { RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 1"); } else { RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: inside 1"); } } else {*/ RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: intersection 1"); RS_Vector ret1(false); RS_Vector ret2(false); //if ( 0 <= t_a && t_a <= 1 ) { //RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t_a<=1"); ret1 = a1.lerp(a2, t_a); RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret1: %f/%f", ret1.x, ret1.y); //} //if ( 0 <= t_b && t_b <= 1 ) { //RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t_b<=1"); ret2 = a1.lerp(a2, t_b); RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret2: %f/%f", ret2.x, ret2.y); //} if (ret1.valid && ret2.valid) { ret = RS_VectorSolutions(ret1, ret2); } else { if (ret1.valid) { ret = RS_VectorSolutions(ret1); } if (ret2.valid) { ret = RS_VectorSolutions(ret2); } } //} } else { double t = -b/a; if ( 0 <= t && t <= 1 ) { RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: 0<=t<=1"); RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: intersection 2"); ret = RS_VectorSolutions(a1.lerp(a2, t)); RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: ret1: %f/%f", ret.get(0).x, ret.get(0).y); } else { RS_DEBUG->print("RS_Information::getIntersectionLineEllipse: outside 2"); } } ret.rotate(center, ang); return ret; /* RS_Arc* arc = new RS_Arc(NULL, RS_ArcData(ellipse->getCenter(), ellipse->getMajorRadius(), ellipse->getAngle1(), ellipse->getAngle2(), false)); RS_Line* other = (RS_Line*)line->clone(); double angle = ellipse->getAngle(); //double ratio = ellipse->getRatio(); // rotate entities: other->rotate(ellipse->getCenter(), -angle); other->scale(ellipse->getCenter(), RS_Vector(1.0, 1.0/ellipse->getRatio())); ret = getIntersectionLineArc(other, arc); ret.scale(ellipse->getCenter(), RS_Vector(1.0, ellipse->getRatio())); ret.rotate(ellipse->getCenter(), angle); delete arc; delete other; return ret; */ }
int sum5(int a1, int a2, int a3, int a4, int a5) { int f = a1 * a4; int v = fact(ret3(ret1(), ret2())); return a1 * a2+ a3 * a4 + a5 * a1 + f + v; }