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_Lin2d_HeaderFile
16 #define _gp_Lin2d_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
22 #include <gp_Ax2d.hxx>
23 #include <Standard_Real.hxx>
24 #include <Standard_Boolean.hxx>
25 class Standard_ConstructionError;
33 //! Describes a line in 2D space.
34 //! A line is positioned in the plane with an axis (a gp_Ax2d
35 //! object) which gives the line its origin and unit vector. A
36 //! line and an axis are similar objects, thus, we can convert
37 //! one into the other.
38 //! A line provides direct access to the majority of the edit
39 //! and query functions available on its positioning axis. In
40 //! addition, however, a line has specific functions for
41 //! computing distances and positions.
43 //! GccAna and Geom2dGcc packages which provide
44 //! functions for constructing lines defined by geometric
46 //! gce_MakeLin2d which provides functions for more
47 //! complex line constructions
48 //! Geom2d_Line which provides additional functions for
49 //! constructing lines and works, in particular, with the
50 //! parametric equations of lines
58 //! Creates a Line corresponding to X axis of the
59 //! reference coordinate system.
62 //! Creates a line located with A.
63 gp_Lin2d(const gp_Ax2d& A);
66 //! <P> is the location point (origin) of the line and
67 //! <V> is the direction of the line.
68 gp_Lin2d(const gp_Pnt2d& P, const gp_Dir2d& V);
71 //! Creates the line from the equation A*X + B*Y + C = 0.0 Raises ConstructionError if Sqrt(A*A + B*B) <= Resolution from gp.
72 //! Raised if Sqrt(A*A + B*B) <= Resolution from gp.
73 Standard_EXPORT gp_Lin2d(const Standard_Real A, const Standard_Real B, const Standard_Real C);
78 //! Reverses the positioning axis of this line.
80 //! - Reverse assigns the result to this line, while
81 //! - Reversed creates a new one.
82 gp_Lin2d Reversed() const;
84 //! Changes the direction of the line.
85 void SetDirection (const gp_Dir2d& V);
87 //! Changes the origin of the line.
88 void SetLocation (const gp_Pnt2d& P);
91 //! Complete redefinition of the line.
92 //! The "Location" point of <A> is the origin of the line.
93 //! The "Direction" of <A> is the direction of the line.
94 void SetPosition (const gp_Ax2d& A);
97 //! Returns the normalized coefficients of the line :
98 //! A * X + B * Y + C = 0.
99 void Coefficients (Standard_Real& A, Standard_Real& B, Standard_Real& C) const;
101 //! Returns the direction of the line.
102 const gp_Dir2d& Direction() const;
104 //! Returns the location point (origin) of the line.
105 const gp_Pnt2d& Location() const;
108 //! Returns the axis placement one axis whith the same
109 //! location and direction as <me>.
110 const gp_Ax2d& Position() const;
112 //! Computes the angle between two lines in radians.
113 Standard_Real Angle (const gp_Lin2d& Other) const;
115 //! Returns true if this line contains the point P, that is, if the
116 //! distance between point P and this line is less than or
117 //! equal to LinearTolerance.
118 Standard_Boolean Contains (const gp_Pnt2d& P, const Standard_Real LinearTolerance) const;
121 //! Computes the distance between <me> and the point <P>.
122 Standard_Real Distance (const gp_Pnt2d& P) const;
124 //! Computes the distance between two lines.
125 Standard_Real Distance (const gp_Lin2d& Other) const;
128 //! Computes the square distance between <me> and the point
130 Standard_Real SquareDistance (const gp_Pnt2d& P) const;
132 //! Computes the square distance between two lines.
133 Standard_Real SquareDistance (const gp_Lin2d& Other) const;
136 //! Computes the line normal to the direction of <me>,
137 //! passing through the point <P>.
138 gp_Lin2d Normal (const gp_Pnt2d& P) const;
140 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
143 //! Performs the symmetrical transformation of a line
144 //! with respect to the point <P> which is the center
146 Standard_EXPORT gp_Lin2d Mirrored (const gp_Pnt2d& P) const;
148 Standard_EXPORT void Mirror (const gp_Ax2d& A);
151 //! Performs the symmetrical transformation of a line
152 //! with respect to an axis placement which is the axis
154 Standard_EXPORT gp_Lin2d Mirrored (const gp_Ax2d& A) const;
156 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
159 //! Rotates a line. P is the center of the rotation.
160 //! Ang is the angular value of the rotation in radians.
161 gp_Lin2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
163 void Scale (const gp_Pnt2d& P, const Standard_Real S);
166 //! Scales a line. S is the scaling value. Only the
167 //! origin of the line is modified.
168 gp_Lin2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
170 void Transform (const gp_Trsf2d& T);
173 //! Transforms a line with the transformation T from class Trsf2d.
174 gp_Lin2d Transformed (const gp_Trsf2d& T) const;
176 void Translate (const gp_Vec2d& V);
179 //! Translates a line in the direction of the vector V.
180 //! The magnitude of the translation is the vector's magnitude.
181 gp_Lin2d Translated (const gp_Vec2d& V) const;
183 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
186 //! Translates a line from the point P1 to the point P2.
187 gp_Lin2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
208 #include <gp_Lin2d.lxx>
214 #endif // _gp_Lin2d_HeaderFile