1 #include "../include/Matematica.h" 47 for(
int d=0;d<this->
NDim;d++){
48 Resp.
x[d] = this->
x[d] + u.
x[d];
55 for(
int d=0;d<this->
NDim;d++){
56 Resp.
x[d] = this->
x[d] + u.
x[d];
61 for(
int d=0;d<this->
NDim;d++){
68 for(
int d=0;d<this->
NDim;d++){
69 Resp.
x[d] = this->
x[d] - u.
x[d];
75 for(
int d=0;d<this->
NDim;d++){
76 Resp.
x[d] = this->
x[d] - u.
x[d];
81 for(
int d=0;d<this->
NDim;d++){
89 for(
int d=0;d<this->
NDim;d++){
90 Resp.
x[d] = this->
x[d] * u.
x[d];
95 for(
int d=0;d<this->
NDim;d++){
102 for(
int d=0;d<this->
NDim;d++){
103 Resp.
x[d] = this->
x[d]*Fact;
109 for(
int d=0;d<this->
NDim;d++){
117 for(
int d=0;d<vec.
NDim;d++){
118 Resp.
x[d] = vec.
x[d]*Fact;
125 for(
int d=0;d<this->
NDim;d++){
126 Resp.
x[d] = this->
x[d] / u.
x[d];
131 for(
int d=0;d<this->
NDim;d++){
132 this->
x[d] /= u.
x[d];
139 for(
int d=0;d<this->
NDim;d++){
140 Resp += this->
x[d] * u.
x[d];
146 for(
int d=0;d<this->
NDim;d++){
154 for(
int d=0;d<
NDim;d++){
155 int NUno = (d+1)%NDim;
156 int NDue = (d+2)%NDim;
157 Resp.
x[d] = u.
x[NUno] *
x[NDue] - u.
x[NDue]*
x[NUno];
162 for(
int d=0;d<
NDim;d++){
163 int NUno = (d+1)%NDim;
164 int NDue = (d+2)%NDim;
165 this->
x[d] = this->
x[NUno] * u.
x[NDue] - this->
x[NDue]*u.
x[NUno];
170 for(
int d=0;d<
NDim;d++)
171 printf(
"%d) %lf\n",d,
x[d]);
175 for(
int d=0;d<
NDim;d++)
181 for(
int d=0;d<
NDim;d++)
182 Resp += QUAD((
x[d]));
188 for(
int d=0;d<
NDim;d++)
193 for(
int d=0;d<
NDim;d++)
194 x[d] = u->
x[d] - v->
x[d];
197 for(
int d=0;d<
NDim;d++)
203 printf(
"Incompatible vectors. Dim: %d %d\n",
NDim,u->
NDim);
208 for(
int d=0;d<
NDim;d++)
209 Resp += u->
x[d] * v->
x[d];
214 if( N >=
NDim || N < 0)
return 0.;
220 if( N >=
NDim || N < 0)
return 0.;
225 double Resp =
ScalS(u,v);
233 for(
int d=0;d<
NDim;d++)
234 Resp +=
x[d] * u->
x[d];
251 for(
int d=0;d<
NDim;d++){
252 int NUno = (d+1)%NDim;
253 int NDue = (d+2)%NDim;
254 Resp += SQR(
x[NUno] * u->
x[NDue] -
x[NDue]*u->
x[NUno]);
256 Resp = sqrt(Resp)/(
Norm()*u->
Norm());
268 printf(
"Incompatible vectors. Dim: %d %d\n",
NDim,u->
NDim);
272 for(
int d=0;d<
NDim;d++)
x[d] = .5*(u->
x[d] + v->
x[d]);
277 printf(
"Incompatible vectors. Dim: %d %d\n",u->
NDim,v->
NDim);
287 printf(
"Incompatible vectors. Dim: %d %d\n",u->
NDim,v->
NDim);
291 for(
int d=0;d<
NDim;d++){
292 int NUno = (d+1)%NDim;
293 int NDue = (d+2)%NDim;
294 double dUno = (u->
x[NUno] - w->
x[NUno])*(v->
x[NDue] - w->
x[NDue]);
295 double dDue = (u->
x[NDue] - w->
x[NDue])*(v->
x[NUno] - w->
x[NUno]);
303 printf(
"Incompatible vectors. Dim: %d %d\n",
NDim,u->
NDim);
307 for(
int d=0;d<
NDim;d++)
308 x[d] = u->
x[d] * v->
x[d];
313 for(
int d=0;d<
NDim;d++){
314 int NUno = (d+1)%NDim;
315 int NDue = (d+2)%NDim;
316 x[d] = u->
x[NUno] * v->
x[NDue] - u->
x[NDue]*v->
x[NUno];
325 for(
int d=0;d<
NDim;d++){
326 int NUno = (d+1)%NDim;
327 int NDue = (d+2)%NDim;
328 w.
x[d] =
x[NUno] * u->
x[NDue] -
x[NDue]*u->
x[NUno];
331 for(
int d=0;d<
NDim;d++){
338 x[0] = u->
x[1]*v->
x[2] - u->
x[2]*v->
x[1];
339 x[1] = u->
x[2]*v->
x[0] - u->
x[0]*v->
x[2];
340 x[2] = u->
x[0]*v->
x[1] - u->
x[1]*v->
x[0];
341 for(
int d=0;d<3;d++){
347 double Fact = Length/
Norm();
348 for(
int d=0;d<
NDim;d++)
354 for(
int d=0;d<
NDim;d++){
355 Pre +=
x[d]*Axis->
x[d];
356 Norma += SQR(Axis->
x[d]);
359 for(
int d=0;d<
NDim;d++)
360 Length +=
x[d] = Axis->
x[d]*Pre/Norma;
365 double InvNorma = 1./Axis->
Norm();
369 for(
int d=0;d<
NDim;d++)
370 x[d] = o->
x[d] -
x[d];
373 for(
int d=0;d<
NDim;d++)
377 for(
int d=0;d<
NDim;d++)
382 double Norma =
Norm();
384 for(
int d=0;d<
NDim;d++){
385 int NUno = (d+1)%NDim;
386 int NDue = (d+2)%NDim;
387 w.
x[d] =
x[NUno]*a->
x[NDue] -
x[NDue]*a->
x[NUno];
396 Perp1.
VetV(Pos,Axis);
397 Perp2.
VetV(&Perp1,Axis);
398 double Distance = Perp1.
Norm()/Axis->
Norm();
399 double NormaInv = 1./Perp2.
Norm();
400 for(
int d=0;d<Axis->
NDim;d++)
401 x[d] = Perp2[d]*Distance*NormaInv;
418 Perp1.
VetV3(Pos,Axis);
419 Perp2.
VetV3(&Perp1,Axis);
420 double Distance = Perp1.
Norm()/Axis->
Norm();
421 double NormaInv = 1./Perp2.
Norm();
423 x[d] = Perp2[d]*Distance*NormaInv;
433 for(
int d=0;d<3;d++){
434 Known[d] = S2->
Val(d) + P->
Val(d);
437 Mat.
Set(2,d,Normal.
Val(d));
439 Mat.
Solve(Known,UnKnown);
441 for(
int d=0;d<3;d++){
void Export(double *x)
Export.
void Subs(const Vettore *u, const Vettore *v)
substruct two Vettore
void Copy(Vettore *o)
Copy the vector.
double operator%(const Vettore &Vet)
Scalar product.
int Solve(double *Known, double *UnKnown)
Solve a system A|b = y.
double Norm()
Return the norm of a Vettore.
void ApplyOn(Vettore *o)
Apply on a origin.
double Normalize()
Normlizes a Vettore.
Geometrical operations on vectors.
Vettore operator^(const Vettore &vec)
Vectorial product.
Vettore operator=(const Vettore &Vet)
Assigns the entries of the rhs Vettore to the lhs.
void Print()
Prints the components.
double PerpTo3(Vettore *Pos, Vettore *Axis)
The vector perpendicolar in three dimension (faster)
void ScalV(const Vettore *u, const Vettore *v)
Scalar product between two Vettore.
Vettore operator*(const Vettore &Vet)
Moltiplication component by component.
double Val(int N)
Value of the N column.
double * x
Where the data are stored.
void Axis(Vettore *u, Vettore *v)
Calculates the axis formed by two Vettore.
double CosAngle(Vettore *u)
Computes the cosine with respect to.
double ScalS(const Vettore *u, const Vettore *v)
Multiplies the components of a Vettore for a scalar.
void Rescale(double NewLength)
Rescale the total length of the vector.
Vettore & operator-=(const Vettore &Vet)
Difference component by component.
double Col(int N)
Value of the N column.
Vettore operator-(const Vettore &Vet)
Difference component by component.
Vettore & operator+=(const Vettore &Vet)
Sum component by component.
double ProjOnAxis(Vettore *a)
Projects along the axis.
Vettore operator/(const Vettore &vec)
Division component by component.
double VetV(const Vettore *u, const Vettore *v)
Vectorial product between two Vettore returns the area.
Matrice computes the algebric operations on matrices.
bool Set(int row, int column, double Val)
Set a coefficient.
Vettore & operator*=(const Vettore &vec)
Scalar product.
int NDim
Dimension allocated.
double Abs()
Return the absolute value.
double Angle(Vettore *u, Vettore *v)
Computes the angle between two Vetttore.
Vettore & operator/=(const Vettore &vec)
Division component by component.
double ProjOnSurf(Vettore *S1, Vettore *S2, Vettore *S3, Vettore *P)
Project a point P on the point PS perpendicular to the surface described by the points S1...
void Mult(double Fact)
multiply by a scalar
double VetV3(const Vettore *u, const Vettore *v)
Vectorial product between two Vettore in three dimension (faster) returns the area.
void Normal(const Vettore *u, const Vettore *v)
Computes the normal with respect to the Vettore u and v.
Vettore operator+(const Vettore &Vet)
Sum component by component.
double SinAngle(Vettore *u, Vettore *v)
Computes the sine between two Vettore.
void Set(double Val, int Col)
Set the N column.
Vettore & operator^=(const Vettore &vec)
Vectorial product.
void NormalSurf(const Vettore *u, const Vettore *v, const Vettore *w)
Computes the normal to the plane described by u,v,w.
void PerpTo(Vettore *o)
The vector perpendicolar.