- Timestamp:
- 11/30/19 01:47:43 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cpp/common/2d.h
r885 r898 29 29 template <typename Q> XY operator/(Q q) const { return XY(x / q, y / q); } 30 30 template <typename Q> XY operator*(Q q) const { return XY(q*x, q*y); } 31 XY operator*=(const XY& q) { x *= q.x; y *= q.y; return *this; } 32 XY operator/=(const XY& q) { x /= q.x; y /= q.y; return *this; } 33 XY operator*(const XY& q) const { return XY(x*q.x, y*q.y); } 34 XY operator/(const XY& q) const { return XY(x/q.x, y/q.y); } 31 35 void set(T _x, T _y) { x = _x; y = _y; } 32 36 void add(T _x, T _y) { x += _x; y += _y; } … … 43 47 static XY average(const XY& v1, const XY& v2) { return XY((v1.x + v2.x)*0.5, (v1.y + v2.y)*0.5); } 44 48 double getDirection() const { return atan2(y, x); } 45 static XY interpolate(const XY& v1, const XY& v2, double t) { return v1 + (v2 - v1)*t; }49 static XY interpolate(const XY& v1, const XY& v2, double t) { return universal_lerp(v1,v2,t); } 46 50 XY toInt() const { return XY(int(x), int(y)); } 47 51 XY transpose() const { return XY(y, x); }
Note: See TracChangeset
for help on using the changeset viewer.