Message: Re: rotation of volume obout global origin rather than local origin Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: rotation of volume obout global origin rather than local origin 

Forum: Geometry
Re: None rotation of volume obout global origin rather than local origin (Greg Thom)
Date: 23 Oct, 2017
From: Michael H. Kelsey <Michael H. Kelsey>

On Mon, 23 Oct 2017 15:04:55 GMT, G Tom wrote:
> I have this scenario: I have a volume in world but this object is
> translated in the z-axis up. I want to rotate that object about the origin.
> How do I set this up so that rotation is about the red star(global origin)
> rather than the yellow start ( objects local origin) ?

Is your desire to both rotate the object and rotate its placement, like swinging it around on a turntable? If you are placing the volume directly in world, that is quite easy. You apply the same angle of rotation to both the G4RotationMatrix of the placement (which changes the object's orientation) _and_ to the G4ThreeVector position of placement.

The easiest way to do this in your code is to first set the G4ThreeVector to the desired position for the zero-angle case, then call G4ThreeVector::rotate{X,Y,Z}(angle) to apply the angular offset.

Here's an example for a rotation of angle Q around the Y axis, starting from a position at Z = 1 m:

    G4RotationMatrix* orient = new CLHEP::HepRotationY(Q);
    G4ThreeVector place(0., 0., 1.*m);
    place.rotateY(Q);

    new G4PVPlacement(orient, place, ...);

This assumes that you actually constructed your object (G4VSolid) so that its natural orientation would be the placement at zero degrees. Obviously, if you have to rotate the object no matter what, then you should add the second "orient" rotation on top of your initial one.

  -- Michael Kelsey

 Add Message Add Message
to: "Re: rotation of volume obout global origin rather than local origin"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]