CR23683: Geom_BSplineSurface incorrectly determines continuity for periodic cases
[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
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_Direction.ixx>
24#include <gp.hxx>
25#include <Standard_ConstructionError.hxx>
26
27typedef Geom2d_Direction Direction;
28typedef Handle(Geom2d_Direction) Handle(Direction);
29typedef Handle(Geom2d_Vector) Handle(Vector);
30typedef gp_Ax2d Ax2d;
31typedef gp_Pnt2d Pnt2d;
32typedef gp_Trsf2d Trsf2d;
33
34
35
36
37
38Handle(Geom2d_Geometry) Geom2d_Direction::Copy() const {
39
40 Handle(Direction) D;
41 D = new Direction (gpVec2d);
42 return D;
43}
44
45
46
47
48
49
50Geom2d_Direction::Geom2d_Direction (const Standard_Real X, const Standard_Real Y) {
51
52 Standard_Real D = Sqrt (X * X + Y * Y);
53 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
54 gpVec2d = gp_Vec2d (X/D, Y/D);
55}
56
57
58Geom2d_Direction::Geom2d_Direction (const gp_Dir2d& V) { gpVec2d = V; }
59
60
61void Geom2d_Direction::SetCoord (const Standard_Real X, const Standard_Real Y) {
62
63 Standard_Real D = Sqrt (X * X + Y * Y);
64 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
65 gpVec2d = gp_Vec2d (X/D, Y/D);
66}
67
68
69void Geom2d_Direction::SetDir2d (const gp_Dir2d& V) { gpVec2d = V; }
70
71
72void Geom2d_Direction::SetX (const Standard_Real X) {
73
74 Standard_Real D = Sqrt(X * X + gpVec2d.Y() * gpVec2d.Y());
75 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
76 gpVec2d = gp_Vec2d (X/D, gpVec2d.Y()/D);
77}
78
79
80void Geom2d_Direction::SetY (const Standard_Real Y) {
81
82 Standard_Real D = Sqrt (gpVec2d.X() * gpVec2d.X() + Y * Y);
83 Standard_ConstructionError_Raise_if (D <= gp::Resolution(), "");
84 gpVec2d = gp_Vec2d (gpVec2d.X()/D, Y/D);
85}
86
87
88gp_Dir2d Geom2d_Direction::Dir2d () const { return gpVec2d; }
89
90
91Standard_Real Geom2d_Direction::Magnitude () const { return 1.0; }
92
93
94Standard_Real Geom2d_Direction::SquareMagnitude () const { return 1.0; }
95
96
97Standard_Real Geom2d_Direction::Crossed (const Handle(Vector)& Other) const {
98
99 return gpVec2d.Crossed (Other->Vec2d());
100}
101
102
103void Geom2d_Direction::Transform (const gp_Trsf2d& T) {
104
105 gp_Dir2d dir = gpVec2d;
106 dir.Transform (T);
107 gpVec2d = dir;
108}