53 inline UVector2(
double x = 0.0,
double y = 0.0);
79 inline void setX(
double x);
80 inline void setY(
double y);
81 inline void set(
double x,
double y);
84 inline double phi()
const;
87 inline double mag2()
const;
90 inline double mag()
const;
93 inline double r()
const;
102 inline void setR(
double r);
224 : x(s1.x), y(s1.y) {}
258 if (
this == &p) {
return *
this; }
266 return (v.
x ==
x && v.
y ==
y) ?
true :
false;
271 return (v.
x !=
x || v.
y !=
y) ?
true :
false;
302 return x * p.
x +
y * p.
y;
307 return x *
x +
y *
y;
312 return std::sqrt(
mag2());
317 return std::sqrt(
mag2());
324 return tot > 0.0 ? p *= (1.0 / std::sqrt(tot)) :
UVector2(1, 0);
329 double x1 = std::fabs(
x), y1 = std::fabs(
y);
342 return x == 0.0 &&
y == 0.0 ? 0.0 : std::atan2(
y,
x);
348 return ptot2 <= 0.0 ? 0.0 : std::acos(
dot(q) / std::sqrt(ptot2));
354 setX(r1 * std::cos(ph));
355 setY(r1 * std::sin(ph));
366 setX(ma * std::cos(phi1));
367 setY(ma * std::sin(phi1));
372 setX(r1 * std::cos(phi1));
373 setY(r1 * std::sin(phi1));
std::ostream & operator<<(std::ostream &, const UVector2 &)
UVector2 & operator+=(const UVector2 &p)
double angle(const UVector2 &) const
double operator*(const UVector2 &a, const UVector2 &b)
static double setTolerance(double tol)
void set(double x, double y)
friend double operator*(const UVector2 &a, const UVector2 &b)
friend UVector2 operator/(const UVector2 &p, double a)
UVector2 operator+(const UVector2 &a, const UVector2 &b)
UVector2 & operator-=(const UVector2 &p)
UVector2 operator-(const UVector2 &a, const UVector2 &b)
static const UVector2 Y_HAT2(0.0, 1.0)
UVector2 & operator=(const UVector2 &p)
bool operator==(const UVector2 &v) const
static const UVector2 X_HAT2(1.0, 0.0)
bool isParallel(const UVector2 &p, double epsilon=tolerance) const
bool isOrthogonal(const UVector2 &p, double epsilon=tolerance) const
UVector2(double x=0.0, double y=0.0)
UVector2 & operator*=(double a)
int compare(const UVector2 &v) const
double howParallel(const UVector2 &p) const
friend UVector2 operator+(const UVector2 &a, const UVector2 &b)
double operator[](int i) const
static double getTolerance()
void setPolar(double r, double phi)
double howOrthogonal(const UVector2 &p) const
bool operator<(const UVector2 &v) const
bool isNear(const UVector2 &p, double epsilon=tolerance) const
UVector2 orthogonal() const
bool operator>=(const UVector2 &v) const
friend std::ostream & operator<<(std::ostream &, const UVector2 &)
double howNear(const UVector2 &p) const
bool operator>(const UVector2 &v) const
double operator()(int i) const
UVector2 operator/(const UVector2 &p, double a)
bool operator!=(const UVector2 &v) const
bool operator<=(const UVector2 &v) const
double dot(const UVector2 &p) const
UVector2 operator-() const