title: How to calculate pixel coordinates having start (x,y) , length in pixel and angle?
body: <br>
  I have an image 640 x 640 and I'd like to draw the line on it. Common task where package like PIL allows me to write a line using 
  <p><code>line(x1,y1,x2,y2)</code></p>
  <p>where x1,y1 is start the and x2,y2 is end line coordinates. I have a different task where I have x1,y1 and line length in pixels with angle of direction. How to calculate x2,y2 having those data only?<br>
  Thanks
  Erick
  <br><br>
  As per stackoverflow.com Admins advice I'm modifying this comment instead of posting answer separately below to provide code to my question plus one doubt that this code works with 0 (zero) angle drawing straight line towards right hand site as it should however 90 degree angle looks like more 110 or something as per picture. What am I doing wrong ? Thanks again in advance.</p>
  <pre><code>import math
  from PIL import Image, ImageDraw
  
  def calc_x2y2(length, angle, x1,y1):
      x2 = x1 + math.cos(angle)*length
      y2 = y1 + math.sin(angle)*length
      return (x2,y2)
  
  w, h = 640, 640
  x1,y1 = w/2, h/2
  shape = [(x1,y1), calc_x2y2(300,90,x1,y1)]
  # creating new Image object
  img = Image.new(&quot;RGB&quot;, (w, h),(225,225,225))
  # create line on the image
  img1 = ImageDraw.Draw(img)
  img1.line(shape, fill=&quot;#401eba&quot;, width=5)
  img.show()
  </code></pre>
  <p><a href="https://i.stack.imgur.com/taJoX.png" rel="nofollow noreferrer">Straight line that should be 90 degree except it's not</a></p>