Sketcher: Parabola perpendicularity constraint

This commit is contained in:
Abdullah Tahiri 2016-12-24 15:24:36 +01:00
parent d8b38032cf
commit 9e7d86f1b8

View File

@ -2012,10 +2012,12 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
if( geo1->getTypeId() == Part::GeomEllipse::getClassTypeId() || if( geo1->getTypeId() == Part::GeomEllipse::getClassTypeId() ||
geo1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() || geo1->getTypeId() == Part::GeomArcOfEllipse::getClassTypeId() ||
geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId()) { geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ||
geo1->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() ) {
Base::Vector3d center; Base::Vector3d center;
Base::Vector3d majdir; Base::Vector3d majdir;
Base::Vector3d focus;
double majord = 0; double majord = 0;
double minord = 0; double minord = 0;
double phi = 0; double phi = 0;
@ -2039,22 +2041,28 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
phi=atan2(majdir.y, majdir.x); phi=atan2(majdir.y, majdir.x);
} }
else else
if( geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ){ if( geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ){
const Part::GeomArcOfHyperbola *aoh = static_cast<const Part::GeomArcOfHyperbola *>(geo1); const Part::GeomArcOfHyperbola *aoh = static_cast<const Part::GeomArcOfHyperbola *>(geo1);
center=aoh->getCenter(); center=aoh->getCenter();
majord=aoh->getMajorRadius(); majord=aoh->getMajorRadius();
minord=aoh->getMinorRadius(); minord=aoh->getMinorRadius();
majdir=aoh->getMajorAxisDir(); majdir=aoh->getMajorAxisDir();
phi=atan2(majdir.y, majdir.x); phi=atan2(majdir.y, majdir.x);
} }
else
if( geo1->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() ){
const Part::GeomArcOfParabola *aop = static_cast<const Part::GeomArcOfParabola *>(geo1);
center=aop->getCenter();
focus=aop->getFocus();
}
const Part::GeomLineSegment *line = static_cast<const Part::GeomLineSegment *>(geo2); const Part::GeomLineSegment *line = static_cast<const Part::GeomLineSegment *>(geo2);
Base::Vector3d point1=line->getStartPoint(); Base::Vector3d point1=line->getStartPoint();
Base::Vector3d PoO; Base::Vector3d PoO;
if( geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ) { if( geo1->getTypeId() == Part::GeomArcOfHyperbola::getClassTypeId() ) {
double df=sqrt(majord*majord+minord*minord); double df=sqrt(majord*majord+minord*minord);
Base::Vector3d direction=point1-(center+majdir*df); // towards the focus Base::Vector3d direction=point1-(center+majdir*df); // towards the focus
@ -2063,7 +2071,13 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg)
PoO = Base::Vector3d(center.x+majord*cosh(tapprox)*cos(phi)-minord*sinh(tapprox)*sin(phi), PoO = Base::Vector3d(center.x+majord*cosh(tapprox)*cos(phi)-minord*sinh(tapprox)*sin(phi),
center.y+majord*cosh(tapprox)*sin(phi)+minord*sinh(tapprox)*cos(phi), 0); center.y+majord*cosh(tapprox)*sin(phi)+minord*sinh(tapprox)*cos(phi), 0);
} }
else { else if( geo1->getTypeId() == Part::GeomArcOfParabola::getClassTypeId() ) {
Base::Vector3d direction=point1-focus; // towards the focus
PoO = point1 + direction / 2;
}
else
{
Base::Vector3d direction=point1-center; Base::Vector3d direction=point1-center;
double tapprox=atan2(direction.y,direction.x)-phi; // we approximate the eccentric anomally by the polar double tapprox=atan2(direction.y,direction.x)-phi; // we approximate the eccentric anomally by the polar