45 FXVec3d(
const FXdouble v[]):x(v[0]),y(v[1]),z(v[2]){}
48 FXVec3d(FXdouble xx,FXdouble yy,FXdouble zz):x(xx),y(yy),z(zz){}
54 const FXdouble&
operator[](FXint i)
const {
return (&x)[i];}
66 FXVec3d&
set(
const FXdouble v[]){x=v[0];y=v[1];z=v[2];
return *
this;}
69 FXVec3d&
set(FXdouble xx,FXdouble yy,FXdouble zz){x=xx;y=yy;z=zz;
return *
this;}
73 FXVec3d& operator/=(FXdouble n){
return set(x/n,y/n,z/n); }
77 FXVec3d& operator-=(
const FXVec3d& v){
return set(x-v.x,y-v.y,z-v.z); }
78 FXVec3d& operator%=(
const FXVec3d& v){
return set(x*v.x,y*v.y,z*v.z); }
84 operator FXdouble*(){
return &x;}
85 operator const FXdouble*()
const {
return &x;}
86 operator FXVec2d&(){
return *
reinterpret_cast<FXVec2d*
>(
this);}
87 operator const FXVec2d&()
const {
return *
reinterpret_cast<const FXVec2d*
>(
this);}
90 FXbool
operator!()
const {
return x==0.0 && y==0.0 && z==0.0; }
97 FXdouble
length2()
const {
return z*z+y*y+x*x; }
98 FXdouble length()
const {
return Math::sqrt(length2()); }
106 static inline FXdouble operator*(
const FXVec3d& a,
const FXVec3d& b){
return a.x*b.x+a.y*b.y+a.z*b.z; }
109 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); }
112 static inline FXVec3d operator*(
const FXVec3d& a,FXdouble n){
return FXVec3d(a.x*n,a.y*n,a.z*n);}
113 static inline FXVec3d operator*(FXdouble n,
const FXVec3d& a){
return FXVec3d(n*a.x,n*a.y,n*a.z);}
114 static inline FXVec3d operator/(
const FXVec3d& a,FXdouble n){
return FXVec3d(a.x/n,a.y/n,a.z/n);}
115 static inline FXVec3d operator/(FXdouble n,
const FXVec3d& a){
return FXVec3d(n/a.x,n/a.y,n/a.z);}
118 static inline FXVec3d operator+(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x+b.x,a.y+b.y,a.z+b.z); }
119 static inline FXVec3d operator-(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x-b.x,a.y-b.y,a.z-b.z); }
122 static inline FXVec3d operator%(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x*b.x,a.y*b.y,a.z*b.z); }
123 static inline FXVec3d operator/(
const FXVec3d& a,
const FXVec3d& b){
return FXVec3d(a.x/b.x,a.y/b.y,a.z/b.z); }
126 static inline FXbool operator==(
const FXVec3d& a,FXdouble n){
return a.x==n && a.y==n && a.z==n;}
127 static inline FXbool operator!=(
const FXVec3d& a,FXdouble n){
return a.x!=n || a.y!=n || a.z!=n;}
128 static inline FXbool operator==(FXdouble n,
const FXVec3d& a){
return n==a.x && n==a.y && n==a.z;}
129 static inline FXbool operator!=(FXdouble n,
const FXVec3d& a){
return n!=a.x || n!=a.y || n!=a.z;}
132 static inline FXbool operator==(
const FXVec3d& a,
const FXVec3d& b){
return a.x==b.x && a.y==b.y && a.z==b.z; }
133 static inline FXbool operator!=(
const FXVec3d& a,
const FXVec3d& b){
return a.x!=b.x || a.y!=b.y || a.z!=b.z; }
136 static inline FXbool operator<(
const FXVec3d& a,FXdouble n){
return a.x<n && a.y<n && a.z<n;}
137 static inline FXbool operator<=(
const FXVec3d& a,FXdouble n){
return a.x<=n && a.y<=n && a.z<=n;}
138 static inline FXbool operator>(
const FXVec3d& a,FXdouble n){
return a.x>n && a.y>n && a.z>n;}
139 static inline FXbool operator>=(
const FXVec3d& a,FXdouble n){
return a.x>=n && a.y>=n && a.z>=n;}
142 static inline FXbool operator<(FXdouble n,
const FXVec3d& a){
return n<a.x && n<a.y && n<a.z;}
143 static inline FXbool operator<=(FXdouble n,
const FXVec3d& a){
return n<=a.x && n<=a.y && n<=a.z;}
144 static inline FXbool operator>(FXdouble n,
const FXVec3d& a){
return n>a.x && n>a.y && n>a.z;}
145 static inline FXbool operator>=(FXdouble n,
const FXVec3d& a){
return n>=a.x && n>=a.y && n>=a.z;}
148 static inline FXbool operator<(
const FXVec3d& a,
const FXVec3d& b){
return a.x<b.x && a.y<b.y && a.z<b.z; }
149 static inline FXbool operator<=(
const FXVec3d& a,
const FXVec3d& b){
return a.x<=b.x && a.y<=b.y && a.z<=b.z; }
150 static inline FXbool operator>(
const FXVec3d& a,
const FXVec3d& b){
return a.x>b.x && a.y>b.y && a.z>b.z; }
151 static inline FXbool operator>=(
const FXVec3d& a,
const FXVec3d& b){
return a.x>=b.x && a.y>=b.y && a.z>=b.z; }
154 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));}
155 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));}
156 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));}
159 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));}
160 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));}
161 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));}
164 static inline FXVec3d clamp(FXdouble lower,
const FXVec3d& x,FXdouble upper){
return hi(lo(x,upper),lower);}
167 static inline FXVec3d clamp(
const FXVec3d& x,FXdouble limit){
return hi(lo(x,limit),-limit);}
170 static inline FXVec3d clamp(
const FXVec3d& lower,
const FXVec3d& x,
const FXVec3d& upper){
return hi(lo(x,upper),lower);}
173 static inline FXVec3d clamp(
const FXVec3d& x,
const FXVec3d& limit){
return hi(lo(x,limit),-limit);}
176 static inline FXVec3d abs(
const FXVec3d& a){
return FXVec3d(Math::fabs(a.x),Math::fabs(a.y),Math::fabs(a.z));}
179 static inline FXdouble max(
const FXVec3d& a){
return Math::fmax(Math::fmax(a.x,a.y),a.z); }
182 static inline FXdouble min(
const FXVec3d& a){
return Math::fmin(Math::fmin(a.x,a.y),a.z); }
185 static inline FXVec3d lerp(
const FXVec3d& u,
const FXVec3d& v,FXdouble f){
return (v-u)*f+u;}
188 extern FXAPI FXColor colorFromVec3d(
const FXVec3d& vec);
191 extern FXAPI FXVec3d colorToVec3d(FXColor clr);
194 extern FXAPI FXVec3d normal(
const FXVec3d& a,
const FXVec3d& b,
const FXVec3d& c);
197 extern FXAPI FXVec3d normal(
const FXVec3d& a,
const FXVec3d& b,
const FXVec3d& c,
const FXVec3d& d);
200 extern FXAPI FXVec3d normalize(
const FXVec3d& v);
203 extern FXAPI FXVec3d orthogonal(
const FXVec3d& v);
206 extern FXAPI FXVec3d rotate(
const FXVec3d& vec,
const FXVec3d& axis,FXdouble ca,FXdouble sa);
209 extern FXAPI FXVec3d rotate(
const FXVec3d& vec,
const FXVec3d& axis,FXdouble ang);
212 extern FXAPI FXdouble distFromRay(
const FXVec3d& org,
const FXVec3d& dir,
const FXVec3d& pnt);
215 extern FXAPI FXStream& operator<<(FXStream& store,
const FXVec3d& v);
218 extern FXAPI FXStream& operator>>(FXStream& store,FXVec3d& v);
FXdouble & operator[](FXint i)
Return a non-const reference to the ith element.
Definition: FXVec3d.h:51
const FXdouble & operator[](FXint i) const
Return a const reference to the ith element.
Definition: FXVec3d.h:54
FXdouble length2() const
Length and square of length.
Definition: FXVec3d.h:97
FXVec3d(const FXdouble v[])
Initialize from array of doubles.
Definition: FXVec3d.h:45
FXVec3d & operator=(const FXVec3d &v)
Assignment.
Definition: FXVec3d.h:57
FXVec3d & operator*=(FXdouble n)
Assigning operators.
Definition: FXVec3d.h:72
Double-precision 3-element vector.
Definition: FXVec3d.h:28
~FXVec3d()
Destructor.
Definition: FXVec3d.h:101
FXVec3d & operator^=(const FXVec3d &v)
Cross product assigning operator.
Definition: FXVec3d.h:81
FXbool operator!() const
Test if zero.
Definition: FXVec3d.h:90
FXVec3d()
Default constructor; value is not initialized.
Definition: FXVec3d.h:36
FXVec3d & operator=(const FXdouble v[])
Assignment from array of doubles.
Definition: FXVec3d.h:60
FXVec3d(const FXVec3d &v)
Initialize from another vector.
Definition: FXVec3d.h:42
FXVec3d(FXdouble xx, FXdouble yy, FXdouble zz)
Initialize from components.
Definition: FXVec3d.h:48
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:76
FXVec3d(const FXVec2d &v, FXdouble s=0.0)
Initialize from 2-vector.
Definition: FXVec3d.h:39
FXVec3d operator+() const
Unary.
Definition: FXVec3d.h:93