Line Class Reference

#include <Polygon.h>

Inheritance diagram for Line:

Polygon ReferenceLine List of all members.

Public Member Functions

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

Private Attributes

ex a_
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 ex  x0,
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   //FIXME does not need to be a list in 1D. 
00031   if ( (is_a<lst>(x0) && is_a<lst>(x1)) && (x0.nops() == x1.nops()) ) { 
00032 
00033     lst aa; 
00034     lst bb; 
00035 
00036 
00037     // compute aa and bb 
00038     for (int i=0; i<= x0.nops()-1; i++) {
00039       bb.append(x0.op(i)); 
00040       aa.append(x1.op(i) - x0.op(i)); 
00041     }
00042 
00043 
00044     //update internal structure
00045     p.insert(p.end(), x0); ; 
00046     p.insert(p.end(), x1); ; 
00047     a_ = aa; 
00048     b_ = bb; 
00049 
00050   } else {
00051     // FIXME: not decided on proper error handling yet. 
00052     // Could build upon GiNaC
00053     cout <<"THIS SHOULD NOT HAPPEN "<<endl; 
00054   }
00055 }

Line::~Line  )  [inline]
 

Definition at line 62 of file Polygon.h.

00062 {}


Member Function Documentation

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

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 135 of file Polygon.cpp.

References Polygon::p, and repr().

Referenced by main().

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

int Line::no_vertices  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 57 of file Polygon.cpp.

00057 { return 2;  }

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

Reimplemented in ReferenceLine.

Definition at line 65 of file Polygon.cpp.

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

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

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

string Line::str  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 173 of file Polygon.cpp.

References Polygon::p.

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

ex Line::vertex int  i  )  [virtual]
 

Reimplemented from Polygon.

Reimplemented in ReferenceLine.

Definition at line 59 of file Polygon.cpp.

References Polygon::p.

00059                       {
00060   return p[i];  
00061 }


Member Data Documentation

ex Line::a_ [private]
 

Definition at line 57 of file Polygon.h.

Referenced by Line(), and repr().

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 Tue Nov 22 11:10:23 2005 for SyFi by  doxygen 1.4.4