*/
double EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(double ux, double uy)
{
- //When arc is lower than 0.707 Using Asin
- if(fabs(ux)<0.707)
- {
- double ret=SafeAcos(ux);
- if(uy>0.)
- return ret;
- ret=-ret;
- return ret;
- }
- else
- {
- double ret=SafeAsin(uy);
- if(ux>0.)
- return ret;
- if(ret>0.)
- return M_PI-ret;
- else
- return -M_PI-ret;
- }
+ return atan2(uy, ux);
}
-//double EdgeArcCircle::GetAbsoluteAngleOfNormalizedVect(double ux, double uy)
-//{
-// return atan2(uy, ux);
-//}
-
void EdgeArcCircle::GetArcOfCirclePassingThru(const double *start, const double *middle, const double *end,
double *center, double& radius, double& angleInRad, double& angleInRad0)
{
//
double myDelta1(angle1-_angle0),myDelta2(angle2-_angle0);
if(_angle>0.)
- { myDelta1=myDelta1>=0.?myDelta1:myDelta1+2.*M_PI; myDelta2=myDelta2>=0.?myDelta2:myDelta2+2.*M_PI; }
+ { myDelta1=myDelta1>-QUADRATIC_PLANAR::_precision?myDelta1:myDelta1+2.*M_PI; myDelta2=myDelta2>-QUADRATIC_PLANAR::_precision?myDelta2:myDelta2+2.*M_PI; }
else
- { myDelta1=myDelta1<=0.?myDelta1:myDelta1-2.*M_PI; myDelta2=myDelta2<=0.?myDelta2:myDelta2-2.*M_PI; }
+ { myDelta1=myDelta1<QUADRATIC_PLANAR::_precision?myDelta1:myDelta1-2.*M_PI; myDelta2=myDelta2<QUADRATIC_PLANAR::_precision?myDelta2:myDelta2-2.*M_PI; }
////
mid[0]=_center[0]+_radius*cos(_angle0+(myDelta1+myDelta2)/2.);
mid[1]=_center[1]+_radius*sin(_angle0+(myDelta1+myDelta2)/2.);
EdgeArcCircle e(start, end, e_center, 1.2264175471673588, -0.9533904350433241, 0.95339043504332388);
e.getMiddleOfPoints(p1, p2, mid);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.7996918047064556, mid[0], 1.e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5627359689548808, mid[1], 1.e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.37969180470645592, mid[0], 1.e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.4372640310451197, mid[1], 1.e-7);
e.getMiddleOfPoints(p2, p1, mid);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.7996918047064556, mid[0], 1.e-7);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(2.5627359689548808, mid[1], 1.e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.37969180470645592, mid[0], 1.e-7);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.4372640310451197, mid[1], 1.e-7);
start->decrRef(); end->decrRef();
}
coo2=DataArrayDouble([(-5,0),(-1,0),(7.,6.),(7,0),(1,6),(1,0),(-3,0),(8.2426406871192839,3),(5,0),(3,0), (2,0),(4,0),(6,0),(7.9196888946291288,1.3764116995614091),(7.9196888946291288,4.6235883004385911),(4,7.2426406871192848),(-2,3),(-4,0),(-2,0),(0,0)])
m=MEDCouplingUMesh("mesh",2) ; m.setCoords(coo2) ; m.allocateCells()
m.insertNextCell(NORM_QPOLYG,[5,9,8,3,7,2,4,0,6,1,10,11,12,13,14,15,16,17,18,19])
- mm = m.deepCpy()
- mm.tessellate2D(0.1)
- mm.writeVTK("/tmp/colin_1_a.vtu")
refPtr=m.getCoords().getHiddenCppPointer()
self.assertTrue(m.colinearize2D(1e-12).isEqual(DataArrayInt([0])))
- mm = m.deepCpy()
- mm.tessellate2D(0.1)
- mm.writeVTK("/tmp/colin_1_b.vtu")
self.assertNotEqual(refPtr,m.getCoords().getHiddenCppPointer())#not same coordinates here
self.assertTrue(coo2.isEqual(m.getCoords()[:20],1e-12))
self.assertTrue(m.getCoords()[20:].isEqual(DataArrayDouble([(1.,0.),(7.,6.)]),1e-12))