13 _minorRadius(minorRadius),
14 _startAngle(startAngle),
16 _isReversed(reversed) {
59 double st2 = 1.0 - ct2;
60 double kx2 = factor.
x() * factor.
x();
61 double ky2 = factor.
y() * factor.
y();
63 double cA = 0.5 * a * a * (kx2 * ct2 + ky2 * st2);
64 double cB = 0.5 * b * b * (kx2 * st2 + ky2 * ct2);
65 double cC = a * b * ct * st * (ky2 - kx2);
73 double ratio = std::sqrt((z - x) / (z + x));
74 double minor_ = vp6.magnitude() *
ratio;
83 return Ellipse(
center().rotate(rotation_center, rotation_angle),
84 majorP().rotate(rotation_center, rotation_angle),
89 std::vector<Coordinate> pnp;
93 double ellipseAngle = this->
getAngle();
101 double x=trcoord.
x(),y=trcoord.
y();
103 double twoa2b2=2*(a*a-b*b);
106 double a0=twoa2b2*twoa2b2;
107 std::vector<double> ce(4,0.);
108 std::vector<double> roots(0,0.);
111 ce[0]=-2.*twoax/twoa2b2;
112 ce[1]= (twoax*twoax+twoby*twoby)/a0-1.;
114 ce[3]= -twoax*twoax/a0;
119 roots.push_back(sqrt(1./(1.+a0*a0)));
120 roots.push_back(-roots[0]);
123 if(roots.size() == 0) {
125 std::cout<<
"(a= "<<a<<
" b= "<<b<<
" x= "<<x<<
" y= "<<y<<
" )\n";
126 std::cout<<
"finding minimum for ("<<x<<
"-"<<a<<
"*cos(t))^2+("<<y<<
"-"<<b<<
"*sin(t))^2\n";
127 std::cout<<
"2::find cosine, variable c, solve(c^4 +("<<ce[0]<<
")*c^3+("<<ce[1]<<
")*c^2+("<<ce[2]<<
")*c+("<<ce[3]<<
")=0,c)\n";
128 std::cout<<ce[0]<<
' '<<ce[1]<<
' '<<ce[2]<<
' '<<ce[3]<<std::endl;
129 std::cerr<<
"lcmath::geoellipse::findPotentialNearestPoints() finds no root from quartic, this should not happen\n";
134 for(
size_t i=0; i<roots.size(); i++) {
135 double const s=twoby*roots[i]/(twoax-twoa2b2*roots[i]);
136 double const d2=twoa2b2+(twoax-2.*roots[i]*twoa2b2)*roots[i]+twoby*s;
142 t = t.
rotate(ellipseAngle);
151 auto minDist = DBL_MAX;
154 for (
auto& verifiedPoint: potencialPoinst)
156 double d = verifiedPoint.distanceTo(coord);
159 minDist = verifiedPoint.distanceTo(coord);
169 double minDist = DBL_MAX;
173 for (
auto verifiedPoint: potencialPoinst)
177 double d = verifiedPoint.distanceTo(coord);
180 minDist = verifiedPoint.distanceTo(coord);
static double getAngleDifferenceShort(double a1, double a2, bool CCW)
getAngleDifference, Angle difference between 2 angles
double startAngle() const
startAngle, Returns Start elliptic!! angle of ellipse
double x() const
Returns x of Coordinate.
Coordinate startPoint() const
startPoint, start point of ellipse
double getEllipseAngle(const Coordinate &coord) const
getEllipseAngle
Ellipse geoscale(const Coordinate ¢er, const Coordinate &factor) const
scale an ellipse at some center by some factor
const double _minorRadius
double y() const
Returns y of Coordinate.
Coordinate scale(const double &scale_factor) const
Ellipse(const Coordinate ¢er, const Coordinate &majorP, double minorRadius, double startAngle, double endAngle, bool reversed=false)
double ratio() const
ratio of major radius to minor radius
Coordinate nearestPointOnPath(const Coordinate &coord) const
nearestPointOnPath, (ignore if it arc)
Coordinate rotate(const Coordinate &angleVector) const
rotate around (0.,0.) with a given angle vector
Ellipse georotate(const Coordinate ¢er, const double rotation_angle) const
rotate an ellipse at a center by an angle
Coordinate getPoint(const double &angle) const
getPoint, return a point on ellipse with given elliptic angle
double majorRadius() const
Major Radius.
double getAngle() const
getAngle of MajorP
double endAngle() const
endAngle, Return the end elliptic!! angle of ellipse
Coordinate endPoint() const
endPoint, end point of ellipse
std::vector< Coordinate > findPotentialNearestPoints(const Coordinate &coord) const
findPotentialNearestPoints
static std::vector< double > quarticSolver(const std::vector< double > &ce)
const Coordinate center() const
center, Returns Center point of Ellipse
double minorRadius() const
minorRadius, Returns the minor radius of ellipse
Coordinate nearestPointOnEntity(const Coordinate &coord) const
nearestPointOnEntity, ( not ignore arc)
const Coordinate majorP() const
majorP, Returns major point of the ellipse, relative to center
bool isAngleBetween(double angle) const