title: iOS: Dynamically drawing on canvas(context)
body: <p>I'm currently making an application which draws out a certain network of signs to the screen (on a CGContextRef). So far everything is going great, but now i'm finding myself in the situation that i can't solve this problem:</p>
  
  <p>I'm trying to draw an object dynamically knowing only the line its on (have the start and ending point's x and y coordinates). With these i found the middle of the line, this is where the symbol should be drawn. With this information i found the angle of the line (with the top as 0). This is the information i have right now:</p>
  
  <pre><code>CGPoint firstLocation;
  CGPoint secondLocation;
  CGPoint middleLocation;
  
  double x1 = firstLocation.x;
  double y1 = firstLocation.y;
  double x2 = middleLocation.x;
  double y2 = middleLocation.y;
  
  float a = (atan2(y2-y1, x2-x1) * (180/M_PI)) - 90;
  </code></pre>
  
  <p>I looked at using some transform function (like CGAffineTransform) on a CGRect, but this doesn't seem to work as i need to rotate the rect around it's center and a CGRect would only rotate around it's origin.</p>
  
  <p>I want to create the following symbols with the above information:</p>
  
  <p><img src="https://i.stack.imgur.com/1hiRL.png" alt="Image"></p>
  
  <p>Any help is appreciated, and if you need any more information please tell me!</p>