Question about Union G4ThreeVector

I am working on the construction of a geometry, which involves the union of two geometric shapes. Currently, my code is as follows:

G4double ZLCN[2] = {330*mm, 780*mm};   // zhi-wai
G4double WLCN[2] = {330*mm, 3000*mm};   // wan-wai

G4Tubs* solidZLCN = new G4Tubs("ZLCN", 0, ZLCN[0]/2*mm, ZLCN[1]/2*mm, 0, 2*PI);
G4Tubs* solidWLCN = new G4Tubs("WLCN", 0, WLCN[0]/2*mm, WLCN[1]/2*mm, 0, 2*PI);

G4RotationMatrix* yRot = new G4RotationMatrix;  
yRot->rotateY(M_PI/4.*rad);                     
yRot->rotateX(M_PI/4.*rad); 
G4ThreeVector yTrans(0*cm,0*cm, 0*cm);   
G4UnionSolid* unionMoved = new G4UnionSolid("unionMoved", solidZLCN, solidWLCN, yRot, yTrans);
G4LogicalVolume* sunionMoved = new G4LogicalVolume(unionMoved, StainlessSteel, "sunionMoved");

G4RotationMatrix *rot  = new G4RotationMatrix();
rot->rotateX(90.0*deg);
G4VPhysicalVolume* physUnion = new G4PVPlacement(rot,           
                                                G4ThreeVector(-27.075*cm, 30*cm,0*cm),
                                                sunionMoved,
                                                "pIntestine",
                                                logicWorld,
                                                false,
                                                0, 
                                                checkOverlaps);

Question 1: I would like to know whether the operations of G4ThreeVector are based on the new coordinate axis after movement or the original world coordinate axis.
Question 2: I want to achieve the requirement as shown in the figure.

The second geometric shape is rotated 45 degrees around both the X and Y axes, and when connected to the first geometric shape, it forms a slide-like container. How should I modify my code?


In Boolean solids, the transformation defines the position of the second solid relative to the first. In other words, the transformation works in the coordinate system of the first solid.

In case of complex transformations that contain both rotation and translation, I would recommend you to use constructors with G4Transform3D instead of constructors with G4RotationMatrix and G4ThreeVector. G4Transform3D can be constructed as sequence of simple transformations.

And finally, your setup can be implemented without Boolean operation using G4CutTubs.

1 Like

Thank u. Use G4Transform3D solved my problem.