1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // JCV 30/08/90 Modif passage version C++ 2.0 sur Sun
17 inline gp_Lin::gp_Lin ()
20 inline gp_Lin::gp_Lin (const gp_Ax1& A1) : pos (A1)
23 inline gp_Lin::gp_Lin (const gp_Pnt& P,
24 const gp_Dir& V) : pos (P, V)
27 inline void gp_Lin::Reverse()
30 inline gp_Lin gp_Lin::Reversed() const {
36 inline void gp_Lin::SetDirection (const gp_Dir& V)
37 { pos.SetDirection(V); }
39 inline void gp_Lin::SetLocation (const gp_Pnt& P)
40 { pos.SetLocation(P); }
42 inline void gp_Lin::SetPosition (const gp_Ax1& A1)
45 inline const gp_Dir& gp_Lin::Direction() const
46 { return pos.Direction(); }
48 inline const gp_Pnt& gp_Lin::Location() const
49 { return pos.Location(); }
51 inline const gp_Ax1& gp_Lin::Position() const
54 inline Standard_Real gp_Lin::Angle (const gp_Lin& Other) const
55 { return pos.Direction().Angle (Other.pos.Direction()); }
57 inline Standard_Boolean gp_Lin::Contains
59 const Standard_Real LinearTolerance) const
60 { return Distance(P) <= LinearTolerance; }
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();
69 inline Standard_Real gp_Lin::SquareDistance (const gp_Pnt& P) const
71 const gp_Pnt& Loc = pos.Location();
72 gp_Vec V (P.X() - Loc.X(),
75 V.Cross (pos.Direction());
76 return V.SquareMagnitude ();
79 inline Standard_Real gp_Lin::SquareDistance (const gp_Lin& Other) const
81 Standard_Real D = Distance (Other);
85 inline gp_Lin gp_Lin::Normal (const gp_Pnt& P) const
87 const gp_Pnt& Loc = pos.Location();
88 gp_Dir V (P.X() - Loc.X(),
91 V = pos.Direction().CrossCrossed(V, pos.Direction());
95 inline void gp_Lin::Rotate (const gp_Ax1& A1,
96 const Standard_Real Ang)
97 { pos.Rotate(A1, Ang); }
99 inline gp_Lin gp_Lin::Rotated (const gp_Ax1& A1,
100 const Standard_Real Ang) const
103 L.pos.Rotate (A1, Ang);
107 inline void gp_Lin::Scale (const gp_Pnt& P,
108 const Standard_Real S)
111 inline gp_Lin gp_Lin::Scaled (const gp_Pnt& P,
112 const Standard_Real S) const
119 inline void gp_Lin::Transform (const gp_Trsf& T)
120 { pos.Transform(T); }
122 inline gp_Lin gp_Lin::Transformed (const gp_Trsf& T) const
129 inline void gp_Lin::Translate (const gp_Vec& V)
130 { pos.Translate(V); }
132 inline gp_Lin gp_Lin::Translated (const gp_Vec& V) const
139 inline void gp_Lin::Translate (const gp_Pnt& P1,
141 {pos.Translate (P1, P2);}
143 inline gp_Lin gp_Lin::Translated (const gp_Pnt& P1,
144 const gp_Pnt& P2) const
147 L.pos.Translate (gp_Vec(P1, P2));