46 FXVec4d(
const FXdouble v[]):x(v[0]),y(v[1]),z(v[2]),w(v[3]){}
49 FXVec4d(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww):x(xx),y(yy),z(zz),w(ww){}
55 const FXdouble&
operator[](FXint i)
const {
return (&x)[i];}
67 FXVec4d&
set(
const FXdouble v[]){x=v[0];y=v[1];z=v[2];w=v[3];
return *
this;}
70 FXVec4d&
set(FXdouble xx,FXdouble yy,FXdouble zz,FXdouble ww){x=xx;y=yy;z=zz;w=ww;
return *
this;}
74 FXVec4d& operator/=(FXdouble n){
return set(x/n,y/n,z/n,w/n); }
78 FXVec4d& operator-=(
const FXVec4d& v){
return set(x-v.x,y-v.y,z-v.z,w-v.w); }
79 FXVec4d& operator%=(
const FXVec4d& v){
return set(x*v.x,y*v.y,z*v.z,w*v.w); }
80 FXVec4d& operator/=(
const FXVec4d& v){
return set(x/v.x,y/v.y,z/v.z,w/v.w); }
83 operator FXdouble*(){
return &x;}
84 operator const FXdouble*()
const {
return &x;}
85 operator FXVec3d&(){
return *
reinterpret_cast<FXVec3d*
>(
this);}
86 operator const FXVec3d&()
const {
return *
reinterpret_cast<const FXVec3d*
>(
this);}
89 FXbool
operator!()
const {
return x==0.0 && y==0.0 && z==0.0 && w==0.0; }
96 FXdouble
length2()
const {
return w*w+z*z+y*y+x*x; }
97 FXdouble length()
const {
return Math::sqrt(length2()); }
100 FXdouble distance(
const FXVec3d& p)
const;
103 FXbool crosses(
const FXVec3d& a,
const FXVec3d& b)
const;
111 static inline FXdouble operator*(
const FXVec4d& a,
const FXVec4d& b){
return a.x*b.x+a.y*b.y+a.z*b.z+a.w*b.w; }
114 static inline FXVec4d operator*(
const FXVec4d& a,FXdouble n){
return FXVec4d(a.x*n,a.y*n,a.z*n,a.w*n);}
115 static inline FXVec4d operator*(FXdouble n,
const FXVec4d& a){
return FXVec4d(n*a.x,n*a.y,n*a.z,n*a.w);}
116 static inline FXVec4d operator/(
const FXVec4d& a,FXdouble n){
return FXVec4d(a.x/n,a.y/n,a.z/n,a.w/n);}
117 static inline FXVec4d operator/(FXdouble n,
const FXVec4d& a){
return FXVec4d(n/a.x,n/a.y,n/a.z,n/a.w);}
120 static inline FXVec4d operator+(
const FXVec4d& a,
const FXVec4d& b){
return FXVec4d(a.x+b.x,a.y+b.y,a.z+b.z,a.w+b.w); }
121 static inline FXVec4d operator-(
const FXVec4d& a,
const FXVec4d& b){
return FXVec4d(a.x-b.x,a.y-b.y,a.z-b.z,a.w-b.w); }
124 static inline FXVec4d operator%(
const FXVec4d& a,
const FXVec4d& b){
return FXVec4d(a.x*b.x,a.y*b.y,a.z*b.z,a.w*b.w); }
125 static inline FXVec4d operator/(
const FXVec4d& a,
const FXVec4d& b){
return FXVec4d(a.x/b.x,a.y/b.y,a.z/b.z,a.w/b.w); }
128 static inline FXbool operator==(
const FXVec4d& a,FXdouble n){
return a.x==n && a.y==n && a.z==n && a.w==n;}
129 static inline FXbool operator!=(
const FXVec4d& a,FXdouble n){
return a.x!=n || a.y!=n || a.z!=n || a.w!=n;}
130 static inline FXbool operator==(FXdouble n,
const FXVec4d& a){
return n==a.x && n==a.y && n==a.z && n==a.w;}
131 static inline FXbool operator!=(FXdouble n,
const FXVec4d& a){
return n!=a.x || n!=a.y || n!=a.z || n!=a.w;}
134 static inline FXbool operator==(
const FXVec4d& a,
const FXVec4d& b){
return a.x==b.x && a.y==b.y && a.z==b.z && a.w==b.w; }
135 static inline FXbool operator!=(
const FXVec4d& a,
const FXVec4d& b){
return a.x!=b.x || a.y!=b.y || a.z!=b.z || a.w!=b.w; }
138 static inline FXbool operator<(
const FXVec4d& a,FXdouble n){
return a.x<n && a.y<n && a.z<n && a.w<n;}
139 static inline FXbool operator<=(
const FXVec4d& a,FXdouble n){
return a.x<=n && a.y<=n && a.z<=n && a.w<=n;}
140 static inline FXbool operator>(
const FXVec4d& a,FXdouble n){
return a.x>n && a.y>n && a.z>n && a.w>n;}
141 static inline FXbool operator>=(
const FXVec4d& a,FXdouble n){
return a.x>=n && a.y>=n && a.z>=n && a.w>=n;}
144 static inline FXbool operator<(FXdouble n,
const FXVec4d& a){
return n<a.x && n<a.y && n<a.z && n<a.w;}
145 static inline FXbool operator<=(FXdouble n,
const FXVec4d& a){
return n<=a.x && n<=a.y && n<=a.z && n<=a.w;}
146 static inline FXbool operator>(FXdouble n,
const FXVec4d& a){
return n>a.x && n>a.y && n>a.z && n>a.w;}
147 static inline FXbool operator>=(FXdouble n,
const FXVec4d& a){
return n>=a.x && n>=a.y && n>=a.z && n>=a.w;}
150 static inline FXbool operator<(
const FXVec4d& a,
const FXVec4d& b){
return a.x<b.x && a.y<b.y && a.z<b.z && a.w<b.w; }
151 static inline FXbool operator<=(
const FXVec4d& a,
const FXVec4d& b){
return a.x<=b.x && a.y<=b.y && a.z<=b.z && a.w<=b.w; }
152 static inline FXbool operator>(
const FXVec4d& a,
const FXVec4d& b){
return a.x>b.x && a.y>b.y && a.z>b.z && a.w>b.w; }
153 static inline FXbool operator>=(
const FXVec4d& a,
const FXVec4d& b){
return a.x>=b.x && a.y>=b.y && a.z>=b.z && a.w>=b.w; }
156 static inline FXVec4d lo(
const FXVec4d& a,
const FXVec4d& b){
return FXVec4d(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y),Math::fmin(a.z,b.z),Math::fmin(a.w,b.w));}
157 static inline FXVec4d lo(
const FXVec4d& a,FXdouble n){
return FXVec4d(Math::fmin(a.x,n),Math::fmin(a.y,n),Math::fmin(a.z,n),Math::fmin(a.w,n));}
158 static inline FXVec4d lo(FXdouble n,
const FXVec4d& b){
return FXVec4d(Math::fmin(n,b.x),Math::fmin(n,b.y),Math::fmin(n,b.z),Math::fmin(n,b.w));}
161 static inline FXVec4d hi(
const FXVec4d& a,
const FXVec4d& b){
return FXVec4d(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y),Math::fmax(a.z,b.z),Math::fmax(a.w,b.w));}
162 static inline FXVec4d hi(
const FXVec4d& a,FXdouble n){
return FXVec4d(Math::fmax(a.x,n),Math::fmax(a.y,n),Math::fmax(a.z,n),Math::fmax(a.w,n));}
163 static inline FXVec4d hi(FXdouble n,
const FXVec4d& b){
return FXVec4d(Math::fmax(n,b.x),Math::fmax(n,b.y),Math::fmax(n,b.z),Math::fmax(n,b.w));}
166 static inline FXVec4d clamp(FXdouble lower,
const FXVec4d& x,FXdouble upper){
return hi(lo(x,upper),lower);}
169 static inline FXVec4d clamp(
const FXVec4d& x,FXdouble limit){
return hi(lo(x,limit),-limit);}
172 static inline FXVec4d clamp(
const FXVec4d& lower,
const FXVec4d& x,
const FXVec4d& upper){
return hi(lo(x,upper),lower);}
175 static inline FXVec4d clamp(
const FXVec4d& x,
const FXVec4d& limit){
return hi(lo(x,limit),-limit);}
178 static inline FXVec4d abs(
const FXVec4d& a){
return FXVec4d(Math::fabs(a.x),Math::fabs(a.y),Math::fabs(a.z),Math::fabs(a.w));}
181 static inline FXdouble max(
const FXVec4d& a){
return Math::fmax(Math::fmax(a.x,a.y),Math::fmax(a.z,a.w)); }
184 static inline FXdouble min(
const FXVec4d& a){
return Math::fmin(Math::fmin(a.x,a.y),Math::fmin(a.z,a.w)); }
187 static inline FXVec4d lerp(
const FXVec4d& u,
const FXVec4d& v,FXdouble f){
return (v-u)*f+u;}
190 extern FXAPI FXVec4d plane(
const FXVec4d& vec);
193 extern FXAPI FXVec4d plane(
const FXVec3d& vec,FXdouble dist);
196 extern FXAPI FXVec4d plane(
const FXVec3d& vec,
const FXVec3d& p);
199 extern FXAPI FXVec4d plane(
const FXVec3d& a,
const FXVec3d& b,
const FXVec3d& c);
202 extern FXAPI FXColor colorFromVec4d(
const FXVec4d& vec);
205 extern FXAPI FXVec4d colorToVec4d(FXColor clr);
208 extern FXAPI FXVec4d normalize(
const FXVec4d& v);
211 extern FXAPI FXStream& operator<<(FXStream& store,
const FXVec4d& v);
214 extern FXAPI FXStream& operator>>(FXStream& store,FXVec4d& v);
FXdouble & operator[](FXint i)
Return a non-const reference to the ith element.
Definition: FXVec4d.h:52
FXVec4d(const FXVec3d &v, FXdouble s=0.0)
Construct with 3-vector.
Definition: FXVec4d.h:40
FXVec4d & operator=(const FXVec4d &v)
Assignment.
Definition: FXVec4d.h:58
FXVec4d(FXdouble xx, FXdouble yy, FXdouble zz, FXdouble ww)
Initialize with components.
Definition: FXVec4d.h:49
Double-precision 3-element vector.
Definition: FXVec3d.h:28
FXVec4d(const FXVec4d &v)
Initialize from another vector.
Definition: FXVec4d.h:43
FXdouble length2() const
Length and square of length.
Definition: FXVec4d.h:96
FXVec4d & operator*=(FXdouble n)
Assigning operators.
Definition: FXVec4d.h:73
FXbool operator!() const
Test if zero.
Definition: FXVec4d.h:89
FXVec4d operator+() const
Unary.
Definition: FXVec4d.h:92
~FXVec4d()
Destructor.
Definition: FXVec4d.h:106
Definition: FX4Splitter.h:28
FXVec4d & operator+=(const FXVec4d &v)
Element-wise assigning operators.
Definition: FXVec4d.h:77
Double-precision 4-element vector.
Definition: FXVec4d.h:28
FXVec4d & operator=(const FXdouble v[])
Assignment from array of doubles.
Definition: FXVec4d.h:61
FXVec4d(const FXdouble v[])
Initialize from array of doubles.
Definition: FXVec4d.h:46
const FXdouble & operator[](FXint i) const
Return a const reference to the ith element.
Definition: FXVec4d.h:55
FXVec4d()
Default constructor; value is not initialized.
Definition: FXVec4d.h:37