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

# Square Class Reference

`#include <Polygon.h>`

Inheritance diagram for Square:

List of all members.

## Public Member Functions
| Square (GiNaC::ex p0, GiNaC::ex p1, string subscript="")
| Square ()
virtual | ~Square ()
virtual int | no_vertices ()
virtual GiNaC::ex | vertex (int i)
virtual Line | line (int i)
virtual GiNaC::ex | repr (Repr_format format=SUBS_PERFORMED)
virtual string | str ()
virtual GiNaC::ex | integrate (GiNaC::ex f)

## Detailed Description

Definition at line 113 of file Polygon.h.

## Constructor & Destructor Documentation

Square::Square | ( | GiNaC::ex | p0,
|  | GiNaC::ex | p1,
|  | string | subscript = `""`
| ) |

| Definition at line 513 of file Polygon.cpp. References Polygon::p, and Polygon::subscript.
    00513                                                          {
    00514   subscript = subscript_;
    00515
    00516   GiNaC::ex x0;
    00517   GiNaC::ex x1;
    00518   GiNaC::ex x2;
    00519   GiNaC::ex x3;
    00520
    00521   if (p0.nops() == 2 && p1.nops() == 2) {
    00522
    00523     x0 = GiNaC::lst(p0.op(0), p0.op(1));
    00524     x1 = GiNaC::lst(p1.op(0), p0.op(1));
    00525     x2 = GiNaC::lst(p1.op(0), p1.op(1));
    00526     x3 = GiNaC::lst(p0.op(0), p1.op(1));
    00527
    00528   }
    00529   else if (p0.nops() == 3 && p1.nops() == 3) {
    00530     if ( p0.op(0) == p1.op(0) ) {
    00531
    00532       x0 = GiNaC::lst(p0.op(0), p0.op(1), p0.op(2));
    00533       x1 = GiNaC::lst(p0.op(0), p1.op(1), p0.op(2));
    00534       x2 = GiNaC::lst(p0.op(0), p1.op(1), p1.op(2));
    00535       x3 = GiNaC::lst(p0.op(0), p0.op(1), p1.op(2));
    00536
    00537     } else if ( p0.op(1) == p1.op(1) ) {
    00538
    00539       x0 = GiNaC::lst(p0.op(0), p0.op(1), p0.op(2));
    00540       x1 = GiNaC::lst(p1.op(0), p0.op(1), p0.op(2));
    00541       x2 = GiNaC::lst(p1.op(0), p0.op(1), p1.op(2));
    00542       x3 = GiNaC::lst(p0.op(0), p0.op(1), p1.op(2));
    00543
    00544     } else if ( p0.op(2) == p1.op(2) ) {
    00545
    00546       x0 = GiNaC::lst(p0.op(0), p0.op(1), p0.op(2));
    00547       x1 = GiNaC::lst(p1.op(0), p0.op(1), p0.op(2));
    00548       x2 = GiNaC::lst(p1.op(0), p1.op(1), p0.op(2));
    00549       x3 = GiNaC::lst(p0.op(0), p1.op(1), p0.op(2));
    00550
    00551     }
    00552   } else {
    00553     throw(std::invalid_argument("The points p0 and p1 must be of dimention either 2 or 3."));
    00554   }
    00555
    00556   p.insert(p.end(), x0);
    00557   p.insert(p.end(), x1);
    00558   p.insert(p.end(), x2);
    00559   p.insert(p.end(), x3);
    00560
    00561 }

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

| Definition at line 116 of file Polygon.h.
    00116 {}

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

| Definition at line 117 of file Polygon.h.
    00117 {}

## Member Function Documentation

GiNaC::ex Square::integrate | ( | GiNaC::ex | f | ) | `[virtual]`

