-- $Id: ghostbaffle_01.lua,v 1.1 1996/10/21 19:35:40 dj Exp $ -- File : ghostbaffle.lua (is) -- P6 baffle shell6. -- Last rev. 10-18-96 (is) -- -------------------------------------------------------------- -- Parameters used for rigid body motion: -- mvx, mvy, mvz, mvazmis, mvelmis, mvclock -- -------------------------------------------------------------- -- PREVIOUS INFO: -- -------------- -- 'Ghost baffle' model for shell 6 (P6 tantalum baffle) -- This module may be used directly or it may also be dofile'd from a -- lua program which sets z_0 to another value before invoking this file. -- All lenghts are in mm; angles are in degrees -- This is the version using 'override()' to select a shell (is) -- (Based on modules from T. Gaetz and D. Jerius) -- This does the plate as a 'opaque disk' rather than a transparent -- annulus (see TG notes) -- ---------------------------------------------------------------------- $debug -- --------------------------------------------------------------------- deg2rad = 3.14159265358979/180.0 inch2mm = 25.4 mm2inch = 1.0/25.4 z_capfront = -10081.0736 -- (T.Casey coordinates.) if ( nil == debug_plate ) then debug_plate = 0 end pid = 1 -- Ghost baffle consists of a single plate -- --------------------------------------------------------------------------- -- translation and rotation parameters mvx = 0.0 mvy = 0.0 mvz = 0.0 mvazmis = 0.0 mvelmis = 0.0 mvclock = 0.0 -- --------------------------------------------------------------------------- -- used to select a shell and set other parameters override() -- --------------------------------------------------------------------------- -- this is useful if this module is 'do-filed' -- in case z_0 wasn't set, set it to the preffered coordinate system -- if(nil == z_0 ) then -- z_0 = 0.0 -- end -- --------------------------------------------------------------------------- -- The functions below set up all the geometric and motion data structures -- ==== 1 ================================================================ function setup_basedata( ) -------------------------- -- This function assigns values for annulus radii -- Last rev. 10-17-96 (is) -- Record: Ghost baffle plate ri - inner radius, ro - outer radius -- z of the ghost baffle center in T.Casey coordinates: -- ri = 0.0 if the ghost baffle is modeled as an opaque disk -- check the 'ro' value again; there is a slight difference from the # on the -- tantalum baffle drawing (315.3664) plate_data = {z = -10432.9361, ri = 0.0, ro = 315.363} -- if opaque disk model -- thickness of P6 is ignored zghost_center = plate_data.z -- this is now in P6 'BCS' -- plate_data.z = 0.0 plate_data.z = plate_data.z - zghost_center end -- End set_basedata() function -- ==== 2 =============================================================== function set_tolerances( ) ------------------------------------------ -- Last rev. 10-18-96 (is) -- This function assigns machining tolerance values for annulus radii, -- for each plate in each shell -- Record: Ghost baffle plate macining tolerances for: ri - inner radius, ro - outer radius delta_radius = {dri = 0.0, dro = 0.0} -- delta_radius = {dri = 0.0, dro = 0.508} -- plate_data.ri = plate_data.ri + delta_radius.dri -- this is N/A for disk model plate_data.ro = plate_data.ro + delta_radius.dro end -- end of function: 'set_tolerances()' -- ==== 3 =============================================================== function set_plate_displacements( ) ------------------------------------ -- Last rev. 6-27-96 (is) -- This function sets the local motion parameters (tweaks) for P6 baffle -- The 'tweak' values are given with respect to the local coordinate system -- of the baffle plate. plate_tweak = {x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0} end -- End of function 'set_plate_displacements0()' -- ==== 4 =============================================================== function move_body( ) ---------------------- -- Last rev. 6-27-96 (is) -- Motion should happen in the Body Centered Coordinate System (OSAC v7 p4-4, BCS) -- NOTE: angles need to be in radians for standard 'Aperture' package routines. -- NOTE: distances are in mm. -- Variable 'motion' : function name performing -- ================ -------- ---- ---------- -- decenter mvx, mvy X, Y translations -- despace mvz Z translation -- tilt mvazmis, mvelims azims, elims rotations -- clock mvclock clock rotation around Z -- Still TB checked : for the right order: OSAC requires : -- 1) Rotate around old OY with azmis -- 2) Rotate around old OX with elmis -- 3) Rotate around new OZ with clock (TG) rotate_y( mvazmis * deg2rad ) -- This rotation should be around 'old' OX axis -- push_ctm() -- (push current transformation matrix) rotate_x( mvelmis * deg2rad ) -- pop_ctm() -- (pop current transformation matrix) -- This rotation should be around 'new' OZ axis (clock) rotate_z(mvclock * deg2rad) -- This translation should be along 'old' OX OY axes (decenter) -- push_ctm() -- (push current transformation matrix) translate( mvx, mvy, 0 ) -- pop_ctm() -- (pop current transformation matrix) -- This translation should be along 'old' OZ axis (despace) -- push_ctm() -- (push current transformation matrix) translate( 0, 0, mvz ) -- pop_ctm() -- (pop current transformation matrix) end -- end of function 'move_body()' -- ==== 5 =============================================================== function move_plate( ) --------------------------- -- Apply tweaks to a plate -- Last rev. 6-27-96 (is) -- Decenter, X, Y translations -- Despace, Z translation -- Tilt, azims, elims rotations -- Clock rotation around Z axis set_plate_displacements( ) mvx = plate_tweak.x mvy = plate_tweak.y mvz = plate_tweak.z mvazmis = plate_tweak.azmis mvelmis = plate_tweak.elmis mvclock = plate_tweak.clock move_body( ) end -- end of function: move_plate( ) -- ==== FOR TESTS ONLY ==================================================== function do_one_strut( ) ------------------------ -- Last rev. 6-27-96 (is) -- standard function to do a strut or two orthogonal struts -- this is used in 'ghostbaffle' to test rotations -- will be removed after tests ...... -- Last rev. 6-27-96 (is) -- local theta = 0 local dtheta = 90 begin_subassembly( ) -- strut( strut_width, 1, 0 ) -- original (opaque interior) strut( strut_width, 1, 1 ) -- (transparent interior) -- theta = theta + dtheta rotate_z ( dtheta * deg2rad ) strut( strut_width, 1, 1 ) -- (transparent interior) end_subassembly( ) end -- ==== END: FOR TESTS ONLY =============================================== -- ==== 6: FILLED DISK VERSION OF DOBAFFLE ================================ function do_baffle(pid) ----------------------- -- Last rev. 10-18-96 (is) begin_subassembly( ) -- just one plate, no translation necessary -- translate( 0, 0, plate_data.z ) if ( pid == debug_plate ) then print_photon( 'raw_project' ) end annulus( plate_data.ri , plate_data.ro , 0, 1 ) -- FOR TEST ONLY: these two lines have to be removed after tests -- strut_width = 0.2*25.4 --just a 'direction mark' for visualizing rotation -- do_one_strut( ) end_subassembly( ) end -- ==== 7: ANNULUS VERSION OF DOBAFFLE =================================== -- function do_baffle1(pid) --------------------------- -- Last rev. 6-27-96 (is) -- this requires revision of 'plate_data' structure above ... -- begin_subassembly( ) -- just one plate, no translation necessary -- translate( 0, 0, plate_data.z ) -- if ( pid == debug_plate ) then -- print_photon( 'raw_project' ) -- end -- annulus( plate_data.ri, plate_data.ro, 0, 0 ) -- end_subassembly( ) -- end -- ==== 8 =================================================================== function ghostbaffle( z_origin ) -------------------------------- -- Ghost baffle assembly function -- Last rev. 10-17-96 (is) -- begin_assembly( "pass" ) begin_assembly( ) setup_basedata() -- setup the shell to be used set_tolerances() -- add tolerances -- the ghost baffle is specified in body centered coordinates -- move it to the correct position in raytrace coordinates -- note that zghost_center is the position of the body -- center in EKC coordinates, and z_origin is the position -- of the raytrace coordinate origin in EKC coordinates translate(0,0, zghost_center - z_origin) --> move_body( ) -- move : for test only ..... --> print_xfrm( ) -- for tests only --> pushctm() do_baffle( pid ) --> popctm() end_assembly( ) end -- end of P6 baffle as 'rigid body' -- ==== 9 ==================================================================== -- Now run the ghost baffle --------------------------- -- push_ctm() -- push current transformation matrix -- print_xfrm( ) -- for test only move_body( ) -- move it as needed; all parameters are applied -- pop_ctm() -- push current transformation matrix -- print_xfrm( ) -- for test only ghostbaffle( z_capfront ) -- create the the P6 baffle assembly -- print_xfrm( ) -- for test only