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