| Reimplemented in ReferenceSquare. Definition at line 599 of file Polygon.cpp. References Polygon::p, and repr(). Referenced by ReferenceSquare::integrate(), and main().
    00599                                        {
    00600
    00601     int counter;
    00602     GiNaC::ex s_repr = repr();
    00603
    00604     GiNaC::lst sub;
    00605     // perform substitution
    00606     if ( p[0].nops() == 3) {
    00607       sub = GiNaC::lst(s_repr.op(0), s_repr.op(1), s_repr.op(2));
    00608       counter = 3;
    00609     } else if ( p[0].nops() == 2) {
    00610       sub = GiNaC::lst(s_repr.op(0), s_repr.op(1));
    00611       counter = 2;
    00612     }
    00613
    00614     GiNaC::ex D;
    00615     if (p[0].nops() == 2) {
    00616       D =  ( p[2].op(0) - p[0].op(0))
    00617           *( p[2].op(1) - p[0].op(1));
    00618     } else if (p[0].nops() == 3) {
    00619
    00620       if ( p[2].op(0) == p[0].op(0) ) {
    00621         D =  ( p[2].op(1) - p[0].op(1))
    00622             *( p[2].op(2) - p[0].op(2));
    00623       }
    00624       else if ( p[2].op(1) == p[0].op(1) ) {
    00625         D =  ( p[2].op(0) - p[0].op(0))
    00626             *( p[2].op(2) - p[0].op(2));
    00627       }
    00628       else if ( p[2].op(2) == p[0].op(2) ) {
    00629         D =  ( p[2].op(0) - p[0].op(0))
    00630             *( p[2].op(1) - p[0].op(1));
    00631       }
    00632     }
    00633
    00634     GiNaC::ex intf = func.subs(sub);
    00635
    00636     intf = intf*D;
    00637
    00638     intf = GiNaC::integral(s_repr.op(counter).op(0), s_repr.op(counter).op(1), s_repr.op(counter).op(2), intf);
    00639     intf = eval_integ(intf);
    00640
    00641     counter++;
    00642     intf = GiNaC::integral(s_repr.op(counter).op(0), s_repr.op(counter).op(1), s_repr.op(counter).op(2), intf);
    00643     intf = eval_integ(intf);
    00644
    00645     counter++;
    00646     if ( counter <  s_repr.nops() ) {
    00647       intf = GiNaC::integral(s_repr.op(counter).op(0), s_repr.op(counter).op(1), s_repr.op(counter).op(2), intf);
    00648       intf = eval_integ(intf);
    00649     }
    00650
    00651     return intf;
    00652
    00653
    00654 }

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

| Reimplemented in ReferenceSquare. Definition at line 569 of file Polygon.cpp. References istr(), Polygon::p, and Polygon::subscript. Referenced by ReferenceSquare::line().
    00569                         {
    00570   if      ( i == 1) return Line(p[0],p[1], istr(subscript,i));
    00571   else if ( i == 2) return Line(p[1],p[2], istr(subscript,i));
    00572   else if ( i == 3) return Line(p[2],p[3], istr(subscript,i));
    00573   else if ( i == 4) return Line(p[3],p[0], istr(subscript,i));
    00574 }

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

| Reimplemented from Polygon. Reimplemented in ReferenceSquare. Definition at line 563 of file Polygon.cpp.
    00563 { return 4; }

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

| Reimplemented in ReferenceSquare. Definition at line 576 of file Polygon.cpp. References Polygon::p, x, y, and z. Referenced by integrate(), main(), and ReferenceSquare::repr().
    00576                                         {
    00577    GiNaC::lst ret;
    00578    GiNaC::symbol r("r"), s("s"), t("t");
    00579    if ( p[0].nops() == 2) {
    00580      ret.append( x == p[0].op(0) + r*( p[2].op(0) - p[0].op(0)));
    00581      ret.append( y == p[0].op(1) + s*( p[2].op(1) - p[0].op(1)));
    00582      ret.append( GiNaC::lst(r,0,1));
    00583      ret.append( GiNaC::lst(s,0,1));
    00584    } else if ( p[0].nops() == 3) {
    00585      ret.append( x == p[0].op(0) + r*( p[2].op(0) - p[0].op(0)));
    00586      ret.append( y == p[0].op(1) + s*( p[2].op(1) - p[0].op(1)));
    00587      ret.append( z == p[0].op(1) + t*( p[2].op(2) - p[0].op(2)));
    00588      ret.append( GiNaC::lst(r,0,1));
    00589      ret.append( GiNaC::lst(s,0,1));
    00590      ret.append( GiNaC::lst(t,0,1));
    00591    }
    00592    return ret;
    00593 }

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

| Reimplemented from Polygon. Reimplemented in ReferenceSquare. Definition at line 595 of file Polygon.cpp.
    00595                      {
    00596   return "Square";
    00597 }

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

| Reimplemented from Polygon. Reimplemented in ReferenceSquare. Definition at line 565 of file Polygon.cpp. References Polygon::p.
    00565                               {
    00566   return p[i];
    00567 }

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

- Polygon.h
- Polygon.cpp