Oracle From x,y and rotation to a line

From WickyWiki
define x=100
define y=100
define r=45 -- degrees
define h=12 -- text height
define w=10 -- char width
define pi=acos(-1)
define L=10  -- line length -- use length('text')*w
select SDO_GEOMETRY(2002, NULL, 557057, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
    &x - &L/2 * cos( &r*&pi/180 ) + &h * sin( &r*&pi/180 )
  , &y - &L/2 * sin( &r*&pi/180 ) - &h * cos( &r*&pi/180 )
  , &x + &L/2 * cos( &r*&pi/180 ) + &h * sin( &r*&pi/180 )
  , &y + &L/2 * sin( &r*&pi/180 ) - &h * cos( &r*&pi/180 ) )) from dual;