Changeset 898 for cpp/common/2d.h


Ignore:
Timestamp:
11/30/19 01:47:43 (8 days ago)
Author:
Maciej Komosinski
Message:

Added a few more basic 2D functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpp/common/2d.h

    r885 r898  
    2929        template <typename Q> XY operator/(Q q) const { return XY(x / q, y / q); }
    3030        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); }
    3135        void set(T _x, T _y) { x = _x; y = _y; }
    3236        void add(T _x, T _y) { x += _x; y += _y; }
     
    4347        static XY average(const XY& v1, const XY& v2) { return XY((v1.x + v2.x)*0.5, (v1.y + v2.y)*0.5); }
    4448        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); }
    4650        XY toInt() const { return XY(int(x), int(y)); }
    4751        XY transpose() const { return XY(y, x); }
Note: See TracChangeset for help on using the changeset viewer.