41 FXVec2f(FXfloat xx,FXfloat yy):x(xx),y(yy){}
47 FXVec2f(
const FXfloat v[]):x(v[0]),y(v[1]){}
53 const FXfloat&
operator[](FXint i)
const {
return (&x)[i];}
62 FXVec2f&
set(FXfloat d){x=d;y=d;
return *
this;}
65 FXVec2f&
set(FXfloat xx,FXfloat yy){x=xx;y=yy;
return *
this;}
71 FXVec2f&
set(
const FXfloat v[]){x=v[0];y=v[1];
return *
this;}
75 FXVec2f& operator/=(FXfloat n){
return set(x/n,y/n); }
80 FXVec2f& operator%=(
const FXVec2f& v){
return set(x*v.x,y*v.y); }
81 FXVec2f& operator/=(
const FXVec2f& v){
return set(x/v.x,y/v.y); }
84 operator FXfloat*(){
return &x;}
85 operator const FXfloat*()
const {
return &x;}
88 FXbool
operator!()
const {
return x==0.0f && y==0.0f; }
95 FXfloat
length2()
const {
return y*y+x*x; }
96 FXfloat length()
const {
return Math::sqrt(length2()); }
104 static inline FXfloat operator*(
const FXVec2f& a,
const FXVec2f& b){
return a.x*b.x+a.y*b.y; }
107 static inline FXVec2f operator*(
const FXVec2f& a,FXfloat n){
return FXVec2f(a.x*n,a.y*n);}
108 static inline FXVec2f operator*(FXfloat n,
const FXVec2f& a){
return FXVec2f(n*a.x,n*a.y);}
109 static inline FXVec2f operator/(
const FXVec2f& a,FXfloat n){
return FXVec2f(a.x/n,a.y/n);}
110 static inline FXVec2f operator/(FXfloat n,
const FXVec2f& a){
return FXVec2f(n/a.x,n/a.y);}
113 static inline FXVec2f operator+(
const FXVec2f& a,
const FXVec2f& b){
return FXVec2f(a.x+b.x,a.y+b.y); }
114 static inline FXVec2f operator-(
const FXVec2f& a,
const FXVec2f& b){
return FXVec2f(a.x-b.x,a.y-b.y); }
117 static inline FXVec2f operator%(
const FXVec2f& a,
const FXVec2f& b){
return FXVec2f(a.x*b.x,a.y*b.y); }
118 static inline FXVec2f operator/(
const FXVec2f& a,
const FXVec2f& b){
return FXVec2f(a.x/b.x,a.y/b.y); }
121 static inline FXbool operator==(
const FXVec2f& a,FXfloat n){
return a.x==n && a.y==n;}
122 static inline FXbool operator!=(
const FXVec2f& a,FXfloat n){
return a.x!=n || a.y!=n;}
123 static inline FXbool operator==(FXfloat n,
const FXVec2f& a){
return n==a.x && n==a.y;}
124 static inline FXbool operator!=(FXfloat n,
const FXVec2f& a){
return n!=a.x || n!=a.y;}
127 static inline FXbool operator==(
const FXVec2f& a,
const FXVec2f& b){
return a.x==b.x && a.y==b.y; }
128 static inline FXbool operator!=(
const FXVec2f& a,
const FXVec2f& b){
return a.x!=b.x || a.y!=b.y; }
131 static inline FXbool operator<(
const FXVec2f& a,FXfloat n){
return a.x<n && a.y<n;}
132 static inline FXbool operator<=(
const FXVec2f& a,FXfloat n){
return a.x<=n && a.y<=n;}
133 static inline FXbool operator>(
const FXVec2f& a,FXfloat n){
return a.x>n && a.y>n;}
134 static inline FXbool operator>=(
const FXVec2f& a,FXfloat n){
return a.x>=n && a.y>=n;}
137 static inline FXbool operator<(FXfloat n,
const FXVec2f& a){
return n<a.x && n<a.y;}
138 static inline FXbool operator<=(FXfloat n,
const FXVec2f& a){
return n<=a.x && n<=a.y;}
139 static inline FXbool operator>(FXfloat n,
const FXVec2f& a){
return n>a.x && n>a.y;}
140 static inline FXbool operator>=(FXfloat n,
const FXVec2f& a){
return n>=a.x && n>=a.y;}
143 static inline FXbool operator<(
const FXVec2f& a,
const FXVec2f& b){
return a.x<b.x && a.y<b.y; }
144 static inline FXbool operator<=(
const FXVec2f& a,
const FXVec2f& b){
return a.x<=b.x && a.y<=b.y; }
145 static inline FXbool operator>(
const FXVec2f& a,
const FXVec2f& b){
return a.x>b.x && a.y>b.y; }
146 static inline FXbool operator>=(
const FXVec2f& a,
const FXVec2f& b){
return a.x>=b.x && a.y>=b.y; }
149 static inline FXVec2f lo(
const FXVec2f& a,
const FXVec2f& b){
return FXVec2f(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y));}
150 static inline FXVec2f lo(
const FXVec2f& a,FXfloat n){
return FXVec2f(Math::fmin(a.x,n),Math::fmin(a.y,n));}
151 static inline FXVec2f lo(FXfloat n,
const FXVec2f& b){
return FXVec2f(Math::fmin(n,b.x),Math::fmin(n,b.y));}
154 static inline FXVec2f hi(
const FXVec2f& a,
const FXVec2f& b){
return FXVec2f(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y));}
155 static inline FXVec2f hi(
const FXVec2f& a,FXfloat n){
return FXVec2f(Math::fmax(a.x,n),Math::fmax(a.y,n));}
156 static inline FXVec2f hi(FXfloat n,
const FXVec2f& b){
return FXVec2f(Math::fmax(n,b.x),Math::fmax(n,b.y));}
159 static inline FXVec2f clamp(FXfloat lower,
const FXVec2f& x,FXfloat upper){
return hi(lo(x,upper),lower);}
162 static inline FXVec2f clamp(
const FXVec2f& x,FXfloat limit){
return hi(lo(x,limit),-limit);}
165 static inline FXVec2f clamp(
const FXVec2f& lower,
const FXVec2f& x,
const FXVec2f& upper){
return hi(lo(x,upper),lower);}
168 static inline FXVec2f clamp(
const FXVec2f& x,
const FXVec2f& limit){
return hi(lo(x,limit),-limit);}
171 static inline FXVec2f abs(
const FXVec2f& a){
return FXVec2f(Math::fabs(a.x),Math::fabs(a.y));}
174 static inline FXfloat max(
const FXVec2f& a){
return Math::fmax(a.x,a.y); }
177 static inline FXfloat min(
const FXVec2f& a){
return Math::fmin(a.x,a.y); }
180 static inline FXVec2f lerp(
const FXVec2f& u,
const FXVec2f& v,FXfloat f){
return (v-u)*f+u;}
183 extern FXAPI FXVec2f normalize(
const FXVec2f& v);
186 extern FXAPI FXStream& operator<<(FXStream& store,
const FXVec2f& v);
189 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:53
Single-precision 2-element vector.
Definition: FXVec2f.h:28
FXfloat length2() const
Length and square of length.
Definition: FXVec2f.h:95
FXVec2f & operator*=(FXfloat n)
Assigning operators.
Definition: FXVec2f.h:74
FXVec2f(const FXVec2f &v)
Initialize from another vector.
Definition: FXVec2f.h:44
FXVec2f(FXfloat xx, FXfloat yy)
Initialize from components.
Definition: FXVec2f.h:41
FXbool operator!() const
Test if zero.
Definition: FXVec2f.h:88
FXVec2f(const FXfloat v[])
Initialize from array of floats.
Definition: FXVec2f.h:47
FXVec2f & operator=(const FXVec2f &v)
Assignment.
Definition: FXVec2f.h:56
FXfloat & operator[](FXint i)
Return a non-const reference to the ith element.
Definition: FXVec2f.h:50
Definition: FX4Splitter.h:28
~FXVec2f()
Destructor.
Definition: FXVec2f.h:99
FXVec2f()
Default constructor; value is not initialized.
Definition: FXVec2f.h:35
FXVec2f & operator+=(const FXVec2f &v)
Element-wise assigning operators.
Definition: FXVec2f.h:78
FXVec2f & operator=(const FXfloat v[])
Assignment from array of floats.
Definition: FXVec2f.h:59
FXVec2f operator+() const
Unary.
Definition: FXVec2f.h:91
FXVec2f(FXfloat d)
Initialize with constant.
Definition: FXVec2f.h:38