0024023: Revamp the OCCT Handle -- general
[occt.git] / src / Geom2d / Geom2d_VectorWithMagnitude.cxx
CommitLineData
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
20typedef Geom2d_Vector Vector;
21typedef Geom2d_VectorWithMagnitude VectorWithMagnitude;
7fd59977 22typedef gp_Ax2d Ax2d;
23typedef gp_Pnt2d Pnt2d;
24typedef gp_Trsf2d Trsf2d;
25
7fd59977 26Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (const gp_Vec2d& V)
27{ gpVec2d = V; }
28
29
30Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
31const Standard_Real X, const Standard_Real Y) { gpVec2d = gp_Vec2d (X, Y); }
32
33
34Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
35const Pnt2d& P1, const Pnt2d& P2) { gpVec2d = gp_Vec2d (P1, P2); }
36
37
38Handle(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
46void Geom2d_VectorWithMagnitude::SetCoord (const Standard_Real X, const Standard_Real Y) {
47
48 gpVec2d = gp_Vec2d (X, Y);
49}
50
51
52void Geom2d_VectorWithMagnitude::SetVec2d (const gp_Vec2d& V) { gpVec2d = V; }
53
54void Geom2d_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec2d.SetX (X); }
55
56
57void Geom2d_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec2d.SetY (Y); }
58
59
60Standard_Real Geom2d_VectorWithMagnitude::Magnitude () const {
61
62 return gpVec2d.Magnitude ();
63}
64
65
66Standard_Real Geom2d_VectorWithMagnitude::SquareMagnitude () const {
67
68 return gpVec2d.SquareMagnitude ();
69}
70
71
c04c30b3 72void Geom2d_VectorWithMagnitude::Add (const Handle(Geom2d_Vector)& Other) {
7fd59977 73
74 gpVec2d.Add (Other->Vec2d());
75}
76
77
c04c30b3 78Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Added (
7fd59977 79
c04c30b3 80const 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 88Standard_Real Geom2d_VectorWithMagnitude::Crossed (const Handle(Geom2d_Vector)& Other) const{
7fd59977 89
90 return gpVec2d.Crossed (Other->Vec2d());
91}
92
93
94void Geom2d_VectorWithMagnitude::Divide (const Standard_Real Scalar) {
95
96 gpVec2d.Divide (Scalar);
97}
98
99
c04c30b3 100Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Divided (
7fd59977 101const Standard_Real Scalar) const {
102
103 gp_Vec2d V (gpVec2d);
104 V.Divide (Scalar);
105 return new VectorWithMagnitude (V);
106}
107
108
c04c30b3 109Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Multiplied (
7fd59977 110const Standard_Real Scalar) const {
111
112 gp_Vec2d V(gpVec2d);
113 V.Multiply (Scalar);
114 return new VectorWithMagnitude (V);
115}
116
117
118void Geom2d_VectorWithMagnitude::Multiply (const Standard_Real Scalar) {
119
120 gpVec2d.Multiply (Scalar);
121}
122
123
124void Geom2d_VectorWithMagnitude::Normalize () { gpVec2d.Normalize (); }
125
126
c04c30b3 127Handle(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 135void Geom2d_VectorWithMagnitude::Subtract (const Handle(Geom2d_Vector)& Other) {
7fd59977 136
137 gpVec2d.Subtract (Other->Vec2d());
138}
139
140
c04c30b3 141Handle(Geom2d_VectorWithMagnitude) Geom2d_VectorWithMagnitude::Subtracted (
142const 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
151void Geom2d_VectorWithMagnitude::Transform (const Trsf2d& T) {
152
153 gpVec2d.Transform (T);
154}