29#ifndef _LINALG_V2_T_H_
30#define _LINALG_V2_T_H_
33#include <tmath/v3_t.h>
35template<
class T>
class v2t;
40template<
class T>
class v2t {
100 x = src.
x;
y = src.
y;
108 x += src.
x;
y += src.
y;
116 x -= src.
x;
y -= src.
y;
140 return v2t(
x + src.
x,
y + src.
y);
154 return v2t(
x - src.
x,
y - src.
y);
160 if (this->
x == s.
x && this->y == s.
y) {
170 return !(*
this == s);
177 if (fabs(cmp.
x - this->x) < eps &&
178 fabs(cmp.
y - this->y) < eps)
190 return src.
x*
x + src.
y*
y;
197 return v2t(s*
x, s*
y);
210 return v2t(this->
x/s, this->
y/s);
219 return (l1*l2)/(l1.
len()*l2.
len());
227 T sina = sin(arc), cosa = cos(arc);
228 return c +
v2t(d.
x*cosa-d.
y*sina, d.
x*sina+d.
y*cosa);
235 return sqrt(
x*
x+
y*
y);
242 return sqrt((
p.x-
x)*(
p.x-
x)+(
p.y-
y)*(
p.y-
y));
257 return this->
x*b->
y - this->
y*b->
x;
int approxEquals(const v2t< T > &cmp, T eps)
int operator!=(const v2t< T > &src) const
T fakeCrossProduct(const v2t< T > *b) const
v2t(const T x, const T y)
v2t< T > & operator=(const v3t< T > &src)
friend v2t< T > operator*(const T s, const v2t< T > &src)
v2t< T > operator*(const T s) const
v2t< T > operator-(const v2t< T > &src) const
v2t< T > operator-(void) const
v2t< T > operator/(const T s) const
v2t< T > & operator*=(const T s)
int operator==(const v2t< T > &src) const
v2t< T > & operator/=(const T s)
v2t< T > rotate(const v2t< T > &c, T arc) const
T cosalpha(const v2t< T > &p2, const v2t< T > ¢er) const
T dist(const v2t< T > &p) const
v2t< T > & operator-=(const v2t< T > &src)
v2t< T > & operator=(const v2t< T > &src)
v2t< T > operator+(const v2t< T > &src) const
v2t< T > & operator+=(const v2t< T > &src)
T operator*(const v2t< T > &src) const
v2t< T > operator*(const T s, const v2t< T > &src)