algorithm for drawing a sort of nozzle(line),whose is direction determined by the mouse?
<p>i am using The old Turbo C++ and am a beginner.
This is the code of a ongoing project that i am planning.</p>

<p>the circle moves withe WSAD keys
But the problem is that i want the nozzle(a line from the center) of that circle to follow the movement of the mouse,but i cant figure out the mathematical part to restrict the length of that nozzle to, say 30 pixels. the line goes on touching the pointer's location.</p>

<p>I tried to use the Distance formula and the line equation to get with an expression which has both the slope and the length of the line. But the problem here is that there is an square root in the denominator, and i think that is causing the problem</p>

<p>Most of the code here is unnecessary for the following problem, so please ignore</p>

<p>here is the relevant code</p>

<pre><code>   originx=getmaxx()/2;
   originy=getmaxy()/2;

   while(doga==0)      //main game loop
     {      if(kbhit())
    op=getch();
        if(limiter&gt;10)             //limiter is used to restrict the motion of the  circle for a limited                                 //  time
   { op=0;limiter=0;}         // otherwise the cirlce moves in that direction unless another                                      //key is pressed


       //movement of the circle
    if(op==72)
      { originy--;  limiter++;}
    if(op==80)
          {originy++;  limiter++;}
    if(op==75)
     { originx--;  limiter++ ;}
    if(op==77)
     { originx++;  limiter++;    }

    circle(originx,originy,5);

      mouseposi(x,y,cl);
   printf(" %d  %d",x,y);
   printf("\b\b\b\b\b\b\b\b");

     m=sloper(originx,originy,x,y);

     line(originx,originy,80/sqrt(1+m*m),m*80/sqrt(1+m*m)); //THIS LINE IS WHERE THE PROBLEM IS


      delay(30);
      cleardevice();
      if(op==49)          //for exiting
        doga=2;
    }


   } 
</code></pre>
