1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <Geom2d_Direction.ixx>
25 #include <Standard_ConstructionError.hxx>
27 typedef Geom2d_Direction Direction;
28 typedef Handle(Geom2d_Direction) Handle(Direction);
29 typedef Handle(Geom2d_Vector) Handle(Vector);
31 typedef gp_Pnt2d Pnt2d;
32 typedef gp_Trsf2d Trsf2d;
38 Handle(Geom2d_Geometry) Geom2d_Direction::Copy() const {
41 D = new Direction (gpVec2d);
50 Geom2d_Direction::Geom2d_Direction (const Standard_Real X, const Standard_Real Y) {
52 Standard_Real D = Sqrt (X * X + Y * Y);
53 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
54 gpVec2d = gp_Vec2d (X/D, Y/D);
58 Geom2d_Direction::Geom2d_Direction (const gp_Dir2d& V) { gpVec2d = V; }
61 void Geom2d_Direction::SetCoord (const Standard_Real X, const Standard_Real Y) {
63 Standard_Real D = Sqrt (X * X + Y * Y);
64 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
65 gpVec2d = gp_Vec2d (X/D, Y/D);
69 void Geom2d_Direction::SetDir2d (const gp_Dir2d& V) { gpVec2d = V; }
72 void Geom2d_Direction::SetX (const Standard_Real X) {
74 Standard_Real D = Sqrt(X * X + gpVec2d.Y() * gpVec2d.Y());
75 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
76 gpVec2d = gp_Vec2d (X/D, gpVec2d.Y()/D);
80 void Geom2d_Direction::SetY (const Standard_Real Y) {
82 Standard_Real D = Sqrt (gpVec2d.X() * gpVec2d.X() + Y * Y);
83 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
84 gpVec2d = gp_Vec2d (gpVec2d.X()/D, Y/D);
88 gp_Dir2d Geom2d_Direction::Dir2d () const { return gpVec2d; }
91 Standard_Real Geom2d_Direction::Magnitude () const { return 1.0; }
94 Standard_Real Geom2d_Direction::SquareMagnitude () const { return 1.0; }
97 Standard_Real Geom2d_Direction::Crossed (const Handle(Vector)& Other) const {
99 return gpVec2d.Crossed (Other->Vec2d());
103 void Geom2d_Direction::Transform (const gp_Trsf2d& T) {
105 gp_Dir2d dir = gpVec2d;