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