Line Class Reference

#include <Polygon.h>

Inheritance diagram for Line:

Polygon ReferenceLine List of all members.

Public Member Functions

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

Private Attributes

GiNaC::ex a_
GiNaC::ex b_

Detailed Description

Definition at line 56 of file Polygon.h.


Constructor & Destructor Documentation

Line::Line  )  [inline]
 

Definition at line 60 of file Polygon.h.

00060 {}

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

Definition at line 20 of file Polygon.cpp.

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

00020                                                     { 
00021    subscript = subscript_; 
00022 
00023   /* Lines on the form 
00024    * x = x_0 + a_1 t
00025    * y = y_0 + a_2 t
00026    * z = z_0 + a_3 t
00027   */
00028 
00029 
00030 
00031 
00032   //FIXME does not need to be a list in 1D. 
00033   if ( true /* (is_a<lst>(x0) && is_a<lst>(x1)) && (x0.nops() == x1.nops())*/ ) { 
00034 
00035     GiNaC::lst aa; 
00036     GiNaC::lst bb; 
00037 
00038 
00039     // compute aa and bb 
00040     for (int i=0; i<= x0.nops()-1; i++) {
00041       bb.append(x0.op(i)); 
00042       aa.append(x1.op(i) - x0.op(i)); 
00043     }
00044 
00045 
00046     //update internal structure
00047     p.insert(p.end(), x0); ; 
00048     p.insert(p.end(), x1); ; 
00049     a_ = aa; 
00050     b_ = bb; 
00051 
00052   } else {
00053     // FIXME: not decided on proper error handling yet. 
00054     // Could build upon GiNaC
00055     cout <<"THIS SHOULD NOT HAPPEN "<<endl; 
00056   }
00057 }

Line::~Line  )  [inline]
 

Definition at line 62 of file Polygon.h.

00062 {}


Member Function Documentation

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

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 137 of file Polygon.cpp.

References Polygon::p, and repr().

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

00137                                                       {
00138   GiNaC::symbol t("t"); 
00139   GiNaC::ex t_repr = repr(t); 
00140   GiNaC::lst sub; 
00141   int counter; 
00142   // perform substitution 
00143   if ( p[0].nops() == 3) {
00144     sub = GiNaC::lst(t_repr.op(0), t_repr.op(1), t_repr.op(2));  
00145     counter = 3;  
00146   } else if ( p[0].nops() == 2) { 
00147     sub = GiNaC::lst(t_repr.op(0), t_repr.op(1));  
00148     counter = 2;  
00149   }
00150 
00151 
00152   // compute D
00153   GiNaC::ex D; 
00154   if ( p[0].nops() == 3) {
00155     D = pow(t_repr.op(0).rhs().coeff(t), 2) +  
00156         pow(t_repr.op(1).rhs().coeff(t), 2) +   
00157         pow(t_repr.op(2).rhs().coeff(t), 2);  
00158   } else if ( p[0].nops() == 2) { 
00159     D = pow(t_repr.op(0).rhs().coeff(t), 2) +  
00160         pow(t_repr.op(1).rhs().coeff(t), 2);  
00161   }
00162 
00163   D = sqrt(D); 
00164 
00165   GiNaC::ex intf = f.subs(sub)*D; 
00166 
00167   intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);  
00168   intf = eval_integ(intf); 
00169 
00170   return intf; 
00171 
00172 
00173 }

int Line::no_vertices  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 59 of file Polygon.cpp.

00059 { return 2;  }

GiNaC::ex Line::repr GiNaC::ex  t,
Repr_format  format = SUBS_PERFORMED
[virtual]
 

Reimplemented in ReferenceLine.

Definition at line 67 of file Polygon.cpp.

References a_, b_, SUBS_NOT_PERFORMED, SUBS_PERFORMED, Polygon::subscript, x, y, and z.

Referenced by integrate(), main(), normal(), Tetrahedron::repr(), and Triangle::repr().

00067                                                  {
00068   /* FIXME: use the same symbols in this 
00069    * description as in the actual symbols 
00070    * below and in the documentation. 
00071    *
00072    * Lines on the form 
00073    * x = x_0 + a_1 t,   
00074    * y = y_0 + a_2 t,
00075    * z = z_0 + a_3 t. 
00076    * for t in [0,1]
00077   */
00078 
00079   GiNaC::lst r; 
00080   // 2D
00081 
00082   if ( format == SUBS_PERFORMED ) { 
00083     if ( a_.nops() == 2) { 
00084       r = GiNaC::lst(  x == b_.op(0) +  a_.op(0)*t, 
00085                 y == b_.op(1) +  a_.op(1)*t);   
00086     // 3D
00087     } else if ( a_.nops() == 3) {
00088       r = GiNaC::lst(  x == b_.op(0) +  a_.op(0)*t, 
00089                 y == b_.op(1) +  a_.op(1)*t,   
00090                 z == b_.op(2) +  a_.op(2)*t);   
00091     }
00092     r.append(GiNaC::lst(t,0,1));
00093   }
00094   else if ( format == SUBS_NOT_PERFORMED ) { 
00095 
00096     // FIXME: decide how the constant should be !!
00097     GiNaC::symbol a1("A"+subscript); 
00098     GiNaC::symbol a2("C"+subscript); 
00099     GiNaC::symbol a3("E"+subscript); 
00100     GiNaC::symbol b1("B"+subscript); 
00101     GiNaC::symbol b2("D"+subscript); 
00102     GiNaC::symbol b3("F"+subscript); 
00103   
00104   
00105     // 3D
00106     if ( a_.nops() == 2) { 
00107       r = GiNaC::lst(  x == b1 +  a1*t, 
00108                 y == b2 +  a2*t);   
00109   
00110       r.append( a1 == a_.op(0));   
00111       r.append( b1 == b_.op(0));
00112       r.append( a2 == a_.op(1)); 
00113       r.append( b2 == b_.op(1)); 
00114     // 3D
00115     } else if ( a_.nops() == 3) {
00116       r = GiNaC::lst(  x == b1 +  a1*t, 
00117                 y == b2 +  a2*t,   
00118                 z == b3 +  a3*t);   
00119   
00120   
00121       r.append( a1 == a_.op(0));   
00122       r.append( b1 == b_.op(0));
00123       r.append( a2 == a_.op(1)); 
00124       r.append( b2 == b_.op(1)); 
00125       r.append( a3 == a_.op(2)); 
00126       r.append( b3 == b_.op(2)); 
00127   
00128   
00129     }
00130   
00131     r.append(GiNaC::lst(t,0,1));
00132   }
00133 
00134   return r; 
00135 }

string Line::str  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 175 of file Polygon.cpp.

00175                  {
00176    std::ostringstream s; 
00177 //   s <<"Line("<<p[0]<<","<<p[1]<<")"; 
00178    s <<"Line";
00179    return s.str(); 
00180 }

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

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 61 of file Polygon.cpp.

References Polygon::p.

00061                            {
00062   return p[i];  
00063 }


Member Data Documentation

GiNaC::ex Line::a_ [private]
 

Definition at line 57 of file Polygon.h.

Referenced by Line(), and repr().

GiNaC::ex Line::b_ [private]
 

Definition at line 58 of file Polygon.h.

Referenced by Line(), and repr().


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