added different rotation function
This commit is contained in:
@@ -20,6 +20,10 @@ blitz::TinyVector<double, 3> rotateVector(const blitz::TinyVector<double, 3>& v,
|
|||||||
double theta,
|
double theta,
|
||||||
double phi);
|
double phi);
|
||||||
|
|
||||||
|
blitz::TinyVector<double, 3> rotateVector2(const blitz::TinyVector<double, 3>& v,
|
||||||
|
double theta,
|
||||||
|
double phi);
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
const blitz::TinyVector<double, 3>& velocity_1,
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
const blitz::TinyVector<double, 3>& velocity_2,
|
||||||
|
|||||||
@@ -50,6 +50,36 @@ blitz::TinyVector<double, 3> rotateVector(const blitz::TinyVector<double, 3>& v,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blitz::TinyVector<double, 3> rotateVector2(const blitz::TinyVector<double, 3>& v,
|
||||||
|
double theta,
|
||||||
|
double phi) {
|
||||||
|
const double norm_value(norm(v));
|
||||||
|
if (norm_value == 0) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
const blitz::TinyVector<double, 3> n = v / norm_value;
|
||||||
|
if (n(2) != -1) {
|
||||||
|
double denominator = (1 + n(2));
|
||||||
|
const double vx =
|
||||||
|
((n(1)*n(1)/denominator + n(2))* std::cos(phi) - n(0)*n(1)/denominator
|
||||||
|
* std::sin(phi)) * std::sin(theta) +
|
||||||
|
n(0) * std::cos(theta);
|
||||||
|
const double vy =
|
||||||
|
((n(0)*n(0)/denominator + n(2))* std::sin(phi) - n(0)*n(1)/denominator
|
||||||
|
* std::cos(phi)) * std::sin(theta) +
|
||||||
|
n(1) * std::cos(theta);
|
||||||
|
const double vz =
|
||||||
|
n(2)*std::cos(theta) - (n(1) * std::sin(phi) + n(0)*std::cos(phi))
|
||||||
|
*std::sin(theta);
|
||||||
|
return blitz::TinyVector<double, 3>(vx, vy, vz) * norm_value;
|
||||||
|
} else {
|
||||||
|
const double vx = std::sin(theta) * std::cos(phi);
|
||||||
|
const double vy = std::sin(theta) * std::sin(phi);
|
||||||
|
const double vz = std::cos(theta);
|
||||||
|
return -blitz::TinyVector<double, 3>(vx, vy, vz) * norm_value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
||||||
const blitz::TinyVector<double, 3>& velocity_1,
|
const blitz::TinyVector<double, 3>& velocity_1,
|
||||||
const blitz::TinyVector<double, 3>& velocity_2,
|
const blitz::TinyVector<double, 3>& velocity_2,
|
||||||
@@ -62,7 +92,7 @@ blitz::TinyVector<double, 3> rotateVelocityInCenterOfMassFrame(
|
|||||||
const blitz::TinyVector<double, 3> v1_in_center_of_mass_frame =
|
const blitz::TinyVector<double, 3> v1_in_center_of_mass_frame =
|
||||||
velocity_1 - v_center_of_mass;
|
velocity_1 - v_center_of_mass;
|
||||||
const blitz::TinyVector<double, 3> v1_rot_in_center_of_mass_frame =
|
const blitz::TinyVector<double, 3> v1_rot_in_center_of_mass_frame =
|
||||||
rotateVector(v1_in_center_of_mass_frame, theta, phi);
|
rotateVector2(v1_in_center_of_mass_frame, theta, phi);
|
||||||
return v1_rot_in_center_of_mass_frame + v_center_of_mass;
|
return v1_rot_in_center_of_mass_frame + v_center_of_mass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user