7fd59977 |
1 | // File: Geom2d_VectorWithMagnitude.cxx |
2 | // Created: Wed Mar 24 19:32:14 1993 |
3 | // Author: JCV |
4 | // <fid@sdsun2> |
5 | // Copyright: Matra Datavision 1993 |
6 | |
7 | //File Geom2d_VectorWithMagnitude.cxx, JCV 16/01/91 |
8 | |
9 | #include <Geom2d_VectorWithMagnitude.ixx> |
10 | |
11 | |
12 | typedef Geom2d_Vector Vector; |
13 | typedef Geom2d_VectorWithMagnitude VectorWithMagnitude; |
14 | typedef Handle(Geom2d_VectorWithMagnitude) Handle(VectorWithMagnitude); |
15 | typedef Handle(Geom2d_Vector) Handle(Vector); |
16 | |
17 | typedef gp_Ax2d Ax2d; |
18 | typedef gp_Pnt2d Pnt2d; |
19 | typedef gp_Trsf2d Trsf2d; |
20 | |
21 | |
22 | |
23 | Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (const gp_Vec2d& V) |
24 | { gpVec2d = V; } |
25 | |
26 | |
27 | Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude ( |
28 | const Standard_Real X, const Standard_Real Y) { gpVec2d = gp_Vec2d (X, Y); } |
29 | |
30 | |
31 | Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude ( |
32 | const Pnt2d& P1, const Pnt2d& P2) { gpVec2d = gp_Vec2d (P1, P2); } |
33 | |
34 | |
35 | Handle(Geom2d_Geometry) Geom2d_VectorWithMagnitude::Copy() const { |
36 | |
37 | Handle(VectorWithMagnitude) V; |
38 | V = new VectorWithMagnitude (gpVec2d); |
39 | return V; |
40 | } |
41 | |
42 | |
43 | void Geom2d_VectorWithMagnitude::SetCoord (const Standard_Real X, const Standard_Real Y) { |
44 | |
45 | gpVec2d = gp_Vec2d (X, Y); |
46 | } |
47 | |
48 | |
49 | void Geom2d_VectorWithMagnitude::SetVec2d (const gp_Vec2d& V) { gpVec2d = V; } |
50 | |
51 | void Geom2d_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec2d.SetX (X); } |
52 | |
53 | |
54 | void Geom2d_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec2d.SetY (Y); } |
55 | |
56 | |
57 | Standard_Real Geom2d_VectorWithMagnitude::Magnitude () const { |
58 | |
59 | return gpVec2d.Magnitude (); |
60 | } |
61 | |
62 | |
63 | Standard_Real Geom2d_VectorWithMagnitude::SquareMagnitude () const { |
64 | |
65 | return gpVec2d.SquareMagnitude (); |
66 | } |
67 | |
68 | |
69 | void Geom2d_VectorWithMagnitude::Add (const Handle(Vector)& Other) { |
70 | |
71 | gpVec2d.Add (Other->Vec2d()); |
72 | } |
73 | |
74 | |
75 | Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Added ( |
76 | |
77 | const Handle(Vector)& Other) const { |
78 | |
79 | gp_Vec2d Temp = Other->Vec2d(); |
80 | Temp.Add (gpVec2d); |
81 | return new VectorWithMagnitude (Temp); |
82 | } |
83 | |
84 | |
85 | Standard_Real Geom2d_VectorWithMagnitude::Crossed (const Handle(Vector)& Other) const{ |
86 | |
87 | return gpVec2d.Crossed (Other->Vec2d()); |
88 | } |
89 | |
90 | |
91 | void Geom2d_VectorWithMagnitude::Divide (const Standard_Real Scalar) { |
92 | |
93 | gpVec2d.Divide (Scalar); |
94 | } |
95 | |
96 | |
97 | Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Divided ( |
98 | const Standard_Real Scalar) const { |
99 | |
100 | gp_Vec2d V (gpVec2d); |
101 | V.Divide (Scalar); |
102 | return new VectorWithMagnitude (V); |
103 | } |
104 | |
105 | |
106 | Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Multiplied ( |
107 | const Standard_Real Scalar) const { |
108 | |
109 | gp_Vec2d V(gpVec2d); |
110 | V.Multiply (Scalar); |
111 | return new VectorWithMagnitude (V); |
112 | } |
113 | |
114 | |
115 | void Geom2d_VectorWithMagnitude::Multiply (const Standard_Real Scalar) { |
116 | |
117 | gpVec2d.Multiply (Scalar); |
118 | } |
119 | |
120 | |
121 | void Geom2d_VectorWithMagnitude::Normalize () { gpVec2d.Normalize (); } |
122 | |
123 | |
124 | Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Normalized () const { |
125 | |
126 | gp_Vec2d V = gpVec2d; |
127 | V.Normalized (); |
128 | return new VectorWithMagnitude (V); |
129 | } |
130 | |
131 | |
132 | void Geom2d_VectorWithMagnitude::Subtract (const Handle(Vector)& Other) { |
133 | |
134 | gpVec2d.Subtract (Other->Vec2d()); |
135 | } |
136 | |
137 | |
138 | Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Subtracted ( |
139 | const Handle(Vector)& Other) const { |
140 | |
141 | gp_Vec2d V = gpVec2d; |
142 | V.Subtract (Other->Vec2d()); |
143 | return new VectorWithMagnitude (V); |
144 | } |
145 | |
146 | |
147 | |
148 | void Geom2d_VectorWithMagnitude::Transform (const Trsf2d& T) { |
149 | |
150 | gpVec2d.Transform (T); |
151 | } |