0024428: Implementation of LGPL license
[occt.git] / src / Geom2d / Geom2d_Direction.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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
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_Direction.ixx>
18#include <gp.hxx>
19#include <Standard_ConstructionError.hxx>
20
21typedef Geom2d_Direction Direction;
22typedef Handle(Geom2d_Direction) Handle(Direction);
23typedef Handle(Geom2d_Vector) Handle(Vector);
24typedef gp_Ax2d Ax2d;
25typedef gp_Pnt2d Pnt2d;
26typedef gp_Trsf2d Trsf2d;
27
28
29
30
31
32Handle(Geom2d_Geometry) Geom2d_Direction::Copy() const {
33
34 Handle(Direction) D;
35 D = new Direction (gpVec2d);
36 return D;
37}
38
39
40
41
42
43
44Geom2d_Direction::Geom2d_Direction (const Standard_Real X, const Standard_Real Y) {
45
46 Standard_Real D = Sqrt (X * X + Y * Y);
47 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
48 gpVec2d = gp_Vec2d (X/D, Y/D);
49}
50
51
52Geom2d_Direction::Geom2d_Direction (const gp_Dir2d& V) { gpVec2d = V; }
53
54
55void Geom2d_Direction::SetCoord (const Standard_Real X, const Standard_Real Y) {
56
57 Standard_Real D = Sqrt (X * X + Y * Y);
58 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
59 gpVec2d = gp_Vec2d (X/D, Y/D);
60}
61
62
63void Geom2d_Direction::SetDir2d (const gp_Dir2d& V) { gpVec2d = V; }
64
65
66void Geom2d_Direction::SetX (const Standard_Real X) {
67
68 Standard_Real D = Sqrt(X * X + gpVec2d.Y() * gpVec2d.Y());
69 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
70 gpVec2d = gp_Vec2d (X/D, gpVec2d.Y()/D);
71}
72
73
74void Geom2d_Direction::SetY (const Standard_Real Y) {
75
76 Standard_Real D = Sqrt (gpVec2d.X() * gpVec2d.X() + Y * Y);
77 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
78 gpVec2d = gp_Vec2d (gpVec2d.X()/D, Y/D);
79}
80
81
82gp_Dir2d Geom2d_Direction::Dir2d () const { return gpVec2d; }
83
84
85Standard_Real Geom2d_Direction::Magnitude () const { return 1.0; }
86
87
88Standard_Real Geom2d_Direction::SquareMagnitude () const { return 1.0; }
89
90
91Standard_Real Geom2d_Direction::Crossed (const Handle(Vector)& Other) const {
92
93 return gpVec2d.Crossed (Other->Vec2d());
94}
95
96
97void Geom2d_Direction::Transform (const gp_Trsf2d& T) {
98
99 gp_Dir2d dir = gpVec2d;
100 dir.Transform (T);
101 gpVec2d = dir;
102}