0032137: Coding Rules - merge redundant .lxx files into header files within Package gp
[occt.git] / src / gp / gp_Lin.lxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 // JCV 30/08/90 Modif passage version C++ 2.0 sur Sun
16
17 inline gp_Lin::gp_Lin ()
18 { }
19
20 inline gp_Lin::gp_Lin (const gp_Ax1& A1) : pos (A1)
21 { }
22
23 inline gp_Lin::gp_Lin (const gp_Pnt& P,
24                        const gp_Dir& V) : pos (P, V)
25 { }
26
27 inline void gp_Lin::Reverse()
28 { pos.Reverse(); }
29
30 inline gp_Lin gp_Lin::Reversed() const { 
31   gp_Lin L = *this;
32   L.pos.Reverse();
33   return L;
34 }
35
36 inline void gp_Lin::SetDirection (const gp_Dir& V)
37 { pos.SetDirection(V); }
38
39 inline void gp_Lin::SetLocation (const gp_Pnt& P)
40 { pos.SetLocation(P); }
41
42 inline void gp_Lin::SetPosition (const gp_Ax1& A1)
43 { pos = A1; }
44
45 inline const gp_Dir& gp_Lin::Direction() const
46 { return pos.Direction(); }
47
48 inline const gp_Pnt& gp_Lin::Location()  const
49 { return pos.Location(); }
50
51 inline    const gp_Ax1& gp_Lin::Position() const
52 { return pos; }
53
54 inline Standard_Real gp_Lin::Angle (const gp_Lin& Other) const
55 { return pos.Direction().Angle (Other.pos.Direction()); }
56
57 inline Standard_Boolean gp_Lin::Contains
58 (const gp_Pnt& P,
59  const Standard_Real LinearTolerance) const
60 { return Distance(P) <= LinearTolerance; }
61
62 inline Standard_Real gp_Lin::Distance (const gp_Pnt& P) const {
63   gp_XYZ Coord = P.XYZ();
64   Coord.Subtract ((pos.Location()).XYZ());
65   Coord.Cross ((pos.Direction()).XYZ());
66   return Coord.Modulus();
67 }
68
69 inline Standard_Real gp_Lin::SquareDistance (const gp_Pnt& P) const
70 {
71   const gp_Pnt& Loc = pos.Location();
72   gp_Vec V (P.X() - Loc.X(),
73             P.Y() - Loc.Y(),
74             P.Z() - Loc.Z());
75   V.Cross (pos.Direction());
76   return V.SquareMagnitude ();                                          
77 }
78
79 inline Standard_Real gp_Lin::SquareDistance (const gp_Lin& Other) const
80 {
81   Standard_Real D = Distance (Other);
82   return D * D;
83 }
84
85 inline gp_Lin gp_Lin::Normal (const gp_Pnt& P) const
86 {
87   const gp_Pnt& Loc = pos.Location();
88   gp_Dir V (P.X() - Loc.X(),
89             P.Y() - Loc.Y(),
90             P.Z() - Loc.Z());
91   V = pos.Direction().CrossCrossed(V, pos.Direction());
92   return gp_Lin (P, V);
93 }
94
95 inline void gp_Lin::Rotate (const gp_Ax1& A1,
96                             const Standard_Real Ang)
97 { pos.Rotate(A1, Ang); }
98
99 inline gp_Lin gp_Lin::Rotated (const gp_Ax1& A1,
100                                const Standard_Real Ang) const
101 {
102   gp_Lin L = *this;
103   L.pos.Rotate (A1, Ang);
104   return L;
105 }
106
107 inline void gp_Lin::Scale (const gp_Pnt& P,
108                            const Standard_Real S)
109 { pos.Scale(P, S); }
110
111 inline gp_Lin gp_Lin::Scaled (const gp_Pnt& P,
112                               const Standard_Real S) const
113 {
114   gp_Lin L = *this;
115   L.pos.Scale (P, S);
116   return L;
117 }
118
119 inline void gp_Lin::Transform (const gp_Trsf& T)
120 { pos.Transform(T); }
121
122 inline gp_Lin gp_Lin::Transformed (const gp_Trsf& T) const
123 {
124   gp_Lin L = *this;
125   L.pos.Transform (T);
126   return L;
127 }
128
129 inline void gp_Lin::Translate (const gp_Vec& V)
130 { pos.Translate(V); }
131
132 inline gp_Lin gp_Lin::Translated (const gp_Vec& V) const
133 {
134   gp_Lin L = *this;
135   L.pos.Translate (V); 
136   return L;
137 }
138
139 inline void gp_Lin::Translate (const gp_Pnt& P1,
140                                const gp_Pnt& P2)
141 {pos.Translate (P1, P2);}
142
143 inline gp_Lin gp_Lin::Translated (const gp_Pnt& P1,
144                                   const gp_Pnt& P2) const
145 {
146   gp_Lin L = *this;
147   L.pos.Translate (gp_Vec(P1, P2));
148   return L;
149 }
150