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

# Triangle Class Reference

`#include <Polygon.h>`

Inheritance diagram for Triangle:

List of all members.

## Public Member Functions
| Triangle (GiNaC::ex x0, GiNaC::ex x1, GiNaC::ex x1, string subscript="")
| Triangle ()
virtual | ~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 276 of file Polygon.cpp. References Polygon::p, and Polygon::subscript.
    00276                                                                          {
    00277   subscript = subscript_;
    00278   p.insert(p.end(), x0);
    00279   p.insert(p.end(), x1);
    00280   p.insert(p.end(), x2);
    00281
    00282 }

Triangle::Triangle | ( |  | ) | `[inline]`

| Definition at line 89 of file Polygon.h.
    00089 {}

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

| 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 372 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().
    00372                                                              {
    00373
    00374   if ( format == SUBS_PERFORMED ) {
    00375     GiNaC::ex t_repr = repr();
    00376     GiNaC::lst sub;
    00377     int counter;
    00378
    00379
    00380     // perform substitution
    00381     if ( p[0].nops() == 3) {
    00382       sub = GiNaC::lst(t_repr.op(0), t_repr.op(1), t_repr.op(2));
    00383       counter = 3;
    00384     } else if ( p[0].nops() == 2) {
    00385       sub = GiNaC::lst(t_repr.op(0), t_repr.op(1));
    00386       counter = 2;
    00387     }
    00388     GiNaC::ex intf = func.subs(sub);
    00389
    00390     // compute D
    00391     GiNaC::ex D;
    00392     if ( p[0].nops() == 3) {
    00393       GiNaC::ex r = t_repr.op(3).op(0);
    00394       GiNaC::ex s = t_repr.op(4).op(0);
    00395       GiNaC::ex a = t_repr.op(0).rhs().coeff(r,1);
    00396       GiNaC::ex b = t_repr.op(0).rhs().coeff(s,1);
    00397       GiNaC::ex c = t_repr.op(1).rhs().coeff(r,1);
    00398       GiNaC::ex d = t_repr.op(1).rhs().coeff(s,1);
    00399       GiNaC::ex e = t_repr.op(2).rhs().coeff(r,1);
    00400       GiNaC::ex f = t_repr.op(2).rhs().coeff(s,1);
    00401       D = pow(c*f-d*e,2) + pow(a*f - b*e,2) + pow(a*d - b*c,2);
    00402       D = sqrt(D);
    00403     } else if ( p[0].nops() == 2) {
    00404       GiNaC::ex r = t_repr.op(2).op(0);
    00405       GiNaC::ex s = t_repr.op(3).op(0);
    00406       GiNaC::ex a = t_repr.op(0).rhs().coeff(r,1);
    00407       GiNaC::ex b = t_repr.op(0).rhs().coeff(s,1);
    00408       GiNaC::ex c = t_repr.op(1).rhs().coeff(r,1);
    00409       GiNaC::ex d = t_repr.op(1).rhs().coeff(s,1);
    00410       D = abs(a*d-b*c);
    00411     }
    00412
    00413     intf = intf*D;
    00414
    00415
    00416     counter++;
    00417     intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);
    00418     intf = eval_integ(intf);
    00419
    00420     counter--;
    00421     intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);
    00422     intf = eval_integ(intf);
    00423     return intf;
    00424   } else if ( format == SUBS_NOT_PERFORMED ) {
    00425     GiNaC::ex t_repr = repr();
    00426     GiNaC::lst sub;
    00427     int counter;
    00428
    00429     GiNaC::symbol a("a"), b("b"), c("c"), d("d"), e("e"), f("f"), r("r"), s("s"), D("D");
    00430
    00431     // perform substitution
    00432     if ( p[0].nops() == 3) {
    00433       sub = GiNaC::lst(x == p[0].op(0) + a*r + b*s,
    00434                        y == p[0].op(1) + c*r + d*s,
    00435                        z == p[0].op(2) + e*r + f*s);
    00436       counter = 3;
    00437     } else if ( p[0].nops() == 2) {
    00438       sub = GiNaC::lst(t_repr.op(0), t_repr.op(1));
    00439       sub = GiNaC::lst(x == p[0].op(0) + a*r + b*s,
    00440                        y == p[0].op(1) + c*r + d*s);
    00441       counter = 2;
    00442     }
    00443
    00444     GiNaC::ex intf = func.subs(sub);
    00445
    00446     counter++;
    00447     intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);
    00448     intf = eval_integ(intf);
    00449
    00450     counter--;
    00451     intf = GiNaC::integral(t_repr.op(counter).op(0), t_repr.op(counter).op(1), t_repr.op(counter).op(2), intf);
    00452     intf = eval_integ(intf);
    00453
    00454     intf = intf*D;
    00455     return intf;
    00456
    00457   }
    00458   return DUMMY;
    00459
    00460 }

