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 static inline FXdouble operator*(
const FXVec2d& a,
const FXVec2d& b){
return a.x*b.x+a.y*b.y; }
101 static inline FXVec2d operator*(
const FXVec2d& a,FXdouble n){
return FXVec2d(a.x*n,a.y*n);}
102 static inline FXVec2d operator*(FXdouble n,
const FXVec2d& a){
return FXVec2d(n*a.x,n*a.y);}
103 static inline FXVec2d operator/(
const FXVec2d& a,FXdouble n){
return FXVec2d(a.x/n,a.y/n);}
104 static inline FXVec2d operator/(FXdouble n,
const FXVec2d& a){
return FXVec2d(n/a.x,n/a.y);}
107 static inline FXVec2d operator+(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x+b.x,a.y+b.y); }
108 static inline FXVec2d operator-(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x-b.x,a.y-b.y); }
111 static inline FXVec2d operator%(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x*b.x,a.y*b.y); }
112 static inline FXVec2d operator/(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(a.x/b.x,a.y/b.y); }
115 static inline FXbool operator==(
const FXVec2d& a,FXdouble n){
return a.x==n && a.y==n;}
116 static inline FXbool operator!=(
const FXVec2d& a,FXdouble n){
return a.x!=n || a.y!=n;}
117 static inline FXbool operator==(FXdouble n,
const FXVec2d& a){
return n==a.x && n==a.y;}
118 static inline FXbool operator!=(FXdouble n,
const FXVec2d& a){
return n!=a.x || n!=a.y;}
121 static inline FXbool operator==(
const FXVec2d& a,
const FXVec2d& b){
return a.x==b.x && a.y==b.y; }
122 static inline FXbool operator!=(
const FXVec2d& a,
const FXVec2d& b){
return a.x!=b.x || a.y!=b.y; }
125 static inline FXbool operator<(
const FXVec2d& a,FXdouble n){
return a.x<n && a.y<n;}
126 static inline FXbool operator<=(
const FXVec2d& a,FXdouble n){
return a.x<=n && a.y<=n;}
127 static inline FXbool operator>(
const FXVec2d& a,FXdouble n){
return a.x>n && a.y>n;}
128 static inline FXbool operator>=(
const FXVec2d& a,FXdouble n){
return a.x>=n && a.y>=n;}
131 static inline FXbool operator<(FXdouble n,
const FXVec2d& a){
return n<a.x && n<a.y;}
132 static inline FXbool operator<=(FXdouble n,
const FXVec2d& a){
return n<=a.x && n<=a.y;}
133 static inline FXbool operator>(FXdouble n,
const FXVec2d& a){
return n>a.x && n>a.y;}
134 static inline FXbool operator>=(FXdouble n,
const FXVec2d& a){
return n>=a.x && n>=a.y;}
137 static inline FXbool operator<(
const FXVec2d& a,
const FXVec2d& b){
return a.x<b.x && a.y<b.y; }
138 static inline FXbool operator<=(
const FXVec2d& a,
const FXVec2d& b){
return a.x<=b.x && a.y<=b.y; }
139 static inline FXbool operator>(
const FXVec2d& a,
const FXVec2d& b){
return a.x>b.x && a.y>b.y; }
140 static inline FXbool operator>=(
const FXVec2d& a,
const FXVec2d& b){
return a.x>=b.x && a.y>=b.y; }
143 static inline FXVec2d lo(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y));}
144 static inline FXVec2d lo(
const FXVec2d& a,FXdouble n){
return FXVec2d(Math::fmin(a.x,n),Math::fmin(a.y,n));}
145 static inline FXVec2d lo(FXdouble n,
const FXVec2d& b){
return FXVec2d(Math::fmin(n,b.x),Math::fmin(n,b.y));}
148 static inline FXVec2d hi(
const FXVec2d& a,
const FXVec2d& b){
return FXVec2d(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y));}
149 static inline FXVec2d hi(
const FXVec2d& a,FXdouble n){
return FXVec2d(Math::fmax(a.x,n),Math::fmax(a.y,n));}
150 static inline FXVec2d hi(FXdouble n,
const FXVec2d& b){
return FXVec2d(Math::fmax(n,b.x),Math::fmax(n,b.y));}
153 static inline FXVec2d clamp(FXdouble lower,
const FXVec2d& x,FXdouble upper){
return hi(lo(x,upper),lower);}
156 static inline FXVec2d clamp(
const FXVec2d& x,FXdouble limit){
return hi(lo(x,limit),-limit);}
159 static inline FXVec2d clamp(
const FXVec2d& lower,
const FXVec2d& x,
const FXVec2d& upper){
return hi(lo(x,upper),lower);}
162 static inline FXVec2d clamp(
const FXVec2d& x,
const FXVec2d& limit){
return hi(lo(x,limit),-limit);}
165 static inline FXVec2d abs(
const FXVec2d& a){
return FXVec2d(Math::fabs(a.x),Math::fabs(a.y));}
168 static inline FXdouble max(
const FXVec2d& a){
return Math::fmax(a.x,a.y); }
171 static inline FXdouble min(
const FXVec2d& a){
return Math::fmin(a.x,a.y); }
174 static inline FXVec2d lerp(
const FXVec2d& u,
const FXVec2d& v,FXdouble f){
return (v-u)*f+u;}
177 extern FXAPI FXVec2d normalize(
const FXVec2d& v);
180 extern FXAPI FXStream& operator<<(FXStream& store,
const FXVec2d& v);
183 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