-- $Id: cap_02.lua,v 1.1 1997/02/27 20:17:37 dj Exp $ -- File : cap.lua (is) -- Last rev. 10-17-96 (is) -- -------------------------------------------------------------- -- Parameters used for rigid body motion: -- mvx, mvy, mvz, mvazmis, mvelmis, mvclock -- -------------------------------------------------------------- -- PREVIOUS INFO: -- -------------- -- Cap model containing all plates for shells 1,3,4,6 -- This module may be used directly. The front of the cap has a z value of 0.0. -- 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) -- and get motion parameters -- (Based on modules from T. Gaetz and D. Jerius) -- -------------------------------------------------------------- $debug -- -------------------------------------------------------------- deg2rad = 3.14159265358979/180.0 inch2mm = 25.4 mm2inch = 1.0/25.4 z_capfront = -10081.0736 -- in T.Casey coordinates -- Set default values for mode variables and flags: first_plate = 1 last_plate = 2 if (nil == debug_plate) then debug_plate = 0 end strut_width = 0.75 * 25.4 -- width of struts in mm -- --------------------------------------------------------------------------- -- 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 (is) override() -- --------------------------------------------------------------------------- -- in case z_0 wasn't set, set it to the preferred coordinate system -- may be useful in 'do-file'd mode 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(shell) --------------------------------- -- This function assigns values for annulus radii, for each plate in each shell -- Last rev. 10-17-96 (is) -- ******************* -- SHELL 1 ALL PLATES -- ******************* if (shell == 1) then -- Record: Plates 1-2 cap; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{z = -10081.0736, ri = 585.61700, ro = 601.72800}, {z = -10031.0864, ri = 586.37900, ro = 601.72800}} -- END OF SHELL 1 elseif (shell == 3) then -- ******************* -- SHELL 3 ALL PLATES -- ******************* -- Record: Plates 1-2 cap; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{z = -10081.0736, ri = 471.09800, ro = 484.55500 }, {z = -10031.0864, ri = 471.86000, ro = 484.55500 }} -- END OF SHELL 3 elseif (shell == 4) then -- ******************* -- SHELL 4 ALL PLATES -- ******************* -- Record: Plates 1-2 cap; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{z = -10081.0736, ri = 415.43300, ro = 427.60300 }, {z = -10031.0864, ri = 416.19500, ro = 427.60300 }} -- END OF SHELL 4 elseif (shell == 6) then -- ******************* -- SHELL 6 ALL PLATES -- ******************* -- Record: Plates 1-2 cap; z - axial coordinate, ri - inner radius, ro - outer radius plate_data = {{ z = -10081.0736, ri = 308.40600, ro = 318.10300 }, { z = -10031.0864, ri = 309.16800, ro = 318.10300 }} -- END OF SHELL 6 else error("LUA: Shell does not exist\n") end -- End of shell selection branching -- Now make Z positions to be relative to the body center -- (This is the Body Center Coordinate System used by OSAC v7) -- z of the cap center in T.Casey coordinates: should coincide with -- zcap_center = -10056.080 -- T.Casey tables (mm) zcap_center = (plate_data[first_plate].z + plate_data[last_plate].z)/2.0 pid = first_plate while pid <= last_plate do plate_data[pid].z = plate_data[pid].z - zcap_center pid = pid + 1 end end -- End set_basedata() function -- ==== 2 =============================================================== function set_tolerances( shell ) -------------------------------- -- This function assigns machining tolerance values for annulus radii, -- for each plate in each shell -- Last rev. 10-17-96 (is) -- ******************* -- SHELL 1 ALL PLATES -- ******************* if (shell == 1) then -- Record: Plates 1-2; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 0.508, dro = 0.508}} -- END OF SHELL 1 elseif (shell == 3) then -- ******************* -- SHELL 3 ALL PLATES -- ******************* -- Record: Plates 1-2; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 0.508, dro = 0.508}} -- END OF SHELL 3 elseif (shell == 4) then -- ******************* -- SHELL 4 ALL PLATES -- ******************* -- Record: Plates 1-2; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 0.508, dro = 0.508}} -- END OF SHELL 4 elseif (shell == 6) then -- ******************* -- SHELL 6 ALL PLATES -- ******************* -- Record: Plates 1-2; z - axial coordinate, ri - inner radius, ro - outer radius delta_radius = {{dri = 0.0, dro = 0.0}, {dri = 0.0, dro = 0.0}} -- delta_radius = -- {{dri = 1.270, dro = 1.270}, -- {dri = 0.508, dro = 0.508}} -- END OF SHELL 6 else error("LUA: Shell does not exist\n") end -- End of shell selection branching -- Now add machining tolerances to annulus radii pid = first_plate while pid <= last_plate do plate_data[pid].ri = plate_data[pid].ri + delta_radius[pid].dri plate_data[pid].ro = plate_data[pid].ro + delta_radius[pid].dro pid = pid + 1 end end -- end of function: 'set_tolerances()' -- ==== 3 =============================================================== function set_plate_displacements( ) ------------------------------------ -- This function sets the local motion parameters (tweaks) for each -- plate of cap. The 'tweak' values are given with respect -- to the 'proper' coordinate system of each plate. -- Last rev. 6-28-96 (is) plate_tweak = {{x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}, {x = 0, y = 0, z = 0, azmis = 0, elmis = 0, clock = 0}} end -- End of function 'set_plate_displacements()' -- ==== 4 =============================================================== function move_body( ) ---------------------- -- Last rev. 6-28-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( pid ) --------------------------- -- Apply tweaks to a specified plate -- Last rev. 6-28-96 (is) local id id = pid -- Decenter, X, Y translations -- Despace, Z translation -- Tilt, azims, elims rotations -- Clock rotation around Z axis set_plate_displacements( ) mvx = plate_tweak[id].x mvy = plate_tweak[id].y mvz = plate_tweak[id].z mvazmis = plate_tweak[id].azmis mvelmis = plate_tweak[id].elmis mvclock = plate_tweak[id].clock move_body( ) end -- end of function: move_plate( ) -- ==== 6 =============================================================== function do_struts( ) --------------------- -- standard function to do the struts -- Last rev. 6-28-96 (is) local theta = 0 local dtheta = 30 begin_subassembly( ) while theta < 180 do strut( strut_width, 1, 0 ) rotate_z ( dtheta * deg2rad ) theta = theta + dtheta end end_subassembly( ) end -- ==== 7 =============================================================== function do_plate( pid ) ------------------------ -- standard function to do a plate -- Last rev. 6-28-96 (is) begin_subassembly() translate( 0, 0, plate_data[pid].z) if ( pid == debug_plate ) then print_photon( 'raw_project' ) end annulus( plate_data[pid].ri, plate_data[pid].ro, 0, 0 ) do_struts( ) end_subassembly( ) end -- ==== 8 ============================================================== function cap( shell, z_origin ) ------------------------------- -- Cap assembly function -- Last rev. 6-28-96 (is) local id begin_assembly("pass") setup_basedata(shell) -- setup the shell to be used set_tolerances(shell) -- add tolerances -- the cap is specified in body centered coordinates -- move it to the correct position in raytrace coordinates -- note that zcap_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, zcap_center - z_origin) --> move_body( ) -- move : for test only ..... -- print_xfrm( ) -- for tests only id = first_plate while id <= last_plate do --> pushctm() move_plate( id ) -- tweak the plate do_plate( id ) --> popctm() id = id + 1 end end_assembly( ) end -- end of cap as 'rigid body' -- ==== 9 ============================================================== -- Now run the cap for the given shell -------------------------------------- -- Last rev. 10-17-96 (is) -- This is useful for tests -- 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 cap( shell, z_capfront ) -- create the cap assembly -- print_xfrm( ) -- for test only