aboutsummaryrefslogtreecommitdiff
path: root/tool_src/BspLib/Vertex2.h
blob: 5ebf1000194c423393984458b673a69eb2e09119 (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
//-----------------------------------------------------------------------------
//	BSPLIB HEADER: Vertex2.h
//
//  Copyright (c) 1997 by Markus Hadwiger
//  All Rights Reserved.
//-----------------------------------------------------------------------------

#ifndef _VERTEX2_H_
#define _VERTEX2_H_

// bsplib header files
#include "BspLibDefs.h"


BSPLIB_NAMESPACE_BEGIN


// conversion from Vector2 to Vertex2 -----------------------------------------
inline Vertex2::Vertex2( const Vector2& vect )
{
	X = vect.X;
	Y = vect.Y;
	W = vect.W;
}

// operator '==' does memberwise comparison for (X,Y,W) -----------------------
inline int operator ==( const Vertex2 v1, const Vertex2 v2 )
{
	return ( ( v1.X == v2.X ) && ( v1.Y == v2.Y ) && ( v1.W == v2.W ) );
}

// operator '!=' does memberwise comparison for (X,Y,W) -----------------------
inline int operator !=( const Vertex2 v1, const Vertex2 v2 )
{
	return ( ( v1.X != v2.X ) || ( v1.Y != v2.Y ) || ( v1.W != v2.W ) );
}

// operator '+=' does memberwise addition for (X,Y) ---------------------------
inline Vertex2& Vertex2::operator +=( const Vector2 v )
{
	X += v.X;
	Y += v.Y;

	return *this;
}

// operator '-=' does memberwise subtraction for (X,Y) ------------------------
inline Vertex2& Vertex2::operator -=( const Vector2 v )
{
	X -= v.X;
	Y -= v.Y;

	return *this;
}

// check if specified vertex is in vicinity of local vertex -------------------
inline int Vertex2::IsInVicinity( const Vertex2& vertex ) const
{
	return ( ( fabs( X - vertex.X ) < EPS_VERTEX_MERGE ) &&
			 ( fabs( Y - vertex.Y ) < EPS_VERTEX_MERGE ) );
}

// copy three coordinates into two plus w -------------------------------------
inline void Vertex2::InitFromVertex3( const Vertex3& vertex )
{
	X = vertex.getX();
	Y = vertex.getY();
	W = vertex.getZ();
}


BSPLIB_NAMESPACE_END


#endif // _VERTEX2_H_