![]() |
|
|||
File indexing completed on 2025-02-23 09:22:01
0001 // 0002 // ******************************************************************** 0003 // * License and Disclaimer * 0004 // * * 0005 // * The Geant4 software is copyright of the Copyright Holders of * 0006 // * the Geant4 Collaboration. It is provided under the terms and * 0007 // * conditions of the Geant4 Software License, included in the file * 0008 // * LICENSE and available at http://cern.ch/geant4/license . These * 0009 // * include a list of copyright holders. * 0010 // * * 0011 // * Neither the authors of this software system, nor their employing * 0012 // * institutes,nor the agencies providing financial support for this * 0013 // * work make any representation or warranty, express or implied, * 0014 // * regarding this software system or assume any liability for its * 0015 // * use. Please see the license in the file LICENSE and URL above * 0016 // * for the full disclaimer and the limitation of liability. * 0017 // * * 0018 // * This code implementation is the result of the scientific and * 0019 // * technical work of the GEANT4 collaboration. * 0020 // * By using, copying, modifying or distributing the software (or * 0021 // * any work based on the software) you agree to acknowledge its * 0022 // * use in resulting scientific publications, and indicate your * 0023 // * acceptance of all terms of the Geant4 Software license. * 0024 // ******************************************************************** 0025 // 0026 // 0027 /// file: EllipticalChromosome.cc 0028 /// brief: Implementation of virt chromosome class for rod chromosomes 0029 0030 #include "EllipticalChromosome.hh" 0031 0032 #include "G4PhysicalConstants.hh" 0033 #include "G4RandomDirection.hh" 0034 #include "Randomize.hh" 0035 0036 const G4String EllipticalChromosome::fShape = "ellipse"; 0037 0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0039 0040 EllipticalChromosome::EllipticalChromosome(const G4String& name, const G4ThreeVector& pos, 0041 const G4double& sx, const G4double& sy, 0042 const G4double& sz) 0043 : VirtualChromosome(name), 0044 fCenter(pos), 0045 fSemiX(std::abs(sx)), 0046 fSemiY(std::abs(sy)), 0047 fSemiZ(std::abs(sz)), 0048 fRotation(G4RotationMatrix()) 0049 { 0050 fInverseRotation = fRotation.inverse(); 0051 } 0052 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0053 0054 EllipticalChromosome::EllipticalChromosome(const G4String& name, const G4ThreeVector& pos, 0055 const G4double& sx, const G4double& sy, 0056 const G4double& sz, const G4RotationMatrix& rot) 0057 : VirtualChromosome(name), 0058 fCenter(pos), 0059 fSemiX(std::abs(sx)), 0060 fSemiY(std::abs(sy)), 0061 fSemiZ(std::abs(sz)), 0062 fRotation(rot) 0063 { 0064 fInverseRotation = fRotation.inverse(); 0065 } 0066 0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0068 0069 EllipticalChromosome::~EllipticalChromosome() = default; 0070 0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0072 0073 G4bool EllipticalChromosome::PointInChromosome(G4ThreeVector const& pos) 0074 { 0075 G4ThreeVector rpos = pos - fCenter; 0076 rpos = fInverseRotation(rpos); 0077 0078 //====================dousatsu========================= 0079 G4bool ok = ((std::pow(rpos.getX(), 2) / std::pow(fSemiX, 2) 0080 + std::pow(rpos.getY(), 2) / std::pow(fSemiY, 2) 0081 + std::pow(rpos.getZ(), 2) / std::pow(fSemiZ, 2)) 0082 <= 1.); 0083 //====================dousatsu========================= 0084 //// TODO: This is a box, not an ellipsoid 0085 //// Check that (x/a)**2 + (y/b)**2 + (z/c)**2 <= 1 instead 0086 // G4bool ok = (std::abs(rpos.getX()) <= fSemiX); 0087 // ok = ok && (std::abs(rpos.getY()) <= fSemiY); 0088 // ok = ok && (std::abs(rpos.getZ()) <= fSemiZ); 0089 0090 return ok; 0091 } 0092 0093 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0094 0095 // NOTE: Not uniformly random 0096 G4ThreeVector EllipticalChromosome::RandomPointInChromosome() 0097 { 0098 G4ThreeVector point = G4UniformRand() * G4RandomDirection(); 0099 point.setX(point.getX() * fSemiX); 0100 point.setY(point.getY() * fSemiY); 0101 point.setZ(point.getZ() * fSemiZ); 0102 return fCenter + fRotation(point); 0103 } 0104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |