39 explicit FXVec3d(FXdouble d):x(d),y(d),z(d){}
48 FXVec3d(
const FXdouble v[]):x(v[0]),y(v[1]),z(v[2]){}
51 FXVec3d(FXdouble xx,FXdouble yy,FXdouble zz):x(xx),y(yy),z(zz){}
57 const FXdouble&
operator[](FXint i)
const {
return (&x)[i];}
66 FXVec3d&
set(FXdouble d){x=d;y=d;z=d;
return *
this;}
69 FXVec3d&
set(FXdouble xx,FXdouble yy,FXdouble zz){x=xx;y=yy;z=zz;
return *
this;}
75 FXVec3d&
set(
const FXdouble v[]){x=v[0];y=v[1];z=v[2];
return *
this;}
79 FXVec3d& operator/=(FXdouble n){
return set(x/n,y/n,z/n); }
83 FXVec3d& operator-=(
const FXVec3d& v){
return set(x-v.x,y-v.y,z-v.z); }
84 FXVec3d& operator%=(
const FXVec3d& v){
return set(x*v.x,y*v.y,z*v.z); }
90 operator FXdouble*(){
return &x;}
91 operator const FXdouble*()
const {
return &x;}
92 operator FXVec2d&(){
return *
reinterpret_cast<FXVec2d*
>(
this);}
93 operator const FXVec2d&()
const {
return *
reinterpret_cast<const FXVec2d*
>(
this);}
96 FXbool
operator!()
const {
return x==0.0 && y==0.0 && z==0.0; }
103 FXdouble
length2()
const {
return z*z+y*y+x*x; }
104 FXdouble length()
const {
return Math::sqrt(length2()); }
112 static inline FXdouble operator*(
const FXVec3d& a,
const FXVec3d& b){
return a.x*b.x+a.y*b.y+a.z*b.z; }
115 static inline FXVec3d operator^(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x); }
118 static inline FXVec3d operator*(
const FXVec3d& a,FXdouble n){
return FXVec3d(a.x*n,a.y*n,a.z*n);}
119 static inline FXVec3d operator*(FXdouble n,
const FXVec3d& a){
return FXVec3d(n*a.x,n*a.y,n*a.z);}
120 static inline FXVec3d operator/(
const FXVec3d& a,FXdouble n){
return FXVec3d(a.x/n,a.y/n,a.z/n);}
121 static inline FXVec3d operator/(FXdouble n,
const FXVec3d& a){
return FXVec3d(n/a.x,n/a.y,n/a.z);}
124 static inline FXVec3d operator+(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x+b.x,a.y+b.y,a.z+b.z); }
125 static inline FXVec3d operator-(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x-b.x,a.y-b.y,a.z-b.z); }
128 static inline FXVec3d operator%(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x*b.x,a.y*b.y,a.z*b.z); }
129 static inline FXVec3d operator/(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x/b.x,a.y/b.y,a.z/b.z); }
132 static inline FXbool operator==(
const FXVec3d& a,FXdouble n){
return a.x==n && a.y==n && a.z==n;}
133 static inline FXbool operator!=(
const FXVec3d& a,FXdouble n){
return a.x!=n || a.y!=n || a.z!=n;}
134 static inline FXbool operator==(FXdouble n,
const FXVec3d& a){
return n==a.x && n==a.y && n==a.z;}
135 static inline FXbool operator!=(FXdouble n,
const FXVec3d& a){
return n!=a.x || n!=a.y || n!=a.z;}
138 static inline FXbool operator==(
const FXVec3d& a,
const FXVec3d& b){
return a.x==b.x && a.y==b.y && a.z==b.z; }
139 static inline FXbool operator!=(
const FXVec3d& a,
const FXVec3d& b){
return a.x!=b.x || a.y!=b.y || a.z!=b.z; }
142 static inline FXbool operator<(
const FXVec3d& a,FXdouble n){
return a.x<n && a.y<n && a.z<n;}
143 static inline FXbool operator<=(
const FXVec3d& a,FXdouble n){
return a.x<=n && a.y<=n && a.z<=n;}
144 static inline FXbool operator>(
const FXVec3d& a,FXdouble n){
return a.x>n && a.y>n && a.z>n;}
145 static inline FXbool operator>=(
const FXVec3d& a,FXdouble n){
return a.x>=n && a.y>=n && a.z>=n;}
148 static inline FXbool operator<(FXdouble n,
const FXVec3d& a){
return n<a.x && n<a.y && n<a.z;}
149 static inline FXbool operator<=(FXdouble n,
const FXVec3d& a){
return n<=a.x && n<=a.y && n<=a.z;}
150 static inline FXbool operator>(FXdouble n,
const FXVec3d& a){
return n>a.x && n>a.y && n>a.z;}
151 static inline FXbool operator>=(FXdouble n,
const FXVec3d& a){
return n>=a.x && n>=a.y && n>=a.z;}
154 static inline FXbool operator<(
const FXVec3d& a,
const FXVec3d& b){
return a.x<b.x && a.y<b.y && a.z<b.z; }
155 static inline FXbool operator<=(
const FXVec3d& a,
const FXVec3d& b){
return a.x<=b.x && a.y<=b.y && a.z<=b.z; }
156 static inline FXbool operator>(
const FXVec3d& a,
const FXVec3d& b){
return a.x>b.x && a.y>b.y && a.z>b.z; }
157 static inline FXbool operator>=(
const FXVec3d& a,
const FXVec3d& b){
return a.x>=b.x && a.y>=b.y && a.z>=b.z; }
160 static inline FXVec3d lo(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(Math::fmin(a.x,b.x),Math::fmin(a.y,b.y),Math::fmin(a.z,b.z));}
161 static inline FXVec3d lo(
const FXVec3d& a,FXdouble n){
return FXVec3d(Math::fmin(a.x,n),Math::fmin(a.y,n),Math::fmin(a.z,n));}
162 static inline FXVec3d lo(FXdouble n,
const FXVec3d& b){
return FXVec3d(Math::fmin(n,b.x),Math::fmin(n,b.y),Math::fmin(n,b.z));}
165 static inline FXVec3d hi(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(Math::fmax(a.x,b.x),Math::fmax(a.y,b.y),Math::fmax(a.z,b.z));}
166 static inline FXVec3d hi(
const FXVec3d& a,FXdouble n){
return FXVec3d(Math::fmax(a.x,n),Math::fmax(a.y,n),Math::fmax(a.z,n));}
167 static inline FXVec3d hi(FXdouble n,
const FXVec3d& b){
return FXVec3d(Math::fmax(n,b.x),Math::fmax(n,b.y),Math::fmax(n,b.z));}
170 static inline FXVec3d clamp(FXdouble lower,
const FXVec3d& x,FXdouble upper){
return hi(lo(x,upper),lower);}
173 static inline FXVec3d clamp(
const FXVec3d& x,FXdouble limit){
return hi(lo(x,limit),-limit);}
176 static inline FXVec3d clamp(
const FXVec3d& lower,
const FXVec3d& x,
const FXVec3d& upper){
return hi(lo(x,upper),lower);}
179 static inline FXVec3d clamp(
const FXVec3d& x,
const FXVec3d& limit){
return hi(lo(x,limit),-limit);}
182 static inline FXVec3d abs(
const FXVec3d& a){
return FXVec3d(Math::fabs(a.x),Math::fabs(a.y),Math::fabs(a.z));}
185 static inline FXdouble max(
const FXVec3d& a){
return Math::fmax(Math::fmax(a.x,a.y),a.z); }
188 static inline FXdouble min(
const FXVec3d& a){
return Math::fmin(Math::fmin(a.x,a.y),a.z); }
191 static inline FXVec3d lerp(
const FXVec3d& u,
const FXVec3d& v,FXdouble f){
return (v-u)*f+u;}
194 extern FXAPI FXColor colorFromVec3d(
const FXVec3d& vec);
197 extern FXAPI FXVec3d colorToVec3d(FXColor clr);
200 extern FXAPI FXVec3d normal(
const FXVec3d& a,
const FXVec3d& b,
const FXVec3d& c);
203 extern FXAPI FXVec3d normal(
const FXVec3d& a,
const FXVec3d& b,
const FXVec3d& c,
const FXVec3d& d);
206 extern FXAPI FXVec3d normalize(
const FXVec3d& v);
209 extern FXAPI FXVec3d orthogonal(
const FXVec3d& v);
212 extern FXAPI FXVec3d rotate(
const FXVec3d& vec,
const FXVec3d& axis,FXdouble ca,FXdouble sa);
215 extern FXAPI FXVec3d rotate(
const FXVec3d& vec,
const FXVec3d& axis,FXdouble ang);
218 extern FXAPI FXdouble distFromRay(
const FXVec3d& org,
const FXVec3d& dir,
const FXVec3d& pnt);
221 extern FXAPI FXStream& operator<<(FXStream& store,
const FXVec3d& v);
224 extern FXAPI FXStream& operator>>(FXStream& store,FXVec3d& v);
FXdouble & operator[](FXint i)
Return a non-const reference to the ith element.
Definition: FXVec3d.h:54
const FXdouble & operator[](FXint i) const
Return a const reference to the ith element.
Definition: FXVec3d.h:57
FXdouble length2() const
Length and square of length.
Definition: FXVec3d.h:103
FXVec3d(const FXdouble v[])
Initialize from array of doubles.
Definition: FXVec3d.h:48
FXVec3d & operator=(const FXVec3d &v)
Assignment.
Definition: FXVec3d.h:60
FXVec3d & operator*=(FXdouble n)
Assigning operators.
Definition: FXVec3d.h:78
Double-precision 3-element vector.
Definition: FXVec3d.h:28
~FXVec3d()
Destructor.
Definition: FXVec3d.h:107
FXVec3d & operator^=(const FXVec3d &v)
Cross product assigning operator.
Definition: FXVec3d.h:87
FXbool operator!() const
Test if zero.
Definition: FXVec3d.h:96
FXVec3d()
Default constructor; value is not initialized.
Definition: FXVec3d.h:36
FXVec3d & operator=(const FXdouble v[])
Assignment from array of doubles.
Definition: FXVec3d.h:63
FXVec3d(const FXVec3d &v)
Initialize from another vector.
Definition: FXVec3d.h:45
FXVec3d(FXdouble xx, FXdouble yy, FXdouble zz)
Initialize from components.
Definition: FXVec3d.h:51
Definition: FX4Splitter.h:28
Double-precision 2-element vector.
Definition: FXVec2d.h:28
FXVec3d & operator+=(const FXVec3d &v)
Element-wise assigning operators.
Definition: FXVec3d.h:82
FXVec3d(const FXVec2d &v, FXdouble s=0.0)
Initialize from 2-vector.
Definition: FXVec3d.h:42
FXVec3d(FXdouble d)
Initialize all components the same.
Definition: FXVec3d.h:39
FXVec3d operator+() const
Unary.
Definition: FXVec3d.h:99