title: How to rotate CGPoint from Landscape to Portrait UIImage orientation?
body: <p>I have a UIImageView that I draw a triangle on.  Points "A" <code>leftPost</code> &amp; "B" <code>rightPost</code> are always static and the same distance from one another.  The "tip" or point "C" is determined by tapping on the UIImageView.  While the image is in portrait mode, I have no problem recreating the UIImageView along with the coordinates of the tapped CGPoint.</p>
  
  <p>However, I need to display the UIImage in landscape mode and represent the same triangle.  How do I "rotate" my coordinates to achieve this?  I am also implying that I am NOT rotating the screen from portrait and landscape.  The app is always in landscape.</p>
  
  <pre><code>import UIKit
  
  class ViewController: UIViewController {
  
      let bezierPath = UIBezierPath()
      let shapeLayer = CAShapeLayer()
      @IBOutlet weak var imageView: UIImageView!
  
      override func viewDidLoad() {
          super.viewDidLoad()
          // Do any additional setup after loading the view, typically from a nib.
  
          let shotGesture = UITapGestureRecognizer(target: self, action: #selector(shotOnNet))
  
          imageView.addGestureRecognizer(shotGesture)
  
          //Enable tapping on screen
          imageView.isUserInteractionEnabled = true
  
      }
  
      func setupBezierPath(tip: CGPoint) {
  
          let leftPost = CGPoint(x: 20, y: 50)
          let rightPost = CGPoint(x: 100, y: 50)
  
          bezierPath.move(to: leftPost)
          bezierPath.addLine(to: rightPost)
          bezierPath.addLine(to: tip)
          bezierPath.close()
  
      }
  
      func setupShapeLayer() {
          shapeLayer.path = bezierPath.cgPath
          shapeLayer.fillColor = UIColor.red.cgColor
          shapeLayer.lineWidth = 1.0
       shapeLayer.strokeColor = UIColor.black.cgColor
      }
  
      func shotOnNet(_ sender: Any) {
  
          let shot = (sender as! UITapGestureRecognizer).location(ofTouch: 0, in: imageView)
  
          setupBezierPath(tip: shot)
          setupShapeLayer()
          imageView.layer.addSublayer(shapeLayer)
  
      }
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ssiIT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ssiIT.png" alt="enter image description here"></a></p>