Revision 0695bf91 utility/vector.h
utility/vector.h | ||
---|---|---|
125 | 125 |
{ |
126 | 126 |
Vector ret; |
127 | 127 |
|
128 |
//the cross product is only valid for vectors with 3 dimensions,
|
|
129 |
//with the exception of higher dimensional stuff that is beyond the intended scope of this library
|
|
128 |
// The cross product is only valid for vectors with 3 dimensions,
|
|
129 |
// with the exception of higher dimensional stuff that is beyond the intended scope of this library
|
|
130 | 130 |
if(N != 3) |
131 | 131 |
return ret; |
132 | 132 |
|
... | ... | |
136 | 136 |
return ret; |
137 | 137 |
} |
138 | 138 |
|
139 |
Vector scale(double scalar) |
|
139 |
Vector scale(double scalar) const
|
|
140 | 140 |
{ |
141 | 141 |
Vector ret; |
142 | 142 |
for(int i = 0; i < N; i++) |
... | ... | |
144 | 144 |
return ret; |
145 | 145 |
} |
146 | 146 |
|
147 |
Vector invert() |
|
147 |
Vector invert() const
|
|
148 | 148 |
{ |
149 | 149 |
Vector ret; |
150 | 150 |
for(int i = 0; i < N; i++) |
... | ... | |
164 | 164 |
return p_vec[n]; |
165 | 165 |
} |
166 | 166 |
|
167 |
double operator [](int n) const |
|
168 |
{ |
|
169 |
return p_vec[n]; |
|
170 |
} |
|
171 |
|
|
167 | 172 |
double& operator ()(int n) |
168 | 173 |
{ |
169 | 174 |
return p_vec[n]; |
170 | 175 |
} |
171 | 176 |
|
172 |
Vector operator + (Vector v) |
|
177 |
double operator ()(int n) const |
|
178 |
{ |
|
179 |
return p_vec[n]; |
|
180 |
} |
|
181 |
|
|
182 |
Vector operator + (Vector v) const |
|
173 | 183 |
{ |
174 | 184 |
Vector ret; |
175 | 185 |
for(int i = 0; i < N; i++) |
... | ... | |
177 | 187 |
return ret; |
178 | 188 |
} |
179 | 189 |
|
180 |
Vector operator - (Vector v) |
|
190 |
Vector operator - (Vector v) const
|
|
181 | 191 |
{ |
182 | 192 |
Vector ret; |
183 | 193 |
for(int i = 0; i < N; i++) |
... | ... | |
185 | 195 |
return ret; |
186 | 196 |
} |
187 | 197 |
|
188 |
Vector operator * (double scalar) |
|
198 |
Vector operator * (double scalar) const
|
|
189 | 199 |
{ |
190 | 200 |
return scale(scalar); |
191 | 201 |
} |
192 | 202 |
|
193 |
Vector operator / (double scalar) |
|
203 |
Vector operator / (double scalar) const
|
|
194 | 204 |
{ |
195 | 205 |
Vector ret; |
196 | 206 |
for(int i = 0; i < N; i++) |
... | ... | |
213 | 223 |
double& x() { return p_vec[0]; } |
214 | 224 |
double& y() { return p_vec[1]; } |
215 | 225 |
double& z() { return p_vec[2]; } |
226 |
double x() const { return p_vec[0]; } |
|
227 |
double y() const { return p_vec[1]; } |
|
228 |
double z() const { return p_vec[2]; } |
|
216 | 229 |
|
217 | 230 |
|
218 | 231 |
private: |
Also available in: Unified diff