1 // Created on: 1993-03-24
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <Geom2d_VectorWithMagnitude.ixx>
20 typedef Geom2d_Vector Vector;
21 typedef Geom2d_VectorWithMagnitude VectorWithMagnitude;
22 typedef Handle(Geom2d_VectorWithMagnitude) Handle(VectorWithMagnitude);
23 typedef Handle(Geom2d_Vector) Handle(Vector);
26 typedef gp_Pnt2d Pnt2d;
27 typedef gp_Trsf2d Trsf2d;
31 Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (const gp_Vec2d& V)
35 Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
36 const Standard_Real X, const Standard_Real Y) { gpVec2d = gp_Vec2d (X, Y); }
39 Geom2d_VectorWithMagnitude::Geom2d_VectorWithMagnitude (
40 const Pnt2d& P1, const Pnt2d& P2) { gpVec2d = gp_Vec2d (P1, P2); }
43 Handle(Geom2d_Geometry) Geom2d_VectorWithMagnitude::Copy() const {
45 Handle(VectorWithMagnitude) V;
46 V = new VectorWithMagnitude (gpVec2d);
51 void Geom2d_VectorWithMagnitude::SetCoord (const Standard_Real X, const Standard_Real Y) {
53 gpVec2d = gp_Vec2d (X, Y);
57 void Geom2d_VectorWithMagnitude::SetVec2d (const gp_Vec2d& V) { gpVec2d = V; }
59 void Geom2d_VectorWithMagnitude::SetX (const Standard_Real X) { gpVec2d.SetX (X); }
62 void Geom2d_VectorWithMagnitude::SetY (const Standard_Real Y) { gpVec2d.SetY (Y); }
65 Standard_Real Geom2d_VectorWithMagnitude::Magnitude () const {
67 return gpVec2d.Magnitude ();
71 Standard_Real Geom2d_VectorWithMagnitude::SquareMagnitude () const {
73 return gpVec2d.SquareMagnitude ();
77 void Geom2d_VectorWithMagnitude::Add (const Handle(Vector)& Other) {
79 gpVec2d.Add (Other->Vec2d());
83 Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Added (
85 const Handle(Vector)& Other) const {
87 gp_Vec2d Temp = Other->Vec2d();
89 return new VectorWithMagnitude (Temp);
93 Standard_Real Geom2d_VectorWithMagnitude::Crossed (const Handle(Vector)& Other) const{
95 return gpVec2d.Crossed (Other->Vec2d());
99 void Geom2d_VectorWithMagnitude::Divide (const Standard_Real Scalar) {
101 gpVec2d.Divide (Scalar);
105 Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Divided (
106 const Standard_Real Scalar) const {
108 gp_Vec2d V (gpVec2d);
110 return new VectorWithMagnitude (V);
114 Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Multiplied (
115 const Standard_Real Scalar) const {
119 return new VectorWithMagnitude (V);
123 void Geom2d_VectorWithMagnitude::Multiply (const Standard_Real Scalar) {
125 gpVec2d.Multiply (Scalar);
129 void Geom2d_VectorWithMagnitude::Normalize () { gpVec2d.Normalize (); }
132 Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Normalized () const {
134 gp_Vec2d V = gpVec2d;
136 return new VectorWithMagnitude (V);
140 void Geom2d_VectorWithMagnitude::Subtract (const Handle(Vector)& Other) {
142 gpVec2d.Subtract (Other->Vec2d());
146 Handle(VectorWithMagnitude) Geom2d_VectorWithMagnitude::Subtracted (
147 const Handle(Vector)& Other) const {
149 gp_Vec2d V = gpVec2d;
150 V.Subtract (Other->Vec2d());
151 return new VectorWithMagnitude (V);
156 void Geom2d_VectorWithMagnitude::Transform (const Trsf2d& T) {
158 gpVec2d.Transform (T);