Problem 1274 - RayTracerX not responding to /vis/viewer/set/upVector commands
Summary: RayTracerX not responding to /vis/viewer/set/upVector commands
Status: RESOLVED FIXED
Alias: None
Product: Geant4
Classification: Unclassified
Component: visualization/RayTracer (show other problems)
Version: 9.4
Hardware: Apple Mac OS X
: P5 normal
Assignee: John.Allison
URL:
Depends on:
Blocks:
 
Reported: 2011-12-27 20:19 CET by jasondet
Modified: 2012-02-12 12:23 CET (History)
0 users

See Also:


Attachments
Edits to G4RayTracerViewer.cc to fix the reported bug (4.60 KB, text/plain)
2012-01-24 07:32 CET, jasondet
Details
Edits to G4TheRayTracer.cc to fix the reported bug (14.29 KB, text/plain)
2012-01-24 07:33 CET, jasondet
Details
Edits to G4TheRayTracer.hh to fix the reported bug (7.75 KB, application/octet-stream)
2012-01-24 07:34 CET, jasondet
Details

Note You need to log in before you can comment on or make changes to this problem.
Description jasondet 2011-12-27 20:19:20 CET
My group is simulating a number of non-beam experiments in which the intuitive coordinate system has the z-axis pointing up. However, G4 visualizations set the z-axis horizontal by default (presumably because the main user base is the beam-physics community). According to the documentation, the command /vis/viewer/set/upVector can be used to get the z-axis to point vertically, e.g.

/vis/viewer/set/upVector 0 0 1

However, this command appears to have no effect when using RayTracerX. Our geometries use a number of boolean solids that are unrenderable in any of the other visualizations so RayTracer is really our only choice. Can someone check whether there is some bug in RayTracer causing this command to have no effect?

I also want to point out that the sections in the G4 User's Guide covering visualizations contain no information on the default rendered orientation of the coordinate system, at least not in any obvious place -- I couldn't find it despite searching for it, reading in detail sec 2.10, many of the sections of Chp 8, and the "Introduction to Geant4 Visualization", "Geant4 Visualization Commands", and "Geant4 Advanced Visualization" pdfs linked from section 8.1.5. Although it may be obvious to a beam physicist, those outside that community may find the default orientation confusing at first. So I suggest some discussion be added on this topic in the User's Guide.
Comment 1 jasondet 2012-01-24 07:32:50 CET
Created attachment 146 [details]
Edits to G4RayTracerViewer.cc to fix the reported bug
Comment 2 jasondet 2012-01-24 07:33:33 CET
Created attachment 147 [details]
Edits to G4TheRayTracer.cc to fix the reported bug
Comment 3 jasondet 2012-01-24 07:34:16 CET
Created attachment 148 [details]
Edits to G4TheRayTracer.hh to fix the reported bug
Comment 4 jasondet 2012-01-24 07:34:25 CET
I was able to find the part of the RayTracer code where all of these calculations are done, and I think I was able to make the edits myself. The attached files, based on their G4.9.5 versions, contain the required edits. To summarize:

- Don't override the user's head angle setting in G4RayTracerViewer::SetView()
- New data member "G4ThreeVector up;" added to G4TheRayTracer, along with a Setter and a Getter.
- Send the user-specified upVector to G4TheRayTracer in G4RayTracerViewer::SetView()
- In G4TheRayTracer::CreateBitMap(): 
  - Rotate rayDirection so that the upVector projection in the jpeg plane is parallel to the jpeg's vertical direction.
  - Use headAngle to allow for a user-specified rotation away from the upVector. headAngle's default value was changed to 0.

The code works for me in all 8 octants and for all the special cases I tried (e.g. viewpoint theta = 0 or theta = 180 deg). As for the other visualizations, the orientation is not well defined when the upVector is parallel to the viewing direction. Also, I made sure that the geometry's positive x axis points to the right and the positive y axis points up when you are looking from positive z (viewpoint theta,phi = 0,0) as I understand the convention to be.
Comment 5 John.Allison 2012-02-12 12:23:53 CET
Thanks, Jason.  Finally got around to looking at this.  Really appreciate your investigation and an actual proposal for fixing the problem.  We are very happy to incorporate your fixes.  We have installed them and tested them and they will be in the next patch, if any, and certainly in the next release.

Also, appreciate your comments about the User Guides.  We will add something for the next release.