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_Ax2d_HeaderFile
16 #define _gp_Ax2d_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 <Standard_Real.hxx>
33 //! Describes an axis in the plane (2D space).
34 //! An axis is defined by:
35 //! - its origin (also referred to as its "Location point"), and
36 //! - its unit vector (referred to as its "Direction").
37 //! An axis implicitly defines a direct, right-handed
38 //! coordinate system in 2D space by:
40 //! - its "Direction" (giving the "X Direction" of the coordinate system), and
41 //! - the unit vector normal to "Direction" (positive angle
42 //! measured in the trigonometric sense).
44 //! - to describe 2D geometric entities (for example, the
45 //! axis which defines angular coordinates on a circle).
46 //! It serves for the same purpose as the STEP function
47 //! "axis placement one axis", or
48 //! - to define geometric transformations (axis of
49 //! symmetry, axis of rotation, and so on).
50 //! Note: to define a left-handed 2D coordinate system, use gp_Ax22d.
58 //! Creates an axis object representing X axis of
59 //! the reference coordinate system.
63 //! Creates an Ax2d. <P> is the "Location" point of
64 //! the axis placement and V is the "Direction" of
65 //! the axis placement.
66 gp_Ax2d(const gp_Pnt2d& P, const gp_Dir2d& V);
68 //! Changes the "Location" point (origin) of <me>.
69 void SetLocation (const gp_Pnt2d& Locat);
71 //! Changes the direction of <me>.
72 void SetDirection (const gp_Dir2d& V);
74 //! Returns the origin of <me>.
75 const gp_Pnt2d& Location() const;
77 //! Returns the direction of <me>.
78 const gp_Dir2d& Direction() const;
82 //! . the angle between <me> and <Other> is lower or equal
83 //! to <AngularTolerance> and
84 //! . the distance between <me>.Location() and <Other> is lower
85 //! or equal to <LinearTolerance> and
86 //! . the distance between <Other>.Location() and <me> is lower
87 //! or equal to LinearTolerance.
88 Standard_EXPORT Standard_Boolean IsCoaxial (const gp_Ax2d& Other, const Standard_Real AngularTolerance, const Standard_Real LinearTolerance) const;
90 //! Returns true if this axis and the axis Other are normal to
91 //! each other. That is, if the angle between the two axes is equal to Pi/2 or -Pi/2.
92 //! Note: the tolerance criterion is given by AngularTolerance.
93 Standard_Boolean IsNormal (const gp_Ax2d& Other, const Standard_Real AngularTolerance) const;
95 //! Returns true if this axis and the axis Other are parallel,
96 //! and have opposite orientations. That is, if the angle
97 //! between the two axes is equal to Pi or -Pi.
98 //! Note: the tolerance criterion is given by AngularTolerance.
99 Standard_Boolean IsOpposite (const gp_Ax2d& Other, const Standard_Real AngularTolerance) const;
101 //! Returns true if this axis and the axis Other are parallel,
102 //! and have either the same or opposite orientations. That
103 //! is, if the angle between the two axes is equal to 0, Pi or -Pi.
104 //! Note: the tolerance criterion is given by AngularTolerance.
105 Standard_Boolean IsParallel (const gp_Ax2d& Other, const Standard_Real AngularTolerance) const;
108 //! Computes the angle, in radians, between this axis and
109 //! the axis Other. The value of the angle is between -Pi and Pi.
110 Standard_Real Angle (const gp_Ax2d& Other) const;
112 //! Reverses the direction of <me> and assigns the result to this axis.
116 //! Computes a new axis placement with a direction opposite to
117 //! the direction of <me>.
118 Standard_NODISCARD gp_Ax2d Reversed() const;
120 Standard_EXPORT void Mirror (const gp_Pnt2d& P);
123 //! Performs the symmetrical transformation of an axis
124 //! placement with respect to the point P which is the
125 //! center of the symmetry.
126 Standard_NODISCARD Standard_EXPORT gp_Ax2d Mirrored (const gp_Pnt2d& P) const;
128 Standard_EXPORT void Mirror (const gp_Ax2d& A);
131 //! Performs the symmetrical transformation of an axis
132 //! placement with respect to an axis placement which
133 //! is the axis of the symmetry.
134 Standard_NODISCARD Standard_EXPORT gp_Ax2d Mirrored (const gp_Ax2d& A) const;
136 void Rotate (const gp_Pnt2d& P, const Standard_Real Ang);
139 //! Rotates an axis placement. <P> is the center of the
140 //! rotation . Ang is the angular value of the rotation
142 Standard_NODISCARD gp_Ax2d Rotated (const gp_Pnt2d& P, const Standard_Real Ang) const;
144 Standard_EXPORT void Scale (const gp_Pnt2d& P, const Standard_Real S);
147 //! Applies a scaling transformation on the axis placement.
148 //! The "Location" point of the axisplacement is modified.
149 //! The "Direction" is reversed if the scale is negative.
150 Standard_NODISCARD gp_Ax2d Scaled (const gp_Pnt2d& P, const Standard_Real S) const;
152 void Transform (const gp_Trsf2d& T);
154 //! Transforms an axis placement with a Trsf.
155 Standard_NODISCARD gp_Ax2d Transformed (const gp_Trsf2d& T) const;
157 void Translate (const gp_Vec2d& V);
160 //! Translates an axis placement in the direction of the vector
161 //! <V>. The magnitude of the translation is the vector's magnitude.
162 Standard_NODISCARD gp_Ax2d Translated (const gp_Vec2d& V) const;
164 void Translate (const gp_Pnt2d& P1, const gp_Pnt2d& P2);
167 //! Translates an axis placement from the point <P1> to the
169 Standard_NODISCARD gp_Ax2d Translated (const gp_Pnt2d& P1, const gp_Pnt2d& P2) const;
171 //! Dumps the content of me into the stream
172 Standard_EXPORT void DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth = -1) const;
194 #include <gp_Ax2d.lxx>
200 #endif // _gp_Ax2d_HeaderFile