1 // Created on: 1993-03-10
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Geom_Direction.ixx>
19 #include <Standard_ConstructionError.hxx>
21 typedef Geom_Direction Direction;
22 typedef Geom_Vector Vector;
30 //=======================================================================
33 //=======================================================================
35 Handle(Geom_Geometry) Geom_Direction::Copy() const {
37 Handle(Geom_Direction) D;
38 D = new Direction (gpVec);
42 //=======================================================================
43 //function : Geom_Direction
45 //=======================================================================
47 Geom_Direction::Geom_Direction (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
49 Standard_Real D = sqrt (X * X + Y * Y + Z * Z);
50 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
51 gpVec = gp_Vec (X/D, Y/D, Z/D);
54 Geom_Direction::Geom_Direction (const gp_Dir& V) { gpVec = V; }
56 void Geom_Direction::SetDir (const gp_Dir& V) { gpVec = V; }
58 gp_Dir Geom_Direction::Dir () const { return gpVec; }
60 Standard_Real Geom_Direction::Magnitude () const { return 1.0; }
62 Standard_Real Geom_Direction::SquareMagnitude () const { return 1.0; }
64 void Geom_Direction::SetCoord (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) {
66 Standard_Real D = Sqrt (X * X + Y * Y + Z * Z);
67 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
68 gpVec = gp_Vec(X/D, Y/D, Z/D);
72 void Geom_Direction::SetX (const Standard_Real X) {
74 Standard_Real D = Sqrt (X * X + gpVec.Y() * gpVec.Y() + gpVec.Z() * gpVec.Z());
75 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
76 gpVec = gp_Vec (X/D, gpVec.Y()/D, gpVec.Z()/D);
80 void Geom_Direction::SetY (const Standard_Real Y) {
82 Standard_Real D = Sqrt (gpVec.X() * gpVec.X() + Y * Y + gpVec.Z() * gpVec.Z());
83 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
84 gpVec = gp_Vec (gpVec.X()/D, Y/D, gpVec.Z()/D);
88 void Geom_Direction::SetZ (const Standard_Real Z) {
90 Standard_Real D = Sqrt (gpVec.X() * gpVec.X() + gpVec.Y() * gpVec.Y() + Z * Z);
91 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
92 gpVec = gp_Vec (gpVec.X()/D, gpVec.Y()/D, Z/D);
96 void Geom_Direction::Cross (const Handle(Geom_Vector)& Other) {
98 gp_Dir V (gpVec.Crossed(Other->Vec()));
103 void Geom_Direction::CrossCross (
104 const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) {
106 gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec()));
111 Handle(Geom_Vector) Geom_Direction::Crossed (const Handle(Geom_Vector)& Other)
114 gp_Dir V (gpVec.Crossed (Other->Vec()));
115 return new Direction (V);
119 Handle(Geom_Vector) Geom_Direction::CrossCrossed (
120 const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const {
122 gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec()));
123 return new Direction (V);
127 void Geom_Direction::Transform (const gp_Trsf& T) {