1 // Copyright (c) 1991-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 #ifndef _gp_Lin_HeaderFile
16 #define _gp_Lin_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Boolean.hxx>
25 class Standard_ConstructionError;
35 //! Describes a line in 3D space.
36 //! A line is positioned in space with an axis (a gp_Ax1
37 //! object) which gives it an origin and a unit vector.
38 //! A line and an axis are similar objects, thus, we can
39 //! convert one into the other. A line provides direct access
40 //! to the majority of the edit and query functions available
41 //! on its positioning axis. In addition, however, a line has
42 //! specific functions for computing distances and positions.
44 //! gce_MakeLin which provides functions for more complex
45 //! line constructions
46 //! Geom_Line which provides additional functions for
47 //! constructing lines and works, in particular, with the
48 //! parametric equations of lines
56 //! Creates a Line corresponding to Z axis of the
57 //! reference coordinate system.
60 //! Creates a line defined by axis A1.
61 gp_Lin(const gp_Ax1& A1);
63 //! Creates a line passing through point P and parallel to
64 //! vector V (P and V are, respectively, the origin and
65 //! the unit vector of the positioning axis of the line).
66 gp_Lin(const gp_Pnt& P, const gp_Dir& V);
70 //! Reverses the direction of the line.
72 //! - Reverse assigns the result to this line, while
73 //! - Reversed creates a new one.
74 Standard_NODISCARD gp_Lin Reversed() const;
76 //! Changes the direction of the line.
77 void SetDirection (const gp_Dir& V);
79 //! Changes the location point (origin) of the line.
80 void SetLocation (const gp_Pnt& P);
83 //! Complete redefinition of the line.
84 //! The "Location" point of <A1> is the origin of the line.
85 //! The "Direction" of <A1> is the direction of the line.
86 void SetPosition (const gp_Ax1& A1);
88 //! Returns the direction of the line.
89 const gp_Dir& Direction() const;
92 //! Returns the location point (origin) of the line.
93 const gp_Pnt& Location() const;
96 //! Returns the axis placement one axis whith the same
97 //! location and direction as <me>.
98 const gp_Ax1& Position() const;
100 //! Computes the angle between two lines in radians.
101 Standard_Real Angle (const gp_Lin& Other) const;
103 //! Returns true if this line contains the point P, that is, if the
104 //! distance between point P and this line is less than or
105 //! equal to LinearTolerance..
106 Standard_Boolean Contains (const gp_Pnt& P, const Standard_Real LinearTolerance) const;
108 //! Computes the distance between <me> and the point P.
109 Standard_Real Distance (const gp_Pnt& P) const;
111 //! Computes the distance between two lines.
112 Standard_EXPORT Standard_Real Distance (const gp_Lin& Other) const;
115 //! Computes the square distance between <me> and the point P.
116 Standard_Real SquareDistance (const gp_Pnt& P) const;
118 //! Computes the square distance between two lines.
119 Standard_Real SquareDistance (const gp_Lin& Other) const;
122 //! Computes the line normal to the direction of <me>, passing
123 //! through the point P. Raises ConstructionError
124 //! if the distance between <me> and the point P is lower
125 //! or equal to Resolution from gp because there is an infinity of
126 //! solutions in 3D space.
127 gp_Lin Normal (const gp_Pnt& P) const;
129 Standard_EXPORT void Mirror (const gp_Pnt& P);
132 //! Performs the symmetrical transformation of a line
133 //! with respect to the point P which is the center of
135 Standard_EXPORT Standard_NODISCARD gp_Lin Mirrored (const gp_Pnt& P) const;
137 Standard_EXPORT void Mirror (const gp_Ax1& A1);
140 //! Performs the symmetrical transformation of a line
141 //! with respect to an axis placement which is the axis
143 Standard_EXPORT Standard_NODISCARD gp_Lin Mirrored (const gp_Ax1& A1) const;
145 Standard_EXPORT void Mirror (const gp_Ax2& A2);
148 //! Performs the symmetrical transformation of a line
149 //! with respect to a plane. The axis placement <A2>
150 //! locates the plane of the symmetry :
151 //! (Location, XDirection, YDirection).
152 Standard_EXPORT Standard_NODISCARD gp_Lin Mirrored (const gp_Ax2& A2) const;
154 void Rotate (const gp_Ax1& A1, const Standard_Real Ang);
157 //! Rotates a line. A1 is the axis of the rotation.
158 //! Ang is the angular value of the rotation in radians.
159 Standard_NODISCARD gp_Lin Rotated (const gp_Ax1& A1, const Standard_Real Ang) const;
161 void Scale (const gp_Pnt& P, const Standard_Real S);
164 //! Scales a line. S is the scaling value.
165 //! The "Location" point (origin) of the line is modified.
166 //! The "Direction" is reversed if the scale is negative.
167 Standard_NODISCARD gp_Lin Scaled (const gp_Pnt& P, const Standard_Real S) const;
169 void Transform (const gp_Trsf& T);
172 //! Transforms a line with the transformation T from class Trsf.
173 Standard_NODISCARD gp_Lin Transformed (const gp_Trsf& T) const;
175 void Translate (const gp_Vec& V);
178 //! Translates a line in the direction of the vector V.
179 //! The magnitude of the translation is the vector's magnitude.
180 Standard_NODISCARD gp_Lin Translated (const gp_Vec& V) const;
182 void Translate (const gp_Pnt& P1, const gp_Pnt& P2);
185 //! Translates a line from the point P1 to the point P2.
186 Standard_NODISCARD gp_Lin Translated (const gp_Pnt& P1, const gp_Pnt& P2) const;
207 #include <gp_Lin.lxx>
213 #endif // _gp_Lin_HeaderFile