Warning, file /geant4/examples/advanced/dna/moleculardna/src/CylindricalChromosome.cc was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #include "CylindricalChromosome.hh"
0031
0032 #include "G4PhysicalConstants.hh"
0033 #include "G4RandomDirection.hh"
0034 #include "Randomize.hh"
0035
0036 #include <utility>
0037
0038
0039
0040 const G4String CylindricalChromosome::fShape = "cyl";
0041
0042
0043
0044 CylindricalChromosome::CylindricalChromosome(const G4String& name, const G4ThreeVector& pos,
0045 const G4double& radius, const G4double& height)
0046 : VirtualChromosome(name),
0047 fCenter(pos),
0048 fRadius(radius),
0049 fHeight(height),
0050 fRotation(G4RotationMatrix())
0051 {
0052 fInverseRotation = fRotation.inverse();
0053 }
0054
0055
0056
0057 CylindricalChromosome::CylindricalChromosome(const G4String& name, const G4ThreeVector& pos,
0058 const G4double& radius, const G4double& height,
0059 const G4RotationMatrix& rot)
0060 : VirtualChromosome(name), fCenter(pos), fRadius(radius), fHeight(height), fRotation(rot)
0061 {
0062 fInverseRotation = fRotation.inverse();
0063 }
0064
0065
0066
0067 bool CylindricalChromosome::PointInChromosome(G4ThreeVector const& pos)
0068 {
0069 G4ThreeVector rpos = pos - fCenter;
0070 rpos = fInverseRotation(rpos);
0071
0072 G4bool height_ok;
0073 G4bool radius_ok;
0074 G4double height;
0075 G4double rad2;
0076
0077 height = std::abs(rpos.getZ());
0078 rad2 = rpos.getX() * rpos.getX() + rpos.getY() * rpos.getY();
0079
0080 height_ok = (height < fHeight);
0081 radius_ok = (rad2 < (fRadius * fRadius));
0082
0083 return height_ok && radius_ok;
0084 }
0085
0086
0087 G4ThreeVector CylindricalChromosome::RandomPointInChromosome()
0088 {
0089 G4ThreeVector point;
0090 G4double z = 2 * (G4UniformRand() - 0.5) * fHeight;
0091 G4double theta = twopi * G4UniformRand();
0092 G4double r = fRadius * std::pow(G4UniformRand(), 0.5);
0093 G4double x = r * std::cos(theta);
0094 G4double y = r * std::sin(theta);
0095 point = G4ThreeVector(x, y, z);
0096 point = fRotation(point) + fCenter;
0097
0098 return point;
0099 }
0100
0101