64 |
*/ |
*/ |
65 |
Vector(T *v) : x(v[0]), y(v[1]) { } |
Vector(T *v) : x(v[0]), y(v[1]) { } |
66 |
|
|
67 |
|
template<class F> |
68 |
|
Vector &operator=(const Vector<F> &v) { x = v.x; y = v.y; return *this; } |
69 |
|
|
70 |
|
template<class F> |
71 |
|
operator Vector<F>() const { return Vector<F>(x, y); } |
72 |
|
|
73 |
/** Making all components finite. |
/** Making all components finite. |
74 |
*/ |
*/ |
75 |
Vector finitized() const { |
Vector finitized() const { |
89 |
|
|
90 |
/** Vector negation. |
/** Vector negation. |
91 |
*/ |
*/ |
92 |
Vector<T> operator-() { return Vector<T>(-x, -y); } |
Vector<T> operator-() const { return Vector<T>(-x, -y); } |
93 |
/** Vector addition. |
/** Vector addition. |
94 |
*/ |
*/ |
95 |
Vector operator+(const Vector<T>&v) const { return Vector(x+v.x, y+v.y); } |
Vector operator+(const Vector<T>&v) const { return Vector(x+v.x, y+v.y); } |
293 |
*/ |
*/ |
294 |
typedef Vector3<float> ZVec; |
typedef Vector3<float> ZVec; |
295 |
|
|
296 |
|
/** Shorthand. |
297 |
|
*/ |
298 |
|
typedef Vector<double> PtD; |
299 |
|
/** Shorthand. |
300 |
|
*/ |
301 |
|
typedef Vector3<double> ZPtD; |
302 |
|
/** Shorthand. |
303 |
|
*/ |
304 |
|
typedef Vector<double> VecD; |
305 |
|
/** Shorthand. |
306 |
|
*/ |
307 |
|
typedef Vector3<double> ZVecD; |
308 |
|
|
309 |
|
|
310 |
|
|
311 |
/** Linear interpolation. |
/** Linear interpolation. |
312 |
* Returns a + fract*(b-a) |
* Returns a + fract*(b-a) |
313 |
*/ |
*/ |
314 |
template<class X, class Y> inline X lerp(X a, Y b, double fract) { |
template<class X> inline X lerp(X a, X b, double fract) { |
315 |
|
return a + fract * (b-a); |
316 |
|
} |
317 |
|
inline float lerp(double a, double b, double fract) { |
318 |
return a + fract * (b-a); |
return a + fract * (b-a); |
319 |
} |
} |
320 |
|
|
407 |
using Vec23::ZVec; |
using Vec23::ZVec; |
408 |
using Vec23::Pt; |
using Vec23::Pt; |
409 |
using Vec23::Vec; |
using Vec23::Vec; |
410 |
|
using Vec23::ZPtD; |
411 |
|
using Vec23::ZVecD; |
412 |
|
using Vec23::PtD; |
413 |
|
using Vec23::VecD; |
414 |
using Vec23::lerp; |
using Vec23::lerp; |
415 |
using Vec23::dirVec; |
using Vec23::dirVec; |
416 |
} |
} |