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