// File: gp_Ax2.lxx #include #include #include inline gp_Ax2::gp_Ax2() : vydir(0.,1.,0.), vxdir(1.,0.,0.) { } inline gp_Ax2::gp_Ax2(const gp_Pnt& P, const gp_Dir& N, const gp_Dir& Vx) : axis(P, N), vydir(N), vxdir(N) { vxdir.CrossCross(Vx, N); vydir.Cross(vxdir); } inline void gp_Ax2::SetAxis (const gp_Ax1& A1) { Standard_Real a = A1.Direction() * vxdir; if(Abs(Abs(a) - 1.) <= Precision::Angular()) { if(a > 0.) { vxdir = vydir; vydir = axis.Direction(); axis = A1; } else { vxdir = axis.Direction(); axis = A1; } } else { axis = A1; vxdir = axis.Direction().CrossCrossed (vxdir, axis.Direction()); vydir = axis.Direction().Crossed (vxdir); } } inline void gp_Ax2::SetDirection (const gp_Dir& V) { Standard_Real a = V * vxdir; if(Abs(Abs(a) - 1.) <= Precision::Angular()) { if(a > 0.) { vxdir = vydir; vydir = axis.Direction(); axis.SetDirection (V); } else { vxdir = axis.Direction(); axis.SetDirection (V); } } else { axis.SetDirection (V); vxdir = V.CrossCrossed (vxdir, V); vydir = V.Crossed (vxdir); } } inline void gp_Ax2::SetLocation (const gp_Pnt& P) { axis.SetLocation(P); } inline void gp_Ax2::SetXDirection (const gp_Dir& Vx) { vxdir = axis.Direction().CrossCrossed (Vx, axis.Direction()); vydir = axis.Direction().Crossed (vxdir); } inline void gp_Ax2::SetYDirection (const gp_Dir& Vy) { vxdir = Vy.Crossed (axis.Direction()); vydir = (axis.Direction()).Crossed (vxdir); } inline Standard_Real gp_Ax2::Angle (const gp_Ax2& Other) const { return axis.Angle (Other.axis); } inline const gp_Ax1& gp_Ax2::Axis () const { return axis; } inline const gp_Dir& gp_Ax2::Direction () const { return axis.Direction(); } inline const gp_Pnt& gp_Ax2::Location () const { return axis.Location(); } inline const gp_Dir& gp_Ax2::XDirection () const { return vxdir; } inline const gp_Dir& gp_Ax2::YDirection () const { return vydir; } inline Standard_Boolean gp_Ax2::IsCoplanar (const gp_Ax2& Other, const Standard_Real LinearTolerance, const Standard_Real AngularTolerance) const { const gp_Dir& DD = axis.Direction(); const gp_Pnt& PP = axis.Location (); const gp_Pnt& OP = Other.axis.Location (); Standard_Real D1 = (DD.X() * (OP.X() - PP.X()) + DD.Y() * (OP.Y() - PP.Y()) + DD.Z() * (OP.Z() - PP.Z())); if (D1 < 0 ) D1 = - D1; return (D1 <= LinearTolerance && axis.IsParallel (Other.axis, AngularTolerance)); } inline Standard_Boolean gp_Ax2::IsCoplanar (const gp_Ax1& A, const Standard_Real LinearTolerance, const Standard_Real AngularTolerance) const { const gp_Dir& DD = axis.Direction(); const gp_Pnt& PP = axis.Location (); const gp_Pnt& AP = A .Location (); Standard_Real D1 = (DD.X() * (AP.X() - PP.X()) + DD.Y() * (AP.Y() - PP.Y()) + DD.Z() * (AP.Z() - PP.Z())); if (D1 < 0) D1 = - D1; return (D1 <= LinearTolerance && axis.IsNormal (A, AngularTolerance)); } inline void gp_Ax2::Rotate(const gp_Ax1& A1, const Standard_Real Ang) { gp_Pnt Temp = axis.Location(); Temp.Rotate (A1, Ang); axis.SetLocation (Temp); vxdir.Rotate (A1, Ang); vydir.Rotate (A1, Ang); axis.SetDirection (vxdir.Crossed (vydir)); } inline gp_Ax2 gp_Ax2::Rotated(const gp_Ax1& A1, const Standard_Real Ang) const { gp_Ax2 Temp = *this; Temp.Rotate (A1, Ang); return Temp; } inline void gp_Ax2::Scale (const gp_Pnt& P, const Standard_Real S) { gp_Pnt Temp = axis.Location(); Temp.Scale (P, S); axis.SetLocation (Temp); if (S < 0.0) { vxdir.Reverse (); vydir.Reverse (); } } inline gp_Ax2 gp_Ax2::Scaled(const gp_Pnt& P, const Standard_Real S) const { gp_Ax2 Temp = *this; Temp.Scale (P, S); return Temp; } inline void gp_Ax2::Transform (const gp_Trsf& T) { gp_Pnt Temp = axis.Location(); Temp.Transform (T); axis.SetLocation (Temp); vxdir.Transform (T); vydir.Transform (T); axis.SetDirection (vxdir.Crossed (vydir)); } inline gp_Ax2 gp_Ax2::Transformed(const gp_Trsf& T) const { gp_Ax2 Temp = *this; Temp.Transform (T); return Temp; } inline void gp_Ax2::Translate (const gp_Vec& V) { axis.Translate (V); } inline gp_Ax2 gp_Ax2::Translated(const gp_Vec& V) const { gp_Ax2 Temp = *this; Temp.Translate (V); return Temp; } inline void gp_Ax2::Translate (const gp_Pnt& P1, const gp_Pnt& P2) { axis.Translate (P1, P2); } inline gp_Ax2 gp_Ax2::Translated (const gp_Pnt& P1, const gp_Pnt& P2) const { gp_Ax2 Temp = *this; Temp.Translate (P1, P2); return Temp; }