b311480e |
1 | // Created on: 1993-03-10 |
2 | // Created by: JCV |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <Geom_Direction.ixx> |
18 | #include <gp.hxx> |
19 | #include <Standard_ConstructionError.hxx> |
20 | |
21 | typedef Geom_Direction Direction; |
7fd59977 |
22 | typedef Geom_Vector Vector; |
7fd59977 |
23 | typedef gp_Ax1 Ax1; |
24 | typedef gp_Ax2 Ax2; |
25 | typedef gp_Pnt Pnt; |
26 | typedef gp_Trsf Trsf; |
27 | |
28 | |
29 | |
30 | //======================================================================= |
31 | //function : Copy |
32 | //purpose : |
33 | //======================================================================= |
34 | |
35 | Handle(Geom_Geometry) Geom_Direction::Copy() const { |
36 | |
c04c30b3 |
37 | Handle(Geom_Direction) D; |
7fd59977 |
38 | D = new Direction (gpVec); |
39 | return D; |
40 | } |
41 | |
42 | //======================================================================= |
43 | //function : Geom_Direction |
44 | //purpose : |
45 | //======================================================================= |
46 | |
47 | Geom_Direction::Geom_Direction (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { |
48 | |
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); |
52 | } |
53 | |
54 | Geom_Direction::Geom_Direction (const gp_Dir& V) { gpVec = V; } |
55 | |
56 | void Geom_Direction::SetDir (const gp_Dir& V) { gpVec = V; } |
57 | |
58 | gp_Dir Geom_Direction::Dir () const { return gpVec; } |
59 | |
60 | Standard_Real Geom_Direction::Magnitude () const { return 1.0; } |
61 | |
62 | Standard_Real Geom_Direction::SquareMagnitude () const { return 1.0; } |
63 | |
64 | void Geom_Direction::SetCoord (const Standard_Real X, const Standard_Real Y, const Standard_Real Z) { |
65 | |
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); |
69 | } |
70 | |
71 | |
72 | void Geom_Direction::SetX (const Standard_Real X) { |
73 | |
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); |
77 | } |
78 | |
79 | |
80 | void Geom_Direction::SetY (const Standard_Real Y) { |
81 | |
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); |
85 | } |
86 | |
87 | |
88 | void Geom_Direction::SetZ (const Standard_Real Z) { |
89 | |
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); |
93 | } |
94 | |
95 | |
c04c30b3 |
96 | void Geom_Direction::Cross (const Handle(Geom_Vector)& Other) { |
7fd59977 |
97 | |
98 | gp_Dir V (gpVec.Crossed(Other->Vec())); |
99 | gpVec = V; |
100 | } |
101 | |
102 | |
103 | void Geom_Direction::CrossCross ( |
c04c30b3 |
104 | const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) { |
7fd59977 |
105 | |
106 | gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec())); |
107 | gpVec = V; |
108 | } |
109 | |
110 | |
c04c30b3 |
111 | Handle(Geom_Vector) Geom_Direction::Crossed (const Handle(Geom_Vector)& Other) |
7fd59977 |
112 | const { |
113 | |
114 | gp_Dir V (gpVec.Crossed (Other->Vec())); |
115 | return new Direction (V); |
116 | } |
117 | |
118 | |
c04c30b3 |
119 | Handle(Geom_Vector) Geom_Direction::CrossCrossed ( |
120 | const Handle(Geom_Vector)& V1, const Handle(Geom_Vector)& V2) const { |
7fd59977 |
121 | |
122 | gp_Dir V (gpVec.CrossCrossed (V1->Vec(), V2->Vec())); |
123 | return new Direction (V); |
124 | } |
125 | |
126 | |
127 | void Geom_Direction::Transform (const gp_Trsf& T) { |
128 | |
129 | gp_Dir V (gpVec); |
130 | V.Transform (T); |
131 | gpVec = V; |
132 | } |