xc
Quadrilateral3d.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //Quadrilateral3d.h
22 
23 #ifndef QUADRILATERAL3D_H
24 #define QUADRILATERAL3D_H
25 
26 #include "utility/geom/d2/D2to3d.h"
27 #include "utility/geom/d2/2d_polygons/Quadrilateral2d.h"
28 
29 class Polygon3d;
30 class Pos3dArray;
31 
33 //
35 class Quadrilateral3d: public D2to3d
36  {
37  Quadrilateral2d quad2d;
38  public:
39  Quadrilateral3d(void): D2to3d(), quad2d() {}
40  Quadrilateral3d(const Pos3d &p1,const Pos3d &p2,const Pos3d &p3, const Pos3d &p4);
44  Quadrilateral3d(const boost::python::list &);
45  virtual GeomObj *getCopy(void) const
46  { return new Quadrilateral3d(*this); }
47 
48  Polygon3d getPolygon3d(void) const;
49 
50  inline virtual unsigned int getNumVertices(void) const
51  { return quad2d.getNumVertices(); }
52  inline virtual unsigned int getNumEdges(void) const
53  { return quad2d.getNumEdges(); }
55  inline GEOM_FT getLength(void) const
56  { return quad2d.getLength(); }
58  inline GEOM_FT getArea(void) const
59  { return quad2d.getArea(); }
60  inline std::vector<double> getTributaryAreas(void) const
61  { return quad2d.getTributaryAreas(); }
63  inline Pos3d Vertice(unsigned int i) const
64  { return to_3d(quad2d.Vertice(i)); }
67  inline Pos3d Vertice0(unsigned int j) const
68  { return to_3d(quad2d.Vertice0(j)); }
70  boost::python::list getVertexListPy(void) const;
71  Segment3d Lado0(unsigned int i) const;
72  Segment3d Lado(unsigned int i) const;
73  int getIndexOfDistalEdge(const Pos3d &) const;
74  int getIndexOfProximalEdge(const Pos3d &) const;
75  int getIndexOfDistalVertex(const Pos3d &) const;
76  int getIndexOfProximalVertex(const Pos3d &) const;
77 
78  bool clockwise(const Pos3d &) const;
79  bool counterclockwise(const Pos3d &) const;
80  void swap(void);
81  std::string orientation(const Pos3d &) const;
82 
83  Plane getPlaneFromSide0(unsigned int i) const;
84  Plane getPlaneFromSide(unsigned int i) const;
85 
86  Vector3d getNormal(void) const;
87 
88  Pos3d getCenterOfMass(void) const;
89  Pos3d Centroid(void) const;
90  GEOM_FT Ix(void) const;
91  GEOM_FT Iy(void) const;
92  GEOM_FT Iz(void) const;
93 
94  GEOM_FT GetMax(unsigned short int i) const;
95  GEOM_FT GetMin(unsigned short int i) const;
96  bool In(const Pos3d &p,const double &tol) const;
97  bool TocaCuadrante(const int &) const;
98 
99  GEOM_FT distSigno(const Pos3d &p) const;
100  GEOM_FT dist(const Pos3d &p) const;
101  GEOM_FT distSigno2(const Pos3d &p) const;
102  GEOM_FT dist2(const Pos3d &p) const;
103 
104 
105  std::vector<double> getNaturalCoordinates(const Pos3d &) const;
106  std::vector<std::vector<double> > getNaturalCoordinates(const std::list<Pos3d> &) const;
107  boost::python::list getNaturalCoordinatesPy(const boost::python::list &) const;
108  std::vector<double> Ni(const Pos3d &) const;
109  std::vector<std::vector<double> > Ni(const std::list<Pos3d> &) const;
110  boost::python::list NiPy(const Pos3d &) const;
111  boost::python::list NiPy(const boost::python::list &) const;
112  Pos3d getMidpoint(void) const;
113 
114  Segment3d Clip(const Line3d &) const;
115  Segment3d Clip(const Ray3d &) const;
116  Segment3d Clip(const Segment3d &) const;
117 
118  bool intersects(const Line3d &) const;
119  Segment3d getIntersection(const Line3d &) const;
120  bool intersects(const Plane &) const;
121  Segment3d getIntersection(const Plane &) const;
122 
123  Pos3dArray genMesh(int n1,int n2) const;
124  Pos3dArray genBilinMesh(const size_t &n1,const size_t &n2) const;
125 
126  void Print(std::ostream &os) const;
127  };
128 
129 #endif
GEOM_FT dist(const Pos3d &p) const
Return the distance from point to quadrilateral.
Definition: Quadrilateral3d.cc:352
GEOM_FT getArea(void) const
Return the area of the object.
Definition: Quadrilateral3d.h:58
GeomObj::list_Pos3d getVertexList(void) const
Return a Python list containing the positions of the quadrilateral vertices.
Definition: Quadrilateral3d.cc:83
Plane polygon in a 3D space.
Definition: Polygon3d.h:35
Pos3dArray genBilinMesh(const size_t &n1, const size_t &n2) const
Returns a point grid (the routine is taken from OpenSees).
Definition: Quadrilateral3d.cc:583
Segment en tres dimensiones.
Definition: Segment3d.h:41
Base class for position lists.
Definition: PolyPos.h:35
int getIndexOfDistalVertex(const Pos3d &) const
Return the distal vertex with respect to the point argument.
Definition: Quadrilateral3d.cc:166
Plane quadrilateral in a 3D space.
Definition: Quadrilateral3d.h:35
int getIndexOfDistalEdge(const Pos3d &) const
Return the index of the distal edge with respect to the point argument.
Definition: Quadrilateral3d.cc:121
GEOM_FT getLength(void) const
Return the length of the object.
Definition: Quadrilateral3d.h:55
Array of positions in a three-dimensional space.
Definition: Pos3dArray.h:38
GEOM_FT Iz(void) const
Moment of inertia with respect to an axis parallel to the z axis passing through the center of mass...
Definition: Quadrilateral3d.cc:273
Pos3d Centroid(void) const
Return the centroid (point interior to the polygon).
Definition: Quadrilateral3d.cc:243
Pos2d Vertice(unsigned int i) const
Return the position of the i-th vertex.
Definition: Polygon2d.h:157
Segment3d Clip(const Line3d &) const
Return the intersection of the quadrilateral with the line.
Definition: Quadrilateral3d.cc:427
Plane in a three-dimensional space.
Definition: Plane.h:49
Segment3d getIntersection(const Line3d &) const
Return the intersection with the line argument.
Definition: Quadrilateral3d.cc:506
int getIndexOfProximalEdge(const Pos3d &) const
Return the proximal edge with respect to the point argument.
Definition: Quadrilateral3d.cc:141
Pos2d Vertice0(unsigned int j) const
Return the position of the i-th vertex (0 based: j=0..getNumVertices()-1).
Definition: Polygon2d.h:161
Segment3d Lado(unsigned int i) const
Return the i-th edge (i between 1 and num_sides).
Definition: Quadrilateral3d.cc:105
bool In(const Pos3d &p, const double &tol) const
Return true if the point lies inside the quadrilateral (i.
Definition: Quadrilateral3d.cc:217
Vector3d getNormal(void) const
Return the normal to the quadrilateral.
Definition: Quadrilateral3d.cc:250
bool intersects(const Line3d &) const
Return true if the line intersects the quadrilateral.
Definition: Quadrilateral3d.cc:499
Ray in a three-dimensional space.
Definition: Ray3d.h:36
boost::python::list getVertexListPy(void) const
Return a Python list containing the positions of the quadrilateral vertices.
Definition: Quadrilateral3d.cc:94
GEOM_FT dist2(const Pos3d &p) const
Return the distance from point to quadrilateral.
Definition: Quadrilateral3d.cc:340
std::vector< double > getNaturalCoordinates(const Pos3d &) const
Return natural coordinates for point xy (in cartesian coord.) based on $ 23.6 from Felippa book:"Intr...
Definition: Quadrilateral3d.cc:363
Pos3d getMidpoint(void) const
Return the intersection between the lines that join the midpoints of the quadrilateral sides...
Definition: Quadrilateral3d.cc:423
bool counterclockwise(const Pos3d &) const
Return true if the point list is oriented counterclockwise.
Definition: Quadrilateral3d.cc:539
std::string orientation(const Pos3d &) const
Return the orientation of the quadrilateral (clockwise or counterclockwise).
Definition: Quadrilateral3d.cc:564
GEOM_FT GetMin(unsigned short int i) const
Return the minimum value of the i-th coordinate.
Definition: Quadrilateral3d.cc:285
GEOM_FT distSigno2(const Pos3d &p) const
Return the squared distance from from point to quadrilateral.
Definition: Quadrilateral3d.cc:311
Class that places 2D objects (circle, ellipse, polygons, ...) in a 3D space.
Definition: D2to3d.h:44
std::vector< double > Ni(const Pos3d &) const
Return the values of the shape functions for the point argument.
Definition: Quadrilateral3d.cc:389
Pos3d Vertice(unsigned int i) const
Return the position of the i-th vertex.
Definition: Quadrilateral3d.h:63
int getIndexOfProximalVertex(const Pos3d &) const
Return the proximal vertex with respect to the point argument.
Definition: Quadrilateral3d.cc:186
D2to3d(void)
Constructor.
Definition: D2to3d.cc:40
Segment3d Lado0(unsigned int i) const
Return the i-th side (i between 0 and num_sides-1).
Definition: Quadrilateral3d.cc:112
Pos3dArray genMesh(int n1, int n2) const
Returns a point grid.
Definition: Quadrilateral3d.cc:573
Quadrilateral on a bi-dimensional space.
Definition: Quadrilateral2d.h:44
std::vector< double > getTributaryAreas(void) const
Return the areas of the tributary polygons (one for each vertex).
Definition: Polygon2d.cc:415
Posición en tres dimensiones.
Definition: Pos3d.h:44
bool TocaCuadrante(const int &) const
Return true if alguno de los vertices toca el cuadrante que se pasa como parámetro.
Definition: Quadrilateral3d.cc:523
Line in a three-dimensional space.
Definition: Line3d.h:62
bool clockwise(const Pos3d &) const
Return true if the point list is oriented clockwise.
Definition: Quadrilateral3d.cc:534
GEOM_FT GetMax(unsigned short int i) const
Return the maximum value of the i-th coordinate.
Definition: Quadrilateral3d.cc:280
boost::python::list NiPy(const Pos3d &) const
Return a Python list containing the values of the shape functions for the point argument.
Definition: Quadrilateral3d.cc:418
GEOM_FT Iy(void) const
Moment of inertia with respect to an axis parallel to the y axis passing through the center of mass...
Definition: Quadrilateral3d.cc:264
virtual GEOM_FT getArea(void) const
Return the polygon area.
Definition: Polygon2d.cc:383
Pos3d Vertice0(unsigned int j) const
Return the position of the i-th vertex (0 based: j=0..getNumVertices()-1)
Definition: Quadrilateral3d.h:67
Pos3d getCenterOfMass(void) const
Return the center of mass of the quadrilateral.
Definition: Quadrilateral3d.cc:233
Clase base para las entidades geométricas.
Definition: GeomObj.h:40
Vector en tres dimensiones.
Definition: Vector3d.h:39
Two-dimensional reference system defined in a three-dimensional space.
Definition: Ref2d3d.h:41
virtual GEOM_FT getLength(void) const
Return the perimeter of the surface.
Definition: PolygonalSurface2d.cc:90
GEOM_FT Ix(void) const
Moment of inertia with respect to an axis parallel to the x axis passing through the center of mass...
Definition: Quadrilateral3d.cc:255
Three-dimensional reference system defined in a three-dimensional space.
Definition: Ref3d3d.h:39
Pos3d to_3d(const Pos2d &) const
Return the 3D point corresponding to the 2D point argument.
Definition: D2to3d.cc:100