/idl/heiles_all/goddard_jan2007/pro/misc/one_ray.pro

http://github.com/charleshull6/c_soft · IDL · 61 lines · 57 code · 4 blank · 0 comment · 4 complexity · 3830b4dd3b40fb22b367154ed15ec698 MD5 · raw file

  1. pro one_ray,xcen,ycen,len,angle,terminus,nodraw=nodraw, _EXTRA=_extra, $
  2. data = data, normal = normal
  3. ;+
  4. ; NAME:
  5. ; ONE_RAY
  6. ; PURPOSE:
  7. ; Draw a line with a specified starting point, length, and angle
  8. ;
  9. ; CALLING SEQUENCE:
  10. ; one_ray, xcen, ycen, len, angle, terminus, /NODRAW ]
  11. ;
  12. ; INPUT PARAMETERS:
  13. ; xcen, ycen = starting point in device coordinates, floating point
  14. ; scalars
  15. ; len = length in pixels, device coordinates
  16. ; angle = angle in degrees counterclockwise from +X direction
  17. ;
  18. ; OUTPUT PARAMETERS:
  19. ; terminus = two-element vector giving ending point of ray in device
  20. ; coordinates
  21. ;
  22. ; OPTIONAL KEYWORD INPUT PARAMETERS:
  23. ; /nodraw if non-zero, the ray is not actually drawn, but the terminus
  24. ; is still calculated
  25. ;
  26. ; Any valid keyword to PLOTS can also be passed ot ONE_RAY. In
  27. ; particular, COLOR, THICK, and LINESTYLE control the color, thickness
  28. ; and linestyle of the drawn line.
  29. ; EXAMPLE:
  30. ; Draw a double thickness line of length 32 pixels from (256,256)
  31. ; 45 degrees counterclockwise from the X axis
  32. ;
  33. ; IDL> one_ray, 256, 256, 32, 45 ,term, THICK = 2
  34. ;
  35. ; PROCEDURE: straightforward matrix arithmetic
  36. ;
  37. ; MODIFICATION HISTORY:
  38. ; Written by R. S. Hill, Hughes STX Corp., 20-May-1992.
  39. ; Modified to work correctly for COLOR=0 J.Wm.Parker HITC 1995 May 25
  40. ; Added _EXTRA keywords to PLOT W. Landsman November 2006
  41. ;-
  42. On_error,2
  43. compile_opt idl2
  44. if N_params() LT 3 then begin
  45. print,'Syntax - one_ray, xcen, ycen, len, angle, [terminus,] ' + $
  46. '[ /DATA, /NORMAL, THICK= ,COLOR =, /NODRAW ]'
  47. endif
  48. device = 1 - (keyword_set(normal) or keyword_set(data) )
  49. sina = sin(angle/!radeg)
  50. cosa = cos(angle/!radeg)
  51. rot_mat = [ [ cosa, sina ], [-sina, cosa ] ]
  52. terminus = (rot_mat # [len, 0.0]) + [xcen, ycen]
  53. if not keyword_set(nodraw) then $
  54. plots, [xcen, terminus[0]], [ycen, terminus[1]], $
  55. DEVICE=device, Normal=Normal,_STRICT_Extra= _extra
  56. return
  57. end