15 #ifndef __IPSDKGEOMETRY_RECTANGLE2D_H__ 16 #define __IPSDKGEOMETRY_RECTANGLE2D_H__ 20 #pragma warning (push) 21 #pragma warning (disable : 4251) 24 #include <IPSDKGeometry/Entity/2d/BaseTypedGeometryEntity2d.h> 25 #include <IPSDKGeometry/Entity/2d/Point/Point2d.h> 54 Rectangle2d(
const T xCenter,
const T yCenter,
const T halfLength,
const T halfWidth,
const ipReal64 orientation);
69 inline void setCenter(
const Point2d<T>& centerPt);
70 inline void setCenter(
const T xMin,
const T yMin);
71 inline void setHalfLength(
const T halfLength);
72 inline void setHalfWidth(
const T halfWidth);
73 inline void setOrientation(
const ipReal64 orientation);
74 inline ipReal64 getOrientation()
const;
75 inline T centerX()
const;
76 inline T centerY()
const;
78 inline T getHalfLength()
const;
79 inline T getHalfWidth()
const;
80 inline T getLength()
const;
81 inline T getWidth()
const;
82 inline T getArea()
const;
112 template <
typename T>
116 return g_coordinateSystem2dType;
119 template <
typename T>
123 return g_entity2dType;
126 template <
typename T>
130 _centerPt = centerPt;
133 template <
typename T>
140 template <
typename T>
144 _centerPt.setCoords(xMin, yMin);
147 template <
typename T>
151 _halfLength = halfLength;
154 template <
typename T>
158 _halfWidth = halfWidth;
161 template <
typename T>
168 template <
typename T>
175 template <
typename T>
182 template <
typename T>
186 _orientation = orientation;
189 template <
typename T>
196 template <
typename T>
203 template <
typename T>
207 return 2 * this->getHalfLength();
210 template <
typename T>
214 return 2 * this->getHalfWidth();
217 template <
typename T>
221 return this->getLength() * this->getWidth();
224 template <
typename T>
231 template <
typename T>
235 const ipReal64 modulus =
std::sqrt(_halfLength*_halfLength + _halfWidth*_halfWidth);
236 const ipReal64 alpha = std::atan(_halfWidth/_halfLength);
237 return Point2dData<T>(
static_cast<T
>(modulus*std::cos(_orientation+M_PI+alpha)) + _centerPt._x,
238 static_cast<T>(modulus*std::sin(_orientation+M_PI+alpha)) + _centerPt._y);
241 template <
typename T>
245 const ipReal64 modulus =
std::sqrt(_halfLength*_halfLength + _halfWidth*_halfWidth);
246 const ipReal64 alpha = std::atan(_halfWidth/_halfLength);
247 return Point2dData<T>(
static_cast<T
>(modulus*std::cos(_orientation-alpha)) + _centerPt._x,
248 static_cast<T>(modulus*std::sin(_orientation-alpha)) + _centerPt._y);
251 template <
typename T>
255 const ipReal64 modulus =
std::sqrt(_halfLength*_halfLength + _halfWidth*_halfWidth);
256 const ipReal64 alpha = std::atan(_halfWidth/_halfLength);
257 return Point2dData<T>(
static_cast<T
>(modulus*std::cos(_orientation+M_PI-alpha) )+ _centerPt._x,
258 static_cast<T>(modulus*std::sin(_orientation+M_PI-alpha)) + _centerPt._y);
261 template <
typename T>
265 const ipReal64 modulus =
std::sqrt(_halfLength*_halfLength + _halfWidth*_halfWidth);
266 const ipReal64 alpha = std::atan(_halfWidth/_halfLength);
267 return Point2dData<T>(
static_cast<T
>(modulus*std::cos(_orientation+alpha)) + _centerPt._x,
268 static_cast<T>(modulus*std::sin(_orientation+alpha)) + _centerPt._y);
277 #pragma warning (pop) 279 #endif // __IPSDKGEOMETRY_RECTANGLE2D_H__ void setCenter(const Point2dData< T > ¢erPt)
access to rectangle coordinates
Definition: Rectangle2d.h:128
T getHalfLength() const
access to rectangle coordinates
Definition: Rectangle2d.h:191
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
T getWidth() const
access to rectangle coordinates
Definition: Rectangle2d.h:212
Point class associated to cartesian 2d coordinates.
Definition: GeometryEntity2dTypes.h:28
Rectangle.
Definition: GeometryEntity2dTypes.h:60
IPSDK_FORCEINLINE PackT sqrt(const PackT &in)
returns the square root of a pack
Definition: sqrt.h:40
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
eCoordinateSystem2dType
Enumerate describing coordinate system 2d type.
Definition: GeometryEntity2dTypes.h:76
eEntity2dType getEntity2dType() const
method allowing to retrieve entity 2d type
Definition: Rectangle2d.h:121
Point2dData< T > bottomRightCorner() const
compute rectangle corners coordinates For instance, the topLeftCorner() method calculates the coordin...
Definition: Rectangle2d.h:263
Point2dData< T > topRightCorner() const
compute rectangle corners coordinates For instance, the topLeftCorner() method calculates the coordin...
Definition: Rectangle2d.h:243
Definition of import/export macro for library.
T centerX() const
access to rectangle coordinates
Definition: Rectangle2d.h:163
#define IPSDKGEOMETRY_API
Import/Export macro for library IPSDKGeometry.
Definition: IPSDKGeometryExports.h:25
Base class for typed 3d geometry entities.
Definition: BaseTypedGeometryEntity2d.h:27
void setHalfLength(const T halfLength)
access to rectangle coordinates
Definition: Rectangle2d.h:149
#define IPSDK_DECLARE_GEOMETRY_ENTITY_2D(libraryName, className)
Macro allowing to declare a geometry entity 2d.
Definition: GeometryEntity2dHdrMacros.h:131
T getArea() const
access to rectangle coordinates
Definition: Rectangle2d.h:219
T getHalfWidth() const
access to rectangle coordinates
Definition: Rectangle2d.h:198
ipReal64 _orientation
orientation (in radian) of the rectangle
Definition: Rectangle2d.h:105
eCoordinateSystem2dType getCoordinateSystem2dType() const
method allowing to retrieve coordinate system 2d type
Definition: Rectangle2d.h:114
void setHalfWidth(const T halfWidth)
access to rectangle coordinates
Definition: Rectangle2d.h:156
void setOrientation(const ipReal64 orientation)
access to rectangle coordinates
Definition: Rectangle2d.h:184
const Point2dData< T > & getCoords() const
access to point coordinates
Definition: Point2d.h:139
2d rectangle class associated to cartesian 2d coordinates
Definition: Rectangle2d.h:35
eEntity2dType
Enumerate describing entity 2d type.
Definition: GeometryEntity2dTypes.h:38
T getLength() const
access to rectangle coordinates
Definition: Rectangle2d.h:205
T centerY() const
access to rectangle coordinates
Definition: Rectangle2d.h:170
Point2dData< T > topLeftCorner() const
compute rectangle corners coordinates For instance, the topLeftCorner() method calculates the coordin...
Definition: Rectangle2d.h:233
Lightweight structure used to store Point2d data.
Definition: GeometryEntity2dTypes.h:26
const Point2dData< T > & center() const
access to rectangle coordinates
Definition: Rectangle2d.h:177
ipReal64 getOrientation() const
access to rectangle coordinates
Definition: Rectangle2d.h:226
Point2dData< T > _centerPt
coordinates associated to the center of the rectangle
Definition: Rectangle2d.h:98
Point2dData< T > bottomLeftCorner() const
compute rectangle corners coordinates For instance, the topLeftCorner() method calculates the coordin...
Definition: Rectangle2d.h:253
Cartesian coordinate system.
Definition: GeometryEntity2dTypes.h:78
T _halfLength
half lengths of the rectangle sides
Definition: Rectangle2d.h:101