67 dimeVec3f(
const dxfdouble X,
const dxfdouble Y,
const dxfdouble Z)
70 { x = xyz[0]; y = xyz[1]; z = xyz[2]; }
72 { x=v.x; y=v.y; z=v.z; };
74 {
return dimeVec3f(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x); }
76 {
return x*v.x+y*v.y+z*v.z; }
79 {
return (x == v.x && y == v.y && z == v.z); }
80 bool equals(
const dimeVec3f &v, dxfdouble tol)
81 {
return (fabs(x-v.x) <= tol && fabs(y-v.y) <= tol && fabs(z-v.z) <= tol); }
83 operator dxfdouble *() {
return &x; }
84 const dxfdouble *getValue()
const {
return &x; }
85 void getValue(dxfdouble &_x, dxfdouble &_y, dxfdouble &_z)
const
86 { _x = x; _y = y; _z = z;}
87 dxfdouble length()
const
88 {
return (dxfdouble) sqrt(x*x+y*y+z*z); }
89 dxfdouble sqrLength(
void)
const
90 {
return x*x+y*y+z*z; }
92 { x = -x; y = -y; z = -z; }
93 void setValue(
const dxfdouble *v)
94 { x = v[0]; y = v[1]; z = v[2]; }
95 void setValue(
const dxfdouble X,
const dxfdouble Y,
const dxfdouble Z)
98 dxfdouble operator [] (
const int i)
const
99 {
return( (i==0)?x:((i==1)?y:z) ); };
100 dxfdouble & operator [] (
const int i)
101 {
return( (i==0)?x:((i==1)?y:z) ); };
103 dimeVec3f &operator *= (
const dxfdouble s)
104 { x*=s; y*=s; z*=s;
return *
this; }
105 dimeVec3f &operator /= (
const dxfdouble s)
106 { x/=s; y/=s; z/=s;
return *
this; }
108 { x+=v.x; y+=v.y; z+=v.z;
return *
this; }
110 { x-=v.x; y-=v.y; z-=v.z;
return *
this;}
114 {
return dimeVec3f(v.x*s, v.y*s, v.z*s); }
116 {
return dimeVec3f(v.x*s, v.y*s, v.z*s); }
118 {
return dimeVec3f(v.x/s, v.y/s, v.z/s); }
120 {
return dimeVec3f(v1.x+v2.x, v1.y+v2.y, v1.z+v2.z); }
122 {
return dimeVec3f(v1.x-v2.x, v1.y-v2.y, v1.z-v2.z); }
125 {
return (v1.x == v2.x && v1.y == v2.y && v1.z == v2.z); }
127 {
return (v1.x != v2.x || v1.y != v2.y || v1.z != v2.z); }
130 { x=v.x; y=v.y; z=v.z;
return *
this; }
132 void multMatrix(dxfdouble *matrix)
134 dxfdouble tx, ty, tz;
136 tx = matrix[0]*x+matrix[1]*y+matrix[2]*z;
137 ty = matrix[4]*x+matrix[5]*y+matrix[6]*z;
138 tz = matrix[8]*x+matrix[9]*y+matrix[10]*z;
139 x = tx, y = ty, z = tz;
143 { printf(
"dimeVec3f: (%.3f, %.3f, %.3f)\n",x, y, z); }
144 void print(
const char *s)
const
145 { printf(
"%s: (%.3f, %.3f, %.3f)\n",s, x, y, z); }
149 {
return dimeVec3f(x*v.x, y*v.y, z*v.z); }
164 dimeMatrix(dxfdouble a11, dxfdouble a12, dxfdouble a13, dxfdouble a14,
165 dxfdouble a21, dxfdouble a22, dxfdouble a23, dxfdouble a24,
166 dxfdouble a31, dxfdouble a32, dxfdouble a33, dxfdouble a34,
167 dxfdouble a41, dxfdouble a42, dxfdouble a43, dxfdouble a44);
170 bool isIdentity()
const;
171 void setTransform(
const dimeVec3f &translation,
183 void setRotation(
const dimeVec3f &u,
const dxfdouble angle);
186 void setScale(
const dxfdouble s);
198 void multMatrixVec(
dimeVec3f &vec)
const;
204 operator dxfdouble *() {
return &matrix[0][0]; }
207 dxfdouble *operator [](
int i) {
return &matrix[i][0]; }
208 const dxfdouble * operator [](
int i)
const {
return &matrix[i][0];}
219 dxfdouble determinant(
const int i=-2,
const int j=-1);
221 void operator *=(
const dxfdouble val);
224 dxfdouble matrix[4][4];