File: vec2list.h

package info (click to toggle)
xjig 2.4-14.1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 892 kB
  • sloc: cpp: 10,177; makefile: 1,142; perl: 23
file content (123 lines) | stat: -rw-r--r-- 3,059 bytes parent folder | download | duplicates (9)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#ifndef _vec2list_h
#define _vec2list_h

#ifndef _vec2_h
#	include "vec2.h"
#endif

//
// -------------------------------------------------------------------------
// class Vec2 : Vektorklasse, die einfach die komplexen Zahlen erweitert
// -------------------------------------------------------------------------
//

class Vec2List {
	private:
		Vec2	*v;
		int	len;
		int	alloc_len;

	public:
		Vec2List( int len=2 );
		Vec2List( const Vec2List &vl );
		Vec2List( const Vec2List &vl, const class Mat2 &m );
		~Vec2List()											{ if (v)		delete [] v; }

		void TurnLeft();
		void TurnRight();
		void TurnAngleRad( const Real &angle );
		void TurnAngleDeg( const Real &angle ) { TurnAngleRad(angle/Real(180/M_PI)); }

		const Vec2List& operator=(const Vec2List &v);

		int Len() const									{ return len; }
		const Vec2 &operator[](int i) const			{ return v[i]; }
		const Vec2 &operator()(int i) const			{ return v[(i+len)%len]; }

		const Vec2List &SetAt( int i, const Vec2 &z );
		const Vec2List &AddAt( int i, const Vec2 &z );
		const Vec2List &Del( int i );
		const Vec2List &DelRange( int i, int j, int *erg );

		void GetExtent( Vec2 *tl, Vec2 *br ) const;

	// Binary Operator Functions

		inline Vec2List operator+(const Vec2&) const;
		inline Vec2List operator-(const Vec2&) const;

#ifndef __TURBOC__
		friend inline Vec2List operator*(const Real&, const Vec2List&);
		friend int operator==(const Vec2List&, const Vec2List&);
		friend inline int operator!=(const Vec2List&, const Vec2List&);
#else
		friend Vec2List operator*(const Real&, const Vec2List&);
		friend extern int operator==(const Vec2List&, const Vec2List&);
		friend int operator!=(const Vec2List&, const Vec2List&);
#endif

		inline Vec2List operator*(const Real&) const;
		inline Vec2List operator/(const Real&) const;

		const Vec2List& operator+=(const Vec2&);
		const Vec2List& operator-=(const Vec2&);
		const Vec2List& operator*=(const Real&);
		const Vec2List& operator/=(const Real&);
		const Vec2List& operator|=(const Vec2&);

		const Vec2List& operator*=(const class Mat2&);

		inline Vec2List operator+() const;
		inline Vec2List operator-() const;
};

inline Vec2List Vec2List::operator+() const
{
	return *this;
}

inline Vec2List Vec2List::operator-() const
{
	Vec2List help(*this);
	return help*=-1;
}


// Definitions of compound-assignment operator member functions

inline Vec2List Vec2List::operator+(const Vec2 &z) const
{
		Vec2List help(*this);
		return help-=z;
}
inline Vec2List Vec2List::operator-(const Vec2 &z) const
{
		Vec2List help(*this);
		return help-=z;
}
inline Vec2List Vec2List::operator*(const Real& val2) const
{
		Vec2List help(*this);
		return help*=val2;
}
inline Vec2List operator*(const Real& val, const Vec2List& z2)
{
		Vec2List	help(z2);
		return help*=val;
}

inline Vec2List Vec2List::operator/(const Real& val) const
{
		Vec2List	help(*this);
		return help/=val;
}

extern int operator==(const Vec2List& z1, const Vec2List& z2);

inline int operator!=(const Vec2List& z1, const Vec2List& z2)
{
		  return !(z1==z2);
}

#endif