Triangle Class Reference

#include <Polygon.h>

Inheritance diagram for Triangle:

Polygon ReferenceTriangle List of all members.

Public Member Functions

 Triangle (GiNaC::ex x0, GiNaC::ex x1, GiNaC::ex x1, string subscript="")
 Triangle ()
 ~Triangle ()
virtual int no_vertices ()
virtual GiNaC::ex vertex (int i)
virtual Line line (int i)
virtual GiNaC::ex repr (Repr_format=SUBS_PERFORMED)
virtual string str ()
virtual GiNaC::ex integrate (GiNaC::ex f, Repr_format format=SUBS_PERFORMED)

Detailed Description

Definition at line 86 of file Polygon.h.


Constructor & Destructor Documentation

Triangle::Triangle GiNaC::ex  x0,
GiNaC::ex  x1,
GiNaC::ex  x1,
string  subscript = ""
 

Definition at line 231 of file Polygon.cpp.

References Polygon::p, and Polygon::subscript.

00231                                                                          { 
00232   subscript = subscript_; 
00233   p.insert(p.end(), x0); 
00234   p.insert(p.end(), x1); 
00235   p.insert(p.end(), x2); 
00236 
00237 }

Triangle::Triangle  )  [inline]
 

Definition at line 89 of file Polygon.h.

00089 {}

Triangle::~Triangle  )  [inline]
 

Definition at line 90 of file Polygon.h.

00090 {}


Member Function Documentation

GiNaC::ex Triangle::integrate GiNaC::ex  f,
Repr_format  format = SUBS_PERFORMED
[virtual]
 

Reimplemented from Polygon.

Definition at line 317 of file Polygon.cpp.

References Polygon::p, and repr().

Referenced by RaviartThomas::compute_basis_functions(), CrouzeixRaviart::compute_basis_functions(), and main().

00317                                                              {
00318 
00319   GiNaC::ex t_repr = repr(); 
00320   GiNaC::lst sub; 
00321   int counter; 
00322 
00323 
00324   // perform substitution
00325   if ( p[0].nops() == 3) {
00326     sub = GiNaC::lst(t_repr.op(0), t_repr.op(1), t_repr.op(2));  
00327     counter = 3;  
00328   } else if ( p[0].nops() == 2) { 
00329     sub = GiNaC::lst(t_repr.op(0), t_repr.op(1));  
00330     counter = 2;  
00331   }
00332   GiNaC::ex intf = func.subs(sub); 
00333 
00334   // compute D
00335   GiNaC::ex D; 
00336   if ( p[0].nops() == 3) {
00337     GiNaC::ex r = t_repr.op(3).op(0); 
00338     GiNaC::ex s = t_repr.op(4).op(0); 
00339     GiNaC::ex a = t_repr.op(0).rhs().coeff(r,1); 
00340     GiNaC::ex b = t_repr.op(0).rhs().coeff(s,1); 
00341     GiNaC::ex c = t_repr.op(1).rhs().coeff(r,1); 
00342     GiNaC::ex d = t_repr.op(1).rhs().coeff(s,1); 
00343     GiNaC::ex e = t_repr.op(2).rhs().coeff(r,1); 
00344     GiNaC::ex f = t_repr.op(2).rhs().coeff(s,1); 
00345     D = pow(c*f-d*e,2) + pow(a*f - b*e,2) + pow(a*d - b*c,2);   
00346     D = sqrt(D); 
00347   } else if ( p[0].nops() == 2) { 
00348     GiNaC::ex r = t_repr.op(2).op(0); 
00349     GiNaC::ex s = t_repr.op(3).op(0); 
00350     GiNaC::ex a = t_repr.op(0).rhs().coeff(r,1); 
00351     GiNaC::ex b = t_repr.op(0).rhs().coeff(s,1); 
00352     GiNaC::ex c = t_repr.op(1).rhs().coeff(r,1); 
00353     GiNaC::ex d = t_repr.op(1).rhs().coeff(s,1); 
00354     D = abs(a*d-b*c); 
00355   }
00356 
00357   intf = intf*D; 
00358 
00359 
00360   counter++; 
00361   intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);  
00362   intf = eval_integ(intf); 
00363 
00364   counter--; 
00365   intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);  
00366   intf = eval_integ(intf); 
00367   return intf; 
00368 
00369 }

Line Triangle::line int  i  )  [virtual]
 

Reimplemented in ReferenceTriangle.

Definition at line 273 of file Polygon.cpp.

References istr(), Polygon::p, and Polygon::subscript.

Referenced by RaviartThomas::compute_basis_functions(), CrouzeixRaviart::compute_basis_functions(), ReferenceTriangle::line(), main(), normal(), and repr().

00273                           {
00274 //  Line l = Line(p[(i-1)%3], p[i%3]); 
00275 //  return l; 
00276   if      ( i == 1) return Line(p[0],p[1], istr(subscript,i));  
00277   else if ( i == 2) return Line(p[0],p[2], istr(subscript,i));  
00278   else if ( i == 3) return Line(p[1],p[2], istr(subscript,i));  
00279 }

int Triangle::no_vertices  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceTriangle.

Definition at line 239 of file Polygon.cpp.

00239 { return 3; }

GiNaC::ex Triangle::repr Repr_format  = SUBS_PERFORMED  )  [virtual]
 

Reimplemented in ReferenceTriangle.

Definition at line 281 of file Polygon.cpp.

References line(), Polygon::p, Line::repr(), x, y, and z.

Referenced by integrate(), main(), and ReferenceTriangle::repr().

00281                                           {
00282    GiNaC::symbol r("r"), s("s"); 
00283    GiNaC::symbol G("G"), H("H"); 
00284    GiNaC::ex l1_repr = line(1).repr(r); 
00285    GiNaC::ex l2_repr = line(2).repr(s); 
00286    GiNaC::lst ret; 
00287    //2D 
00288    if ( p[0].nops() == 2) {
00289      ret = GiNaC::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,  
00290                 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);   
00291 
00292 
00293    }
00294    else if ( p[0].nops() == 3) {
00295 
00296      ret = GiNaC::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,  
00297                 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,   
00298                 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);   
00299 
00300    }
00301 
00302    ret.append(GiNaC::lst(r, 0, 1)); 
00303    ret.append(GiNaC::lst(s, 0, 1 - r)); 
00304 
00305    return ret; 
00306 
00307 }

string Triangle::str  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceTriangle.

Definition at line 310 of file Polygon.cpp.

00310                       {
00311    std::ostringstream s; 
00312 //   s <<"Triangle("<<p[0]<<","<<p[1]<<","<<p[2]<<")"<<endl; 
00313    s <<"Triangle"; 
00314    return s.str(); 
00315 }

GiNaC::ex Triangle::vertex int  i  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceTriangle.

Definition at line 241 of file Polygon.cpp.

References Polygon::p.

Referenced by bezier_ordinates(), and ReferenceTriangle::vertex().

00241                                {
00242   return p[i]; 
00243 }


The documentation for this class was generated from the following files:
Generated on Mon Jan 9 18:08:09 2006 for SyFi by  doxygen 1.4.4