41 FXVec2d(
const FXdouble v[]):x(v[0]),y(v[1]){}
44 FXVec2d(FXdouble xx,FXdouble yy):x(xx),y(yy){}
50 const FXdouble&
operator[](FXint i)
const {
return (&x)[i];}
62 FXVec2d&
set(
const FXdouble v[]){x=v[0];y=v[1];
return *
this;}
65 FXVec2d&
set(FXdouble xx,FXdouble yy){x=xx;y=yy;
return *
this;}
69 FXVec2d& operator/=(FXdouble n){
return set(x/n,y/n); }
74 FXVec2d& operator%=(
const FXVec2d& v){
return set(x*v.x,y*v.y); }
75 FXVec2d& operator/=(
const FXVec2d& v){
return set(x/v.x,y/v.y); }
78 operator FXdouble*(){
return &x;}
79 operator const FXdouble*()
const {
return &x;}
82 FXbool
operator!()
const {
return x==0.0 && y==0.0;}
89 FXdouble
length2()
const {
return y*y+x*x; }
90 FXdouble length()
const {
return Math::sqrt(length2()); }
98 inline FXdouble operator*(
const FXVec2d& a,
const FXVec2d& b){
return a.x*b.x+a.y*b.y; }
101 inline FXVec2d operator*(
const FXVec2d& a,FXdouble n){
return FXVec2d(a.x*n,a.y*n);}
102 inline FXVec2d operator*(FXdouble n,
const FXVec2d& a){
return FXVec2d(n*a.x,n*a.y);}
103 inline FXVec2d operator/(
const FXVec2d& a,FXdouble n){
return FXVec2d(a.x/n,a.y/n);}
104 inline FXVec2d operator/(FXdouble n,
const FXVec2d& a){
return FXVec2d(n/a.x,n/a.y);}
107 inline FXVec2d operator+(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x+b.x,a.y+b.y); }
108 inline FXVec2d operator-(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x-b.x,a.y-b.y); }
111 inline FXVec2d operator%(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x*b.x,a.y*b.y); }
112 inline FXVec2d operator/(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x/b.x,a.y/b.y); }
115 inline FXbool operator==(
const FXVec2d& a,FXdouble n){
return a.x==n && a.y==n;}
116 inline FXbool operator!=(
const FXVec2d& a,FXdouble n){
return a.x!=n || a.y!=n;}
117 inline FXbool operator==(FXdouble n,
const FXVec2d& a){
return n==a.x && n==a.y;}
118 inline FXbool operator!=(FXdouble n,
const FXVec2d& a){
return n!=a.x || n!=a.y;}
121 inline FXbool operator==(
const FXVec2d& a,
const FXVec2d& b){
return a.x==b.x && a.y==b.y; }
122 inline FXbool operator!=(
const FXVec2d& a,
const FXVec2d& b){
return a.x!=b.x || a.y!=b.y; }
125 inline FXbool operator<(
const FXVec2d& a,FXdouble n){
return a.x<n && a.y<n;}
126 inline FXbool operator<=(
const FXVec2d& a,FXdouble n){
return a.x<=n && a.y<=n;}
127 inline FXbool operator>(
const FXVec2d& a,FXdouble n){
return a.x>n && a.y>n;}
128 inline FXbool operator>=(
const FXVec2d& a,FXdouble n){
return a.x>=n && a.y>=n;}
131 inline FXbool operator<(FXdouble n,
const FXVec2d& a){
return n<a.x && n<a.y;}
132 inline FXbool operator<=(FXdouble n,
const FXVec2d& a){
return n<=a.x && n<=a.y;}
133 inline FXbool operator>(FXdouble n,
const FXVec2d& a){
return n>a.x && n>a.y;}
134 inline FXbool operator>=(FXdouble n,
const FXVec2d& a){
return n>=a.x && n>=a.y;}
137 inline FXbool operator<(
const FXVec2d& a,
const FXVec2d& b){
return a.x<b.x && a.y<b.y; }
138 inline FXbool operator<=(
const FXVec2d& a,
const FXVec2d& b){
return a.x<=b.x && a.y<=b.y; }
139 inline FXbool operator>(
const FXVec2d& a,
const FXVec2d& b){
return a.x>b.x && a.y>b.y; }
140 inline FXbool operator>=(
const FXVec2d& a,
const FXVec2d& b){
return a.x>=b.x && a.y>=b.y; }
143 inline FXVec2d lo(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y));}
144 inline FXVec2d lo(
const FXVec2d& a,FXdouble n){
return FXVec2d(Math::fmin(a.x,n),Math::fmin(a.y,n));}
145 inline FXVec2d lo(FXdouble n,
const FXVec2d& b){
return FXVec2d(Math::fmin(n,b.x),Math::fmin(n,b.y));}
148 inline FXVec2d hi(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y));}
149 inline FXVec2d hi(
const FXVec2d& a,FXdouble n){
return FXVec2d(Math::fmax(a.x,n),Math::fmax(a.y,n));}
150 inline FXVec2d hi(FXdouble n,
const FXVec2d& b){
return FXVec2d(Math::fmax(n,b.x),Math::fmax(n,b.y));}
153 inline FXVec2d clamp(FXdouble lower,
const FXVec2d& x,FXdouble upper){
return hi(lo(x,upper),lower);}
156 inline FXVec2d clamp(
const FXVec2d& lower,
const FXVec2d& x,
const FXVec2d& upper){
return hi(lo(x,upper),lower);}
159 inline FXVec2d abs(
const FXVec2d& a){
return FXVec2d(Math::fabs(a.x),Math::fabs(a.y));}
162 inline FXdouble max(
const FXVec2d& a){
return Math::fmax(a.x,a.y); }
165 inline FXdouble min(
const FXVec2d& a){
return Math::fmin(a.x,a.y); }
168 inline FXVec2d lerp(
const FXVec2d& u,
const FXVec2d& v,FXdouble f){
return (v-u)*f+u;}
171 extern FXAPI FXVec2d normalize(
const FXVec2d& v);
174 extern FXAPI FXStream& operator<<(FXStream& store,
const FXVec2d& v);
177 extern FXAPI FXStream& operator>>(FXStream& store,FXVec2d& v);
FXVec2d & operator*=(FXdouble n)
Assigning operators.
Definition: FXVec2d.h:68
FXVec2d & operator=(const FXdouble v[])
Assignment from array of doubles.
Definition: FXVec2d.h:56
FXVec2d operator+() const
Unary.
Definition: FXVec2d.h:85
FXVec2d & operator+=(const FXVec2d &v)
Element-wise assigning operators.
Definition: FXVec2d.h:72
FXVec2d(const FXVec2d &v)
Initialize from another vector.
Definition: FXVec2d.h:38
FXVec2d(FXdouble xx, FXdouble yy)
Initialize from components.
Definition: FXVec2d.h:44
FXVec2d(const FXdouble v[])
Initialize from array of doubles.
Definition: FXVec2d.h:41
Definition: FX4Splitter.h:28
FXdouble length2() const
Length and square of length.
Definition: FXVec2d.h:89
const FXdouble & operator[](FXint i) const
Return a const reference to the ith element.
Definition: FXVec2d.h:50
Double-precision 2-element vector.
Definition: FXVec2d.h:28
~FXVec2d()
Destructor.
Definition: FXVec2d.h:93
FXbool operator!() const
Test if zero.
Definition: FXVec2d.h:82
FXVec2d & operator=(const FXVec2d &v)
Assignment.
Definition: FXVec2d.h:53
FXVec2d()
Default constructor; value is not initialized.
Definition: FXVec2d.h:35
FXdouble & operator[](FXint i)
Return a non-const reference to the ith element.
Definition: FXVec2d.h:47