summaryrefslogtreecommitdiff
path: root/inc/gp_Ax3.lxx
blob: 50c177a434927e7af703484ff243cd486de68645 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
// File:	gp_Ax3.lxx

#include <gp.hxx>
#include <gp_Ax2.hxx>
#include <gp_Ax1.hxx>

inline gp_Ax3::gp_Ax3() : vydir(0.,1.,0.), vxdir(1.,0.,0.)
{ }

inline gp_Ax3::gp_Ax3(const gp_Ax2& A) :
axis(A.Axis()),
vydir(A.YDirection()),
vxdir(A.XDirection())
{ }

inline gp_Ax3::gp_Ax3(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_Ax3::XReverse()
{ vxdir.Reverse(); }

inline void  gp_Ax3::YReverse()
{ vydir.Reverse(); }

inline void  gp_Ax3::ZReverse()
{ axis.Reverse();  }

inline void  gp_Ax3::SetAxis(const gp_Ax1& A1)
{
  Standard_Boolean direct = Direct();
  axis = A1;
  vxdir = axis.Direction().CrossCrossed (vxdir, axis.Direction());
  if(direct) { vydir = axis.Direction().Crossed(vxdir); }
  else       { vydir = vxdir.Crossed(axis.Direction()); }
}

inline void  gp_Ax3::SetDirection(const gp_Dir& V)
{
  Standard_Boolean direct = Direct();
  axis.SetDirection (V);
  vxdir = V.CrossCrossed (vxdir, V);
  if (direct) { vydir = V.Crossed (vxdir); }
  else        { vydir = vxdir.Crossed (V); }
}

inline void  gp_Ax3::SetLocation(const gp_Pnt& P)
{  axis.SetLocation(P); }

inline void  gp_Ax3::SetXDirection(const gp_Dir& Vx)
{
  Standard_Boolean direct = Direct();
  vxdir = axis.Direction().CrossCrossed (Vx, axis.Direction());
  if (direct) { vydir = axis.Direction().Crossed(vxdir); }
  else        { vydir = vxdir.Crossed(axis.Direction()); }
}

inline void  gp_Ax3::SetYDirection(const gp_Dir& Vy)
{
  Standard_Boolean direct = Direct();
  vxdir = Vy.Crossed (axis.Direction());
  vydir = (axis.Direction()).Crossed (vxdir);
  if (!direct) { vxdir.Reverse(); }
}

inline Standard_Real  gp_Ax3::Angle(const gp_Ax3& Other) const 
{ return axis.Angle (Other.axis); }

inline const gp_Ax1&  gp_Ax3::Axis()const
{  return axis; }

inline gp_Ax2  gp_Ax3::Ax2()const 
{
  gp_Dir zz = axis.Direction();
  if (!Direct()) { zz.Reverse(); }
  return gp_Ax2 (axis.Location(),zz,vxdir);
}

inline const gp_Dir&  gp_Ax3::Direction()const
{   return axis.Direction(); }

inline const gp_Pnt&  gp_Ax3::Location()const
{   return axis.Location(); }

inline const gp_Dir&  gp_Ax3::XDirection()const
{  return vxdir;  }

inline const gp_Dir&  gp_Ax3::YDirection()const
{  return vydir; }

inline Standard_Boolean  gp_Ax3::Direct()const 
{ return (vxdir.Crossed(vydir).Dot(axis.Direction()) > 0.); }

inline Standard_Boolean gp_Ax3::IsCoplanar
(const gp_Ax3& Other, 
 const Standard_Real LinearTolerance, 
 const Standard_Real AngularTolerance)const 
{
  gp_Vec vec(axis.Location(),Other.axis.Location());
  Standard_Real D1 = gp_Vec(axis.Direction()      ).Dot(vec);
  if (D1 < 0) D1 = - D1;
  Standard_Real D2 = gp_Vec(Other.axis.Direction()).Dot(vec);
  if (D2 < 0) D2 = - D2;
  return (D1 <= LinearTolerance && D2 <= LinearTolerance &&
          axis.IsParallel (Other.axis, AngularTolerance));
}

inline Standard_Boolean gp_Ax3::IsCoplanar
(const gp_Ax1& A1, 
 const Standard_Real LinearTolerance, 
 const Standard_Real AngularTolerance)const 
{
  gp_Vec vec(axis.Location(),A1.Location());
  Standard_Real D1 = gp_Vec(axis.Direction()).Dot(vec);
  if (D1 < 0) D1 = - D1;
  Standard_Real D2 = (gp_Vec(A1.Direction()).Crossed(vec)).Magnitude();
  if (D2 < 0) D2 = - D2;
  return (D1 <= LinearTolerance && D2 <= LinearTolerance &&
          axis.IsNormal (A1, AngularTolerance));
}

inline void  gp_Ax3::Rotate(const gp_Ax1& A1,
			    const Standard_Real Ang)
{
  axis.Rotate (A1,Ang);
  vxdir.Rotate (A1,Ang);
  vydir.Rotate (A1,Ang);
}

inline gp_Ax3  gp_Ax3::Rotated(const gp_Ax1& A1,
			       const Standard_Real Ang)const
{
  gp_Ax3 Temp = *this;
  Temp.Rotate (A1,Ang);
  return Temp;
}

inline void  gp_Ax3::Scale(const gp_Pnt& P, const Standard_Real S)
{
  axis.Scale (P,S);
  if (S < 0.) {
    vxdir.Reverse ();
    vydir.Reverse ();
  }
}

inline gp_Ax3  gp_Ax3::Scaled(const gp_Pnt& P,
			      const Standard_Real S)const
{
  gp_Ax3 Temp = *this;
  Temp.Scale (P,S);
  return Temp;
}

inline void  gp_Ax3::Transform(const gp_Trsf& T)
{
  axis.Transform (T);
  vxdir.Transform (T);
  vydir.Transform (T);
}

inline gp_Ax3  gp_Ax3::Transformed(const gp_Trsf& T)const
{
  gp_Ax3 Temp = *this;
  Temp.Transform (T);
  return Temp;
}

inline void  gp_Ax3::Translate(const gp_Vec& V)
{ axis.Translate (V); }

inline gp_Ax3  gp_Ax3::Translated(const gp_Vec& V)const
{
  gp_Ax3 Temp = *this;
  Temp.Translate (V);
  return Temp;
}

inline void  gp_Ax3::Translate(const gp_Pnt& P1, const gp_Pnt& P2)
{ Translate(gp_Vec(P1,P2)); }

inline gp_Ax3  gp_Ax3::Translated(const gp_Pnt& P1, const gp_Pnt& P2)const
{ return Translated(gp_Vec(P1,P2)); }