summaryrefslogtreecommitdiff
path: root/src/Graphic2d/Graphic2d_Vertex.cxx
blob: a6b6989c566ecc1ccea3e59dc1cfea891b0d1f56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

// File		Graphic2d_Vertex.cxx
// Created	Aout 1993
// Author	CAL

//-Copyright	MatraDatavision 1993

//-Version	

//-Design	Declaration des variables specifiques aux points

//-Warning	Un point est defini par ses coordonnees

//-References	

//-Language	C++ 2.0

//-Declarations

// for the class
#include <Graphic2d_Vertex.ixx>

//-Aliases

//-Global data definitions
static Standard_ShortReal epsilon = ShortRealEpsilon();

//	-- les coordonnees du point
//	myX		:	Standard_ShortReal;
//	myY		:	Standard_ShortReal;

//-Constructors

//-Destructors

//-Methods, in order

Graphic2d_Vertex::Graphic2d_Vertex () {

	myX	= 0.0;
	myY	= 0.0;

}

Graphic2d_Vertex::Graphic2d_Vertex (const Quantity_Length X, const Quantity_Length Y) {

	myX	= Standard_ShortReal (X);
	myY	= Standard_ShortReal (Y);

}

Graphic2d_Vertex::Graphic2d_Vertex (const Standard_ShortReal X, const Standard_ShortReal Y) {

	myX	= X;
	myY	= Y;

}

void Graphic2d_Vertex::Coord (Quantity_Length& X, Quantity_Length& Y) const {

	X	= Quantity_Length (myX);
	Y	= Quantity_Length (myY);

}

Quantity_Length Graphic2d_Vertex::X () const {

	return (Quantity_Length (myX));

}

Quantity_Length Graphic2d_Vertex::Y () const {

	return (Quantity_Length (myY));

}

Standard_Boolean Graphic2d_Vertex::IsEqual(const Graphic2d_Vertex &other) const {

 	if( (Abs(myX - other.myX) > epsilon) ||
		(Abs(myY - other.myY) > epsilon) ) return Standard_False;
	else return Standard_True;
}

void Graphic2d_Vertex::SetCoord (const Quantity_Length Xnew, const Quantity_Length Ynew) {

	myX	= Standard_ShortReal (Xnew);
	myY	= Standard_ShortReal (Ynew);

}

void Graphic2d_Vertex::SetXCoord (const Quantity_Length Xnew) {

	myX	= Standard_ShortReal (Xnew);

}

void Graphic2d_Vertex::SetYCoord (const Quantity_Length Ynew) {

	myY	= Standard_ShortReal (Ynew);

}

Quantity_Length Graphic2d_Vertex::Distance (const Graphic2d_Vertex& AV1, const Graphic2d_Vertex& AV2) {

	return (sqrt ( (AV1.X () - AV2.X ()) * (AV1.X () - AV2.X ())
		     + (AV1.Y () - AV2.Y ()) * (AV1.Y () - AV2.Y ())));

}