ellipse.cpp revision cf3a43d3db54c432635fb2cd1f714cb3b9e78126
/*
* Ellipse Curve
*
* Authors:
* Marco Cecchetti <mrcekets at gmail.com>
*
* Copyright 2008 authors
*
* modify it either under the terms of the GNU Lesser General Public
* License version 2.1 as published by the Free Software Foundation
* (the "LGPL") or, at your option, under the terms of the Mozilla
* Public License Version 1.1 (the "MPL"). If you do not alter this
* notice, a recipient may use your version of this file under either
* the MPL or the LGPL.
*
* You should have received a copy of the LGPL along with this library
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* You should have received a copy of the MPL along with this library
* in the file COPYING-MPL-1.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
* the specific language governing rights and limitations.
*/
namespace Geom
{
{
double den = 4*A*C - B*B;
if ( den == 0 )
{
THROW_LOGICALERROR("den == 0, while computing ellipse centre");
}
// evaluate the a coefficient of the ellipse equation in normal form
// E(x,y) = a*(x-cx)^2 + b*(x-cx)*(y-cy) + c*(y-cy)^2 = 1
// where b = a*B , c = a*C, (cx,cy) == centre
- F;
//evaluate ellipse rotation angle
// std::cerr << "rot = " << rot << std::endl;
bool swap_axes = false;
{
swap_axes = true;
}
// evaluate the length of the ellipse rays
if ( den == 0 )
{
THROW_LOGICALERROR("den == 0, while computing 'rx' coefficient");
}
if ( rx2 < 0 )
{
THROW_LOGICALERROR("rx2 < 0, while computing 'rx' coefficient");
}
if ( den == 0 )
{
THROW_LOGICALERROR("den == 0, while computing 'ry' coefficient");
}
if ( ry2 < 0 )
{
THROW_LOGICALERROR("ry2 < 0, while computing 'rx' coefficient");
}
// the solution is not unique so we choose always the ellipse
// with a rotation angle between 0 and PI/2
{
rot = 0;
}
else if ( rot < 0 )
{
}
}
{
{
THROW_LOGICALERROR("a degenerate ellipse doesn't own an implicit form");
}
- 1;
return coeff;
}
{
if (sz < 5)
{
THROW_RANGEERROR("fitting error: too few points passed");
}
{
}
}
bool _svg_compliant)
{
bool large_arc_flag = true;
bool sweep_flag = true;
if ( angle1 > 0 )
{
{
large_arc_flag = false;
sweep_flag = true;
}
else
{
large_arc_flag = true;
sweep_flag = false;
}
}
else
{
{
large_arc_flag = false;
sweep_flag = false;
}
else
{
large_arc_flag = true;
sweep_flag = true;
}
}
if (_svg_compliant) {
} else {
}
return ret_arc;
}
{
0, 0 );
Affine M = m.withoutTranslation();
{
double angle;
if (AM[0] != 0)
{
}
else if (AM[1] != 0)
{
}
else
{
}
V *= AM;
}
0, 0 );
Q = invm * Q ;
Q *= invm;
e.m_centre = new_center;
return e;
}
{
}
} // end namespace Geom
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :