double REllipse::angleToParam(double a) const { double p; if (fabs(a - 2*M_PI)<RS::AngleTolerance) { p = 2*M_PI; } else if (fabs(a)<RS::AngleTolerance) { p = 0.0; } else { REllipse normEllipse = *this; normEllipse.move(-center); normEllipse.rotate(-getAngle()); normEllipse.setStartParam(0.0); normEllipse.setEndParam(2*M_PI); RLine line(RVector(0,0), RVector::createPolar(getMajorRadius()*2, a)); QList<RVector> r = RShape::getIntersectionPoints(line, normEllipse, true); if (r.length()!=1) { return RNANDOUBLE; } p = acos(r[0].x / getMajorRadius()); } if (RMath::getNormalizedAngle(a) > M_PI) { p = 2*M_PI-p; } return p; }