We’ll draw a circle tangent to another circle today.

    override func draw(_ rect: CGRect) {
// lineSegmentBisector()
// angleBisector()
// perpendicular()
// perpendicular2()
// parallel()
// regularTriangle()
// triangle()
// circleThroughTwoPoints()
// circleThroughThreePoints()
// pythagoreanTriples()
// squareRootOfTwo()
// triangleWithHypotenuseAndSide()
circleTangentToCircle()
}

func circleTangentToCircle() {
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 100, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)
}
    func circleTangentToCircle() {
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 100, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)
let centerToCenter = UIBezierPath()
centerToCenter.move(to: CGPoint(x: 350, y: 200))
centerToCenter.addLine(to: CGPoint(x: 350, y: 350))
centerToCenter.stroke()

}
    func circleTangentToCircle() {
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 100, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)
let centerToCenter = UIBezierPath()
centerToCenter.move(to: CGPoint(x: 350, y: 200))
centerToCenter.addLine(to: CGPoint(x: 350, y: 350))
centerToCenter.stroke()

UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 50, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()

}

Don’t forget there is another case.

    func circleTangentToCircle() {
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 100, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)

let centerToCenter = UIBezierPath()
centerToCenter.move(to: CGPoint(x: 350, y: 200))
centerToCenter.addLine(to: CGPoint(x: 350, y: 350))
centerToCenter.stroke()

UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 50, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()

let centerToCenterExtended = UIBezierPath()
centerToCenterExtended.move(to: CGPoint(x: 350, y: 50))
centerToCenterExtended.addLine(to: CGPoint(x: 350, y: 350))
UIColor.green.setStroke()
centerToCenterExtended.stroke()

}
    func circleTangentToCircle() {
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 100, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)

let centerToCenter = UIBezierPath()
centerToCenter.move(to: CGPoint(x: 350, y: 200))
centerToCenter.addLine(to: CGPoint(x: 350, y: 350))
centerToCenter.stroke()

UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 50, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()

let centerToCenterExtended = UIBezierPath()
centerToCenterExtended.move(to: CGPoint(x: 350, y: 50))
centerToCenterExtended.addLine(to: CGPoint(x: 350, y: 350))
UIColor.green.setStroke()
centerToCenterExtended.stroke()

UIColor.red.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 250, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()

}

What if it’s like this originally:

    func circleTangentToCircle() {
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)

UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 250, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
}

The centre of circle we are going to draw is inside the existing circle.

    func circleTangentToCircle() {
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)

UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 250, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
let centerToCenterExtended = UIBezierPath()
centerToCenterExtended.move(to: CGPoint(x: 350, y: 50))
centerToCenterExtended.addLine(to: CGPoint(x: 350, y: 650))
UIColor.green.setStroke()
centerToCenterExtended.stroke()

}
    func circleTangentToCircle() {
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)

UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 250, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
let centerToCenterExtended = UIBezierPath()
centerToCenterExtended.move(to: CGPoint(x: 350, y: 50))
centerToCenterExtended.addLine(to: CGPoint(x: 350, y: 650))
UIColor.green.setStroke()
centerToCenterExtended.stroke()
UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 100, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
}

Don’t forget this big one:

    func circleTangentToCircle() {
drawPointAt(x: 350, y: 200)
drawPointAt(x: 350, y: 350)

UIBezierPath(arcCenter: CGPoint(x: 350, y: 350), radius: 250, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
let centerToCenterExtended = UIBezierPath()
centerToCenterExtended.move(to: CGPoint(x: 350, y: 50))
centerToCenterExtended.addLine(to: CGPoint(x: 350, y: 650))
UIColor.green.setStroke()
centerToCenterExtended.stroke()
UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 100, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()
UIColor.red.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 350, y: 200), radius: 400, startAngle: 0, endAngle: 2 * CGFloat.pi, clockwise: true).stroke()

}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store