7 float sqr(
float a) {
return a*a;}
11 float magnitude(Vector v) {
17 printf(
"Can't normalize ZERO vector\n");
29 return Vector(v1.x+v2.x,v1.y+v2.y,v1.z+v2.z);
33 return Vector(v1.x-v2.x,v1.y-v2.y,v1.z-v2.z);
35 Vector
operator-(Vector v) {
return Vector(-v.x,-v.y,-v.z);}
36 Vector
operator*(Vector v1,
float s) {
return Vector(v1.x*s,v1.y*s,v1.z*s);}
37 Vector
operator*(
float s, Vector v1) {
return Vector(v1.x*s,v1.y*s,v1.z*s);}
38 Vector
operator/(Vector v1,
float s) {
return v1*(1.0f/
s);}
41 return v1.x*v2.x + v1.y*v2.y + v1.z*v2.z;
45 v1.y * v2.z - v1.z*v2.y,
46 v1.z * v2.x - v1.x*v2.z,
47 v1.x * v2.y - v1.y*v2.x);
49 Vector planelineintersection(Vector
n,
float d,Vector p1,Vector p2){
53 float t = -(d+(n^p1) )/dn;
56 int concurrent(Vector a,Vector b) {
57 return(a.x==b.x && a.y==b.y && a.z==b.z);
62 matrix transpose(matrix m) {
63 return matrix( Vector(m.x.x,m.y.x,m.z.x),
64 Vector(m.x.y,m.y.y,m.z.y),
65 Vector(m.x.z,m.y.z,m.z.z));
69 return Vector(m.x^v,m.y^v,m.z^v);
73 return matrix(m1*m2.x,m1*m2.y,m1*m2.z);
77 Quaternion
operator*(Quaternion a,Quaternion b) {
79 c.r = a.r*b.r - a.x*b.x - a.y*b.y - a.z*b.z;
80 c.x = a.r*b.x + a.x*b.r + a.y*b.z - a.z*b.y;
81 c.y = a.r*b.y - a.x*b.z + a.y*b.r + a.z*b.x;
82 c.z = a.r*b.z + a.x*b.y - a.y*b.x + a.z*b.r;
86 return Quaternion(q.r*-1,q.x,q.y,q.z);
88 Quaternion
operator*(Quaternion a,
float b) {
89 return Quaternion(a.r*b, a.x*b, a.y*b, a.z*b);
92 return q.getmatrix() * v;
96 return Vector(0.0
f,0.0
f,0.0
f);
99 Quaternion
operator+(Quaternion a,Quaternion b) {
100 return Quaternion(a.r+b.r, a.x+b.x, a.y+b.y, a.z+b.z);
102 float operator^(Quaternion a,Quaternion b) {
103 return (a.r*b.r + a.x*b.x + a.y*b.y + a.z*b.z);
105 Quaternion
slerp(Quaternion a,Quaternion b,
float interp){
112 float theta = float(
acos(a^b));
113 if(theta==0.0
f) {
return(a);}
115 a*float(
sin(theta-interp*theta)/
sin(theta))
116 + b*float(
sin(interp*theta)/
sin(theta));
dimensionedScalar acos(const dimensionedScalar &ds)
HashSet< Key, Hash > operator^(const HashSet< Key, Hash > &hash1, const HashSet< Key, Hash > &hash2)
Create a HashSet that only contains unique entries (xor)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensionedScalar operator/(const scalar s1, const dimensionedScalar &ds2)
quaternion normalize(const quaternion &q)
Return the normalized (unit) quaternion of the given quaternion.
const dimensionedScalar & c
Speed of light in a vacuum.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
tmp< fvMatrix< Type > > operator*(const volScalarField::Internal &, const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator-(const fvMatrix< Type > &)
tmp< fvMatrix< Type > > operator+(const fvMatrix< Type > &, const fvMatrix< Type > &)
dimensionedScalar sin(const dimensionedScalar &ds)
quaternion slerp(const quaternion &qa, const quaternion &qb, const scalar t)
Spherical linear interpolation of quaternions.