OpenSceneGraph 3.6.5
Vec2i
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSG_VEC2I
15#define OSG_VEC2I 1
16
17namespace osg {
18
21class Vec2i
22{
23 public:
24
26 typedef int value_type;
27
29 enum { num_components = 2 };
30
33
34 Vec2i() { _v[0]=0; _v[1]=0; }
35
36 Vec2i(value_type x, value_type y) { _v[0] = x; _v[1] = y; }
37
38 inline bool operator == (const Vec2i& v) const { return _v[0]==v._v[0] && _v[1]==v._v[1]; }
39 inline bool operator != (const Vec2i& v) const { return _v[0]!=v._v[0] || _v[1]!=v._v[1]; }
40 inline bool operator < (const Vec2i& v) const
41 {
42 if (_v[0]<v._v[0]) return true;
43 else if (_v[0]>v._v[0]) return false;
44 else return (_v[1]<v._v[1]);
45 }
46
47 inline value_type* ptr() { return _v; }
48 inline const value_type* ptr() const { return _v; }
49
50 inline void set( value_type x, value_type y)
51 {
52 _v[0]=x; _v[1]=y;
53 }
54
55 inline void set( const Vec2i& rhs)
56 {
57 _v[0]=rhs._v[0]; _v[1]=rhs._v[1];
58 }
59
60 inline value_type& operator [] (int i) { return _v[i]; }
61 inline value_type operator [] (int i) const { return _v[i]; }
62
63 inline value_type& x() { return _v[0]; }
64 inline value_type& y() { return _v[1]; }
65
66 inline value_type x() const { return _v[0]; }
67 inline value_type y() const { return _v[1]; }
68
69 inline value_type& r() { return _v[0]; }
70 inline value_type& g() { return _v[1]; }
71
72 inline value_type r() const { return _v[0]; }
73 inline value_type g() const { return _v[1]; }
74
75 inline Vec2i operator * (value_type rhs) const
76 {
77 return Vec2i(_v[0]*rhs, _v[1]*rhs);
78 }
79
80 inline Vec2i operator / (value_type rhs) const
81 {
82 return Vec2i(_v[0]/rhs, _v[1]/rhs);
83 }
84
85 inline Vec2i operator + (value_type rhs) const
86 {
87 return Vec2i(_v[0]+rhs, _v[1]+rhs);
88 }
89
90 inline Vec2i operator - (value_type rhs) const
91 {
92 return Vec2i(_v[0]-rhs, _v[1]-rhs);
93 }
94
95 inline Vec2i operator + (const Vec2i& rhs) const
96 {
97 return Vec2i(_v[0]+rhs._v[0], _v[1]+rhs._v[1]);
98 }
99
100 inline Vec2i operator - (const Vec2i& rhs) const
101 {
102 return Vec2i(_v[0]-rhs._v[0], _v[1]-rhs._v[1]);
103 }
104
105 inline Vec2i operator * (const Vec2i& rhs) const
106 {
107 return Vec2i(_v[0]*rhs._v[0], _v[1]*rhs._v[1]);
108 }
109
110};
111
112}
113
114#endif
The core osg library provides the basic scene graph classes such as Nodes, State and Drawables,...
Definition AlphaFunc:19
Vec2i(value_type x, value_type y)
Definition Vec2i:36
@ num_components
Definition Vec2i:29
value_type _v[2]
Vec member variable.
Definition Vec2i:32
void set(value_type x, value_type y)
Definition Vec2i:50
Vec2i operator+(value_type rhs) const
Definition Vec2i:85
value_type x() const
Definition Vec2i:66
value_type & r()
Definition Vec2i:69
value_type g() const
Definition Vec2i:73
Vec2i operator-(value_type rhs) const
Definition Vec2i:90
Vec2i()
Definition Vec2i:34
int value_type
Type of Vec class.
Definition Vec2i:26
Vec2i operator/(value_type rhs) const
Definition Vec2i:80
Vec2i operator*(value_type rhs) const
Definition Vec2i:75
value_type * ptr()
Definition Vec2i:47
value_type & g()
Definition Vec2i:70
bool operator!=(const Vec2i &v) const
Definition Vec2i:39
bool operator<(const Vec2i &v) const
Definition Vec2i:40
value_type & operator[](int i)
Definition Vec2i:60
void set(const Vec2i &rhs)
Definition Vec2i:55
const value_type * ptr() const
Definition Vec2i:48
value_type y() const
Definition Vec2i:67
bool operator==(const Vec2i &v) const
Definition Vec2i:38
value_type r() const
Definition Vec2i:72
value_type & y()
Definition Vec2i:64
value_type & x()
Definition Vec2i:63

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.