Line Triangle::line | ( | int | i | ) | `[virtual]`

| Reimplemented in ReferenceTriangle. Definition at line 318 of file Polygon.cpp. References istr(), Polygon::p, and Polygon::subscript. Referenced by RaviartThomas::compute_basis_functions(), Nedelec::compute_basis_functions(), CrouzeixRaviart::compute_basis_functions(), ReferenceTriangle::line(), main(), normal(), repr(), and tangent().
    00318                           {
    00319 //  Line l = Line(p[(i-1)%3], p[i%3]);
    00320 //  return l;
    00321   if      ( i == 1) return Line(p[0],p[1], istr(subscript,i));
    00322   else if ( i == 2) return Line(p[0],p[2], istr(subscript,i));
    00323   else if ( i == 3) return Line(p[1],p[2], istr(subscript,i));
    00324 }

int Triangle::no_vertices | ( |  | ) | `[virtual]`

| Reimplemented from Polygon. Reimplemented in ReferenceTriangle. Definition at line 284 of file Polygon.cpp.
    00284 { return 3; }

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

| Reimplemented in ReferenceTriangle. Definition at line 326 of file Polygon.cpp. References line(), Polygon::p, Line::repr(), x, y, and z. Referenced by integrate(), main(), and ReferenceTriangle::repr().
    00326                                           {
    00327    GiNaC::symbol r("r"), s("s");
    00328    GiNaC::symbol G("G"), H("H");
    00329    GiNaC::ex l1_repr = line(1).repr(r);
    00330    GiNaC::ex l2_repr = line(2).repr(s);
    00331    GiNaC::lst ret;
    00332    //2D
    00333    if ( p[0].nops() == 2) {
    00334      ret = GiNaC::lst( x == l1_repr.op(0).rhs().coeff(r,0)
    00335                          +  l1_repr.op(0).rhs().coeff(r,1)*r
    00336                          +  l2_repr.op(0).rhs().coeff(s,1)*s,
    00337                        y == l1_repr.op(1).rhs().coeff(r,0)
    00338                          +  l1_repr.op(1).rhs().coeff(r,1)*r
    00339                          +  l2_repr.op(1).rhs().coeff(s,1)*s);
    00340
    00341
    00342    }
    00343    else if ( p[0].nops() == 3) {
    00344
    00345      ret = GiNaC::lst( x == l1_repr.op(0).rhs().coeff(r,0)
    00346                           + l1_repr.op(0).rhs().coeff(r,1)*r
    00347                           + l2_repr.op(0).rhs().coeff(s,1)*s,
    00348                        y == l1_repr.op(1).rhs().coeff(r,0)
    00349                           + l1_repr.op(1).rhs().coeff(r,1)*r
    00350                           + l2_repr.op(1).rhs().coeff(s,1)*s,
    00351                        z == l1_repr.op(2).rhs().coeff(r,0)
    00352                           + l1_repr.op(2).rhs().coeff(r,1)*r
    00353                           + l2_repr.op(2).rhs().coeff(s,1)*s);
    00354
    00355    }
    00356
    00357    ret.append(GiNaC::lst(r, 0, 1));
    00358    ret.append(GiNaC::lst(s, 0, 1 - r));
    00359
    00360    return ret;
    00361
    00362 }

string Triangle::str | ( |  | ) | `[virtual]`

| Reimplemented from Polygon. Reimplemented in ReferenceTriangle. Definition at line 365 of file Polygon.cpp.
    00365                       {
    00366    std::ostringstream s;
    00367 //   s <<"Triangle("<<p[0]<<","<<p[1]<<","<<p[2]<<")"<<endl;
    00368    s <<"Triangle";
    00369    return s.str();
    00370 }

GiNaC::ex Triangle::vertex | ( | int | i | ) | `[virtual]`

| Reimplemented from Polygon. Reimplemented in ReferenceTriangle. Definition at line 286 of file Polygon.cpp. References Polygon::p. Referenced by bezier_ordinates(), and ReferenceTriangle::vertex().
    00286                                {
    00287   return p[i];
    00288 }

The documentation for this class was generated from the following files:

- Polygon.h
- Polygon.cpp