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_Ax22d_HeaderFile
16 #define _gp_Ax22d_HeaderFile
18 #include <Standard.hxx>
19 #include <Standard_DefineAlloc.hxx>
20 #include <Standard_Handle.hxx>
22 #include <gp_Pnt2d.hxx>
23 #include <gp_Dir2d.hxx>
24 #include <Standard_Boolean.hxx>
25 #include <gp_Ax2d.hxx>
26 #include <Standard_Real.hxx>
27 class Standard_ConstructionError;
36 //! Describes a coordinate system in a plane (2D space).
37 //! A coordinate system is defined by:
38 //! - its origin (also referred to as its "Location point"), and
39 //! - two orthogonal unit vectors, respectively, called the "X
40 //! Direction" and the "Y Direction".
41 //! A gp_Ax22d may be right-handed ("direct sense") or
42 //! left-handed ("inverse" or "indirect sense").
43 //! You use a gp_Ax22d to:
44 //! - describe 2D geometric entities, in particular to position
45 //! them. The local coordinate system of a geometric
46 //! entity serves for the same purpose as the STEP
47 //! function "axis placement two axes", or
48 //! - define geometric transformations.
49 //! Note: we refer to the "X Axis" and "Y Axis" as the axes having:
50 //! - the origin of the coordinate system as their origin, and
51 //! - the unit vectors "X Direction" and "Y Direction",
52 //! respectively, as their unit vectors.
60 //! Creates an object representing the reference
61 //! co-ordinate system (OXY).
65 //! Creates a coordinate system with origin P and where:
66 //! - Vx is the "X Direction", and
67 //! - the "Y Direction" is orthogonal to Vx and
68 //! oriented so that the cross products Vx^"Y
69 //! Direction" and Vx^Vy have the same sign.
70 //! Raises ConstructionError if Vx and Vy are parallel (same or opposite orientation).
71 gp_Ax22d(const gp_Pnt2d& P, const gp_Dir2d& Vx, const gp_Dir2d& Vy);
74 //! Creates - a coordinate system with origin P and "X Direction"
76 //! - right-handed if Sense is true (default value), or
77 //! - left-handed if Sense is false
78 gp_Ax22d(const gp_Pnt2d& P, const gp_Dir2d& V, const Standard_Boolean Sense = Standard_True);
81 //! Creates - a coordinate system where its origin is the origin of
82 //! A and its "X Direction" is the unit vector of A, which is:
83 //! - right-handed if Sense is true (default value), or
84 //! - left-handed if Sense is false.
85 gp_Ax22d(const gp_Ax2d& A, const Standard_Boolean Sense = Standard_True);
88 //! Assigns the origin and the two unit vectors of the
89 //! coordinate system A1 to this coordinate system.
90 void SetAxis (const gp_Ax22d& A1);
93 //! Changes the XAxis and YAxis ("Location" point and "Direction")
95 //! The "YDirection" is recomputed in the same sense as before.
96 void SetXAxis (const gp_Ax2d& A1);
98 //! Changes the XAxis and YAxis ("Location" point and "Direction") of <me>.
99 //! The "XDirection" is recomputed in the same sense as before.
100 void SetYAxis (const gp_Ax2d& A1);
103 //! Changes the "Location" point (origin) of <me>.
104 void SetLocation (const gp_Pnt2d& P);
107 //! Assigns Vx to the "X Direction" of
108 //! this coordinate system. The other unit vector of this
109 //! coordinate system is recomputed, normal to Vx ,
110 //! without modifying the orientation (right-handed or
111 //! left-handed) of this coordinate system.
112 void SetXDirection (const gp_Dir2d& Vx);
114 //! Assignsr Vy to the "Y Direction" of
115 //! this coordinate system. The other unit vector of this
116 //! coordinate system is recomputed, normal to Vy,
117 //! without modifying the orientation (right-handed or
118 //! left-handed) of this coordinate system.
119 void SetYDirection (const gp_Dir2d& Vy);
121 //! Returns an axis, for which
122 //! - the origin is that of this coordinate system, and
123 //! - the unit vector is either the "X Direction" of this coordinate system.
124 //! Note: the result is the "X Axis" of this coordinate system.
125 gp_Ax2d XAxis() const;
127 //! Returns an axis, for which
128 //! - the origin is that of this coordinate system, and
129 //! - the unit vector is either the "Y Direction" of this coordinate system.
130 //! Note: the result is the "Y Axis" of this coordinate system.
131 gp_Ax2d YAxis() const;
134 //! Returns the "Location" point (origin) of <me>.
135 const gp_Pnt2d& Location() const;
138 //! Returns the "XDirection" of <me>.
139 const gp_Dir2d& XDirection() const;
142 //! Returns the "YDirection" of <me>.
143 const gp_Dir2d& YDirection() const;
145 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
148 //! Performs the symmetrical transformation of an axis
149 //! placement with respect to the point P which is the
150 //! center of the symmetry.
152 //! The main direction of the axis placement is not changed.
153 //! The "XDirection" and the "YDirection" are reversed.
154 //! So the axis placement stay right handed.
155 Standard_EXPORT Standard_NODISCARD gp_Ax22d Mirrored (const gp_Pnt2d& P) const;
157 Standard_EXPORT void Mirror (const gp_Ax2d& A);
160 //! Performs the symmetrical transformation of an axis
161 //! placement with respect to an axis placement which
162 //! is the axis of the symmetry.
163 //! The transformation is performed on the "Location"
164 //! point, on the "XDirection" and "YDirection".
165 //! The resulting main "Direction" is the cross product between
166 //! the "XDirection" and the "YDirection" after transformation.
167 Standard_EXPORT Standard_NODISCARD gp_Ax22d Mirrored (const gp_Ax2d& A) const;
169 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
172 //! Rotates an axis placement. <A1> is the axis of the
173 //! rotation . Ang is the angular value of the rotation
175 Standard_NODISCARD gp_Ax22d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
177 void Scale (const gp_Pnt2d& P, const Standard_Real S);
180 //! Applies a scaling transformation on the axis placement.
181 //! The "Location" point of the axisplacement is modified.
183 //! If the scale <S> is negative :
184 //! . the main direction of the axis placement is not changed.
185 //! . The "XDirection" and the "YDirection" are reversed.
186 //! So the axis placement stay right handed.
187 Standard_NODISCARD gp_Ax22d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
189 void Transform (const gp_Trsf2d& T);
192 //! Transforms an axis placement with a Trsf.
193 //! The "Location" point, the "XDirection" and the
194 //! "YDirection" are transformed with T. The resulting
195 //! main "Direction" of <me> is the cross product between
196 //! the "XDirection" and the "YDirection" after transformation.
197 Standard_NODISCARD gp_Ax22d Transformed (const gp_Trsf2d& T) const;
199 void Translate (const gp_Vec2d& V);
202 //! Translates an axis plaxement in the direction of the vector
203 //! <V>. The magnitude of the translation is the vector's magnitude.
204 Standard_NODISCARD gp_Ax22d Translated (const gp_Vec2d& V) const;
206 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
209 //! Translates an axis placement from the point <P1> to the
211 Standard_NODISCARD gp_Ax22d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
234 #include <gp_Ax22d.lxx>
240 #endif // _gp_Ax22d_HeaderFile