# Changeset 898

Ignore:
Timestamp:
11/30/19 01:47:43 (4 years ago)
Message:

Added a few more basic 2D functions

File:
1 edited

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

 r885 template XY operator/(Q q) const { return XY(x / q, y / q); } template XY operator*(Q q) const { return XY(q*x, q*y); } XY operator*=(const XY& q) { x *= q.x; y *= q.y; return *this; } XY operator/=(const XY& q) { x /= q.x; y /= q.y; return *this; } XY operator*(const XY& q) const { return XY(x*q.x, y*q.y); } XY operator/(const XY& q) const { return XY(x/q.x, y/q.y); } void set(T _x, T _y) { x = _x; y = _y; } void add(T _x, T _y) { x += _x; y += _y; } static XY average(const XY& v1, const XY& v2) { return XY((v1.x + v2.x)*0.5, (v1.y + v2.y)*0.5); } double getDirection() const { return atan2(y, x); } static XY interpolate(const XY& v1, const XY& v2, double t) { return v1 + (v2 - v1)*t; } static XY interpolate(const XY& v1, const XY& v2, double t) { return universal_lerp(v1,v2,t); } XY toInt() const { return XY(int(x), int(y)); } XY transpose() const { return XY(y, x); }
Note: See TracChangeset for help on using the changeset viewer.