File indexing completed on 2026-09-12 09:17:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _gp_Ax22d_HeaderFile
0016 #define _gp_Ax22d_HeaderFile
0017
0018 #include <gp_Ax2d.hxx>
0019 #include <gp_Dir2d.hxx>
0020 #include <gp_Pnt2d.hxx>
0021 #include <gp_Trsf2d.hxx>
0022 #include <gp_Vec2d.hxx>
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041 class gp_Ax22d
0042 {
0043 public:
0044 DEFINE_STANDARD_ALLOC
0045
0046
0047
0048 constexpr gp_Ax22d() noexcept
0049 : vydir(gp_Dir2d::D::Y)
0050
0051 {
0052 }
0053
0054
0055
0056
0057
0058
0059
0060 constexpr gp_Ax22d(const gp_Pnt2d& theP, const gp_Dir2d& theVx, const gp_Dir2d& theVy)
0061 : point(theP),
0062 vydir(theVy),
0063 vxdir(theVx)
0064 {
0065 const double aValue = theVx.Crossed(theVy);
0066 if (aValue >= 0.0)
0067 {
0068 vydir.SetCoord(-vxdir.Y(), vxdir.X());
0069 }
0070 else
0071 {
0072 vydir.SetCoord(vxdir.Y(), -vxdir.X());
0073 }
0074 }
0075
0076
0077
0078
0079
0080 constexpr gp_Ax22d(const gp_Pnt2d& theP, const gp_Dir2d& theV, const bool theIsSense = true)
0081 : point(theP),
0082 vxdir(theV)
0083 {
0084 if (theIsSense)
0085 {
0086 vydir.SetCoord(-theV.Y(), theV.X());
0087 }
0088 else
0089 {
0090 vydir.SetCoord(theV.Y(), -theV.X());
0091 }
0092 }
0093
0094
0095
0096
0097
0098 constexpr gp_Ax22d(const gp_Ax2d& theA, const bool theIsSense = true)
0099 : point(theA.Location()),
0100 vxdir(theA.Direction())
0101 {
0102 if (theIsSense)
0103 {
0104 vydir.SetCoord(-vxdir.Y(), vxdir.X());
0105 }
0106 else
0107 {
0108 vydir.SetCoord(vxdir.Y(), -vxdir.X());
0109 }
0110 }
0111
0112
0113
0114 constexpr void SetAxis(const gp_Ax22d& theA1) noexcept
0115 {
0116 point = theA1.Location();
0117 vxdir = theA1.XDirection();
0118 vydir = theA1.YDirection();
0119 }
0120
0121
0122
0123
0124 constexpr void SetXAxis(const gp_Ax2d& theA1);
0125
0126
0127
0128 constexpr void SetYAxis(const gp_Ax2d& theA1);
0129
0130
0131 constexpr void SetLocation(const gp_Pnt2d& theP) noexcept { point = theP; }
0132
0133
0134
0135
0136
0137
0138 constexpr void SetXDirection(const gp_Dir2d& theVx);
0139
0140
0141
0142
0143
0144
0145 constexpr void SetYDirection(const gp_Dir2d& theVy);
0146
0147
0148
0149
0150
0151 gp_Ax2d XAxis() const { return gp_Ax2d(point, vxdir); }
0152
0153
0154
0155
0156
0157 gp_Ax2d YAxis() const { return gp_Ax2d(point, vydir); }
0158
0159
0160 constexpr const gp_Pnt2d& Location() const noexcept { return point; }
0161
0162
0163 constexpr const gp_Dir2d& XDirection() const noexcept { return vxdir; }
0164
0165
0166 constexpr const gp_Dir2d& YDirection() const noexcept { return vydir; }
0167
0168 Standard_EXPORT void Mirror(const gp_Pnt2d& theP) noexcept;
0169
0170
0171
0172
0173
0174
0175
0176
0177 [[nodiscard]] Standard_EXPORT gp_Ax22d Mirrored(const gp_Pnt2d& theP) const noexcept;
0178
0179 Standard_EXPORT void Mirror(const gp_Ax2d& theA) noexcept;
0180
0181
0182
0183
0184
0185
0186
0187
0188 [[nodiscard]] Standard_EXPORT gp_Ax22d Mirrored(const gp_Ax2d& theA) const noexcept;
0189
0190 void Rotate(const gp_Pnt2d& theP, const double theAng);
0191
0192
0193
0194
0195 [[nodiscard]] gp_Ax22d Rotated(const gp_Pnt2d& theP, const double theAng) const
0196 {
0197 gp_Ax22d aTemp = *this;
0198 aTemp.Rotate(theP, theAng);
0199 return aTemp;
0200 }
0201
0202 void Scale(const gp_Pnt2d& theP, const double theS);
0203
0204
0205
0206
0207
0208
0209
0210
0211 [[nodiscard]] gp_Ax22d Scaled(const gp_Pnt2d& theP, const double theS) const
0212 {
0213 gp_Ax22d aTemp = *this;
0214 aTemp.Scale(theP, theS);
0215 return aTemp;
0216 }
0217
0218 void Transform(const gp_Trsf2d& theT) noexcept;
0219
0220
0221
0222
0223
0224
0225 [[nodiscard]] gp_Ax22d Transformed(const gp_Trsf2d& theT) const
0226 {
0227 gp_Ax22d aTemp = *this;
0228 aTemp.Transform(theT);
0229 return aTemp;
0230 }
0231
0232 constexpr void Translate(const gp_Vec2d& theV) noexcept { point.Translate(theV); }
0233
0234
0235
0236 [[nodiscard]] constexpr gp_Ax22d Translated(const gp_Vec2d& theV) const noexcept
0237 {
0238 gp_Ax22d aTemp = *this;
0239 aTemp.Translate(theV);
0240 return aTemp;
0241 }
0242
0243 constexpr void Translate(const gp_Pnt2d& theP1, const gp_Pnt2d& theP2) noexcept
0244 {
0245 point.Translate(theP1, theP2);
0246 }
0247
0248
0249
0250 [[nodiscard]] constexpr gp_Ax22d Translated(const gp_Pnt2d& theP1,
0251 const gp_Pnt2d& theP2) const noexcept
0252 {
0253 gp_Ax22d aTemp = *this;
0254 aTemp.Translate(theP1, theP2);
0255 return aTemp;
0256 }
0257
0258
0259 Standard_EXPORT void DumpJson(Standard_OStream& theOStream, int theDepth = -1) const;
0260
0261 private:
0262 gp_Pnt2d point;
0263 gp_Dir2d vydir;
0264 gp_Dir2d vxdir;
0265 };
0266
0267
0268
0269 inline constexpr void gp_Ax22d::SetXAxis(const gp_Ax2d& theA1)
0270 {
0271 const bool isSign = (vxdir.Crossed(vydir)) >= 0.0;
0272 point = theA1.Location();
0273 vxdir = theA1.Direction();
0274 if (isSign)
0275 {
0276 vydir.SetCoord(-vxdir.Y(), vxdir.X());
0277 }
0278 else
0279 {
0280 vydir.SetCoord(vxdir.Y(), -vxdir.X());
0281 }
0282 }
0283
0284
0285
0286 inline constexpr void gp_Ax22d::SetYAxis(const gp_Ax2d& theA1)
0287 {
0288 const bool isSign = (vxdir.Crossed(vydir)) >= 0.0;
0289 point = theA1.Location();
0290 vydir = theA1.Direction();
0291 if (isSign)
0292 {
0293 vxdir.SetCoord(vydir.Y(), -vydir.X());
0294 }
0295 else
0296 {
0297 vxdir.SetCoord(-vydir.Y(), vydir.X());
0298 }
0299 }
0300
0301
0302
0303 inline constexpr void gp_Ax22d::SetXDirection(const gp_Dir2d& theVx)
0304 {
0305 const bool isSign = (vxdir.Crossed(vydir)) >= 0.0;
0306 vxdir = theVx;
0307 if (isSign)
0308 {
0309 vydir.SetCoord(-theVx.Y(), theVx.X());
0310 }
0311 else
0312 {
0313 vydir.SetCoord(theVx.Y(), -theVx.X());
0314 }
0315 }
0316
0317
0318
0319 inline constexpr void gp_Ax22d::SetYDirection(const gp_Dir2d& theVy)
0320 {
0321 const bool isSign = (vxdir.Crossed(vydir)) >= 0.0;
0322 vydir = theVy;
0323 if (isSign)
0324 {
0325 vxdir.SetCoord(theVy.Y(), -theVy.X());
0326 }
0327 else
0328 {
0329 vxdir.SetCoord(-theVy.Y(), theVy.X());
0330 }
0331 }
0332
0333
0334
0335 inline void gp_Ax22d::Rotate(const gp_Pnt2d& theP, const double theAng)
0336 {
0337 gp_Pnt2d aTemp = point;
0338 aTemp.Rotate(theP, theAng);
0339 point = aTemp;
0340 vxdir.Rotate(theAng);
0341 vydir.Rotate(theAng);
0342 }
0343
0344
0345
0346 inline void gp_Ax22d::Scale(const gp_Pnt2d& theP, const double theS)
0347 {
0348 gp_Pnt2d aTemp = point;
0349 aTemp.Scale(theP, theS);
0350 point = aTemp;
0351 if (theS < 0.0)
0352 {
0353 vxdir.Reverse();
0354 vydir.Reverse();
0355 }
0356 }
0357
0358
0359
0360 inline void gp_Ax22d::Transform(const gp_Trsf2d& theT) noexcept
0361 {
0362 gp_Pnt2d aTemp = point;
0363 aTemp.Transform(theT);
0364 point = aTemp;
0365 vxdir.Transform(theT);
0366 vydir.Transform(theT);
0367 }
0368
0369 #endif