#include <Polygon.h>
Inheritance diagram for Triangle:
Public Member Functions | |
Triangle (ex x0, ex x1, ex x1, string subscript="") | |
Triangle () | |
~Triangle () | |
virtual int | no_vertices () |
virtual ex | vertex (int i) |
virtual Line | line (int i) |
virtual ex | repr (Repr_format=SUBS_PERFORMED) |
virtual string | str () |
virtual ex | integrate (ex f, Repr_format format=SUBS_PERFORMED) |
Definition at line 86 of file Polygon.h.
|
Definition at line 226 of file Polygon.cpp. References Polygon::p, and Polygon::subscript. 00226 { 00227 subscript = subscript_; 00228 p.insert(p.end(), x0); 00229 p.insert(p.end(), x1); 00230 p.insert(p.end(), x2); 00231 00232 }
|
|
Definition at line 89 of file Polygon.h.
|
|
Definition at line 90 of file Polygon.h.
|
|
Reimplemented from Polygon. Definition at line 312 of file Polygon.cpp. References Polygon::p, and repr(). Referenced by main(). 00312 { 00313 00314 ex t_repr = repr(); 00315 lst sub; 00316 int counter; 00317 00318 00319 // perform substitution 00320 if ( p[0].nops() == 3) { 00321 sub = lst(t_repr.op(0), t_repr.op(1), t_repr.op(2)); 00322 counter = 3; 00323 } else if ( p[0].nops() == 2) { 00324 sub = lst(t_repr.op(0), t_repr.op(1)); 00325 counter = 2; 00326 } 00327 ex intf = func.subs(sub); 00328 00329 // compute D 00330 ex D; 00331 if ( p[0].nops() == 3) { 00332 ex r = t_repr.op(3).op(0); 00333 ex s = t_repr.op(4).op(0); 00334 ex a = t_repr.op(0).rhs().coeff(r,1); 00335 ex b = t_repr.op(0).rhs().coeff(s,1); 00336 ex c = t_repr.op(1).rhs().coeff(r,1); 00337 ex d = t_repr.op(1).rhs().coeff(s,1); 00338 ex e = t_repr.op(2).rhs().coeff(r,1); 00339 ex f = t_repr.op(2).rhs().coeff(s,1); 00340 D = pow(c*f-d*e,2) + pow(a*f - b*e,2) + pow(a*d - b*c,2); 00341 D = sqrt(D); 00342 } else if ( p[0].nops() == 2) { 00343 ex r = t_repr.op(2).op(0); 00344 ex s = t_repr.op(3).op(0); 00345 ex a = t_repr.op(0).rhs().coeff(r,1); 00346 ex b = t_repr.op(0).rhs().coeff(s,1); 00347 ex c = t_repr.op(1).rhs().coeff(r,1); 00348 ex d = t_repr.op(1).rhs().coeff(s,1); 00349 D = a*d-b*c; 00350 } 00351 00352 intf = intf*D; 00353 00354 00355 counter++; 00356 intf = integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf); 00357 intf = eval_integ(intf); 00358 00359 counter--; 00360 intf = integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf); 00361 intf = eval_integ(intf); 00362 return intf; 00363 00364 00365 00366 /* OLD Code: 00367 symbol r("r"); symbol s("s"); symbol t("t"); 00368 lst v = lst(r,s,t); 00369 00370 ex line1_repr = line(1).repr(v.op(0), SUBS_NOT_PERFORMED); 00371 ex line2_repr = line(2).repr(v.op(1), SUBS_NOT_PERFORMED); 00372 ex line3_repr = line(3).repr(v.op(2), SUBS_NOT_PERFORMED); 00373 lst new_coor; 00374 // Coordinates (x,y) represented as functions of (r,s) 00375 // FIXME:: this depends on nsd, 4 is another number in 3D 00376 for (int i=0; i<= line1_repr.nops()-4; i++) { 00377 // FIXME: (x_0, y_0, z_0) is not appended ??? 00378 new_coor.append(line1_repr.op(i).lhs() 00379 == (line1_repr.op(i).rhs() + line2_repr.op(i).rhs())); 00380 } 00381 00382 00383 // compute t as a function of s 00384 lst equations; 00385 equations.append(new_coor.op(0).rhs() - line3_repr.op(0).rhs() == 0 ); 00386 equations.append(new_coor.op(1).rhs() - line3_repr.op(1).rhs() == 0 ); 00387 //FIXME: only in 3D 00388 // equations.append(new_coor.op(2).rhs() - line3_repr.op(2).rhs() == 0 ); 00389 00390 ex intf; 00391 try { 00392 ex ss = lsolve( lst(equations.op(0), equations.op(1)), 00393 lst(v.op(0), v.op(2))); 00394 ss = ss.op(0).rhs().collect(s); 00395 00396 symbol A("A"), B("B"); 00397 ex sss = A*s + B; 00398 00399 intf = eval_integ(integral(s, 0,1, eval_integ(integral(r,0, sss, f.subs(new_coor))))); 00400 return lst(intf, A == ss.coeff(s,1), B == ss.coeff(s,0), 00401 line1_repr.op(2), line1_repr.op(3), line1_repr.op(4), line1_repr.op(5), 00402 line2_repr.op(2), line2_repr.op(3), line2_repr.op(4), line2_repr.op(5), 00403 line3_repr.op(2), line3_repr.op(3), line3_repr.op(4), line3_repr.op(5)); 00404 00405 } catch (exception &p) { 00406 cerr << p.what() << endl; 00407 } 00408 00409 // FIXME should probably return something else in case of fault 00410 return infinity; 00411 */ 00412 }
|
|
Reimplemented in ReferenceTriangle. Definition at line 268 of file Polygon.cpp. References istr(), Polygon::p, and Polygon::subscript. Referenced by ReferenceTriangle::line(), main(), and repr(). 00268 { 00269 // Line l = Line(p[(i-1)%3], p[i%3]); 00270 // return l; 00271 if ( i == 1) return Line(p[0],p[1], istr(subscript,i)); 00272 else if ( i == 2) return Line(p[0],p[2], istr(subscript,i)); 00273 else if ( i == 3) return Line(p[1],p[2], istr(subscript,i)); 00274 }
|
|
Reimplemented from Polygon. Reimplemented in ReferenceTriangle. Definition at line 234 of file Polygon.cpp.
|
|
Reimplemented in ReferenceTriangle. Definition at line 276 of file Polygon.cpp. References line(), Polygon::p, Line::repr(), x, y, and z. Referenced by integrate(), main(), and ReferenceTriangle::repr(). 00276 { 00277 symbol r("r"), s("s"); 00278 symbol G("G"), H("H"); 00279 ex l1_repr = line(1).repr(r); 00280 ex l2_repr = line(2).repr(s); 00281 lst ret; 00282 //2D 00283 if ( p[0].nops() == 2) { 00284 ret = lst( x ==l1_repr.op(0).rhs().coeff(r,0) + l1_repr.op(0).rhs().coeff(r,1)*r + l2_repr.op(0).rhs().coeff(s,1)*s, 00285 y ==l1_repr.op(1).rhs().coeff(r,0) + l1_repr.op(1).rhs().coeff(r,1)*r + l2_repr.op(1).rhs().coeff(s,1)*s); 00286 00287 00288 } 00289 else if ( p[0].nops() == 3) { 00290 00291 ret = lst( x == l1_repr.op(0).rhs().coeff(r,0) + l1_repr.op(0).rhs().coeff(r,1)*r + l2_repr.op(0).rhs().coeff(s,1)*s, 00292 y == l1_repr.op(1).rhs().coeff(r,0) + l1_repr.op(1).rhs().coeff(r,1)*r + l2_repr.op(1).rhs().coeff(s,1)*s, 00293 z == l1_repr.op(2).rhs().coeff(r,0) + l1_repr.op(2).rhs().coeff(r,1)*r + l2_repr.op(2).rhs().coeff(s,1)*s); 00294 00295 } 00296 00297 ret.append(lst(r, 0, 1)); 00298 ret.append(lst(s, 0, 1 - r)); 00299 00300 return ret; 00301 00302 }
|
|
Reimplemented from Polygon. Reimplemented in ReferenceTriangle. Definition at line 305 of file Polygon.cpp. 00305 { 00306 std::ostringstream s; 00307 // s <<"Triangle("<<p[0]<<","<<p[1]<<","<<p[2]<<")"<<endl; 00308 s <<"Triangle"; 00309 return s.str(); 00310 }
|
|
Reimplemented from Polygon. Reimplemented in ReferenceTriangle. Definition at line 236 of file Polygon.cpp. References Polygon::p. Referenced by bezier_ordinates(), and ReferenceTriangle::vertex(). 00236 { 00237 return p[i]; 00238 }
|