6 #include "../shared/shared.h"
15 Metric::Metric(
double a){
23 Metric::Metric(
double a11_in,
double a21_in,
double a22_in){
39 double v1x = + vab.
vx;
40 double v1y = + vab.
vy;
41 double v2x = - vab.
vy;
42 double v2y = + vab.
vx;
44 double h1=a[0] / m0.
Length(v1x,v1y) + a[1] / m1.
Length(v1x,v1y) + a[2] / m2.
Length(v1x,v1y);
45 double h2=a[0] / m0.
Length(v2x,v2y) + a[1] / m1.
Length(v2x,v2y) + a[2] / m2.
Length(v2x,v2y);
51 double v00=vab.
vx*vab.
vx;
52 double v11=vab.
vy*vab.
vy;
53 double v01=vab.
vx*vab.
vy;
59 Metric::Metric(
double a,
const Metric ma,
double b,
const Metric mb) {
66 double v1x = + vab.
vx;
67 double v1y = + vab.
vy;
68 double v2x = - vab.
vy;
69 double v2y = + vab.
vx;
78 double v00=vab.
vx*vab.
vx;
79 double v11=vab.
vy*vab.
vy;
80 double v01=vab.
vx*vab.
vy;
89 return a11*a22-a21*a21;
91 void Metric::Echo(
void){
94 _printf_(
" [a11 a21 a22]: [" << a11 <<
" " << a21 <<
" " << a22 <<
"]\n");
99 int Metric::IntersectWith(
const Metric& M2) {
130 double lambda1=M1(v1,v1);
131 double lambda2=M1(v2,v2);
132 double mu1=M2(v1,v1);
133 double mu2=M2(v2,v2);
136 if ( lambda1 < mu1 ) change=1,lambda1=mu1;
137 if ( lambda2 < mu2 ) change=1,lambda2=mu2;
142 D2xD2 D(lambda1,0,0,lambda2);
145 a21=0.5*(M.
x.y+M.
y.x);
151 double Metric::Length(
double Ax,
double Ay)
const{
153 return sqrt(Ax*Ax*a11+2*Ax*Ay*a21+Ay*Ay*a22);
164 static Metric Ms1[32],Ms2[32];
165 static double lMs1[32],lMs2[32];
184 double s1= lMs1[level];
185 double s2= lMs2[level];
188 if( s > sstop && level < 30 && i < 500-level ) {
191 if(
Abs((s1+s2)-(si+si)) > s1*0.001)
210 L[i]= l += s,S[i]=sss+=k,i++;
213 L[i]= l += s,S[i]=sss+=k,i++;
221 if (i>200 && kkk++<10)
_printf_(
"WARNING: LengthInterpole: ( i=" << i <<
" l=" << l <<
" sss=" << sss <<
" ) " << sstop <<
"\n");
254 const double a= a11*a22 - a21*a21;
255 const double b=-a11*b22 - b11*a22+2*b21*a21;
256 const double c=-b21*b21 + b11*b22;
257 const double bb=b*b,ac=a*c;
258 const double delta= bb-4*ac;
263 if ( (bb +
Abs(ac) < 1.0e-34 ) || (delta < 1.0e-6*bb) ){
272 const double delta2 = sqrt(delta);
274 lambda[0]= (-b - delta2)/(2*a);
275 lambda[1]= (-b + delta2)/(2*a);
282 for(
int i=0;i<2;i++){
301 v0 = b11 - lambda[i]*a11;
302 v1 = b21 - lambda[i]*a21;
303 v2 = b22 - lambda[i]*a22;
323 V=
D2xD2(vp[0][0],vp[0][1],vp[1][0],vp[1][1]);
359 r = 2*(S[i]*(L[j]-l)+ S[j]*(l-L[i]))/(L[j]-L[i]);