Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Search for

# Line Class Reference

`#include <Polygon.h>`

Inheritance diagram for Line:

List of all members.

## Public Member Functions
| Line ()
| Line (GiNaC::ex x0, GiNaC::ex x1, string subscript="")
virtual | ~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 }

virtual Line::~Line | ( |  | ) | `[inline, virtual]`

| 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 DUMMY, Polygon::p, repr(), SUBS_NOT_PERFORMED, SUBS_PERFORMED, x, y, and z. Referenced by RaviartThomas::compute_basis_functions(), Nedelec::compute_basis_functions(), CrouzeixRaviart::compute_basis_functions(), and main().
    00137                                                       {
    00138   if ( format == SUBS_PERFORMED) {
    00139     GiNaC::symbol t("t");
    00140     GiNaC::ex t_repr = repr(t);
    00141     GiNaC::lst sub;
    00142     int counter;
    00143     // perform substitution
    00144     if ( p[0].nops() == 3) {
    00145       sub = GiNaC::lst(t_repr.op(0), t_repr.op(1), t_repr.op(2));
    00146       counter = 3;
    00147     } else if ( p[0].nops() == 2) {
    00148       sub = GiNaC::lst(t_repr.op(0), t_repr.op(1));
    00149       counter = 2;
    00150     }
    00151
    00152
    00153     // compute D
    00154     GiNaC::ex D;
    00155     if ( p[0].nops() == 3) {
    00156       D = pow(t_repr.op(0).rhs().coeff(t), 2) +
    00157           pow(t_repr.op(1).rhs().coeff(t), 2) +
    00158           pow(t_repr.op(2).rhs().coeff(t), 2);
    00159     } else if ( p[0].nops() == 2) {
    00160       D = pow(t_repr.op(0).rhs().coeff(t), 2) +
    00161           pow(t_repr.op(1).rhs().coeff(t), 2);
    00162     }
    00163
    00164     D = sqrt(D);
    00165
    00166     GiNaC::ex intf = f.subs(sub)*D;
    00167
    00168     intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);
    00169     intf = eval_integ(intf);
    00170
    00171     return intf;
    00172   } else if ( format == SUBS_NOT_PERFORMED ) {
    00173     GiNaC::symbol t("t");
    00174     GiNaC::ex t_repr = repr(t);
    00175     GiNaC::lst sub;
    00176     GiNaC::symbol a("a"), b("b"), c("c"), D("D");
    00177     int counter;
    00178     // perform substitution
    00179
    00180     if ( p[0].nops() == 3) {x ==  p[0].op(0) + a*t,
    00181 //      sub = GiNaC::lst(t_repr.op(0), t_repr.op(1), t_repr.op(2));
    00182       sub = GiNaC::lst( x ==  p[0].op(0) + a*t,
    00183                         y ==  p[0].op(1) + b*t,
    00184                         z ==  p[0].op(2) + c*t);
    00185       counter = 3;
    00186     } else if ( p[0].nops() == 2) {
    00187 //      sub = GiNaC::lst(t_repr.op(0), t_repr.op(1));
    00188       sub = GiNaC::lst( x ==  p[0].op(0) + a*t,
    00189                         y ==  p[0].op(1) + b*t);
    00190       counter = 2;
    00191     }
    00192
    00193
    00194     // compute D
    00195     GiNaC::ex DD;
    00196     if ( p[0].nops() == 3) {
    00197       DD = pow(t_repr.op(0).rhs().coeff(t), 2) +
    00198           pow(t_repr.op(1).rhs().coeff(t), 2) +
    00199           pow(t_repr.op(2).rhs().coeff(t), 2);
    00200     } else if ( p[0].nops() == 2) {
    00201       DD = pow(t_repr.op(0).rhs().coeff(t), 2) +
    00202           pow(t_repr.op(1).rhs().coeff(t), 2);
    00203     }
    00204
    00205     DD = sqrt(DD);
    00206
    00207     GiNaC::ex intf = f.subs(sub);
    00208
    00209     intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);
    00210     intf = eval_integ(intf);
    00211
    00212
    00213     intf = intf*D;
    00214
    00215     return intf;
    00216   }
    00217   return DUMMY;
    00218 }

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 Nedelec::compute_basis_functions(), integrate(), main(), normal(), Tetrahedron::repr(), Triangle::repr(), and tangent().
    00067                                                  {
    00068   /* NOTE: 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     // NOTE: 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 220 of file Polygon.cpp.
    00220                  {
    00221    std::ostringstream s;
    00222 //   s <<"Line("<<p[0]<<","<<p[1]<<")";
    00223    s <<"Line";
    00224    return s.str();
    00225 }

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:

- Polygon.h
- Polygon.cpp