We kick off with two line segments, the longer one for hypotenuse while the shorter one for one of the other sides.

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

func triangleWithHypotenuseAndSide() {
horizontalLineSegment(fromX: 100, toX: 250, y: 100)
horizontalLineSegment(fromX: 100, toX: 300, y: 150)
}

Make two perpendiculars:

    func triangleWithHypotenuseAndSide() {
horizontalLineSegment(fromX: 100, toX: 250, y: 100)
horizontalLineSegment(fromX: 100, toX: 300, y: 150)

perpendicular()
}

Use the shorter length to cut on the horizontal line of the perpendicular cross:

    func triangleWithHypotenuseAndSide() {
horizontalLineSegment(fromX: 100, toX: 250, y: 100)
horizontalLineSegment(fromX: 100, toX: 300, y: 150)

perpendicular()

UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 400, y: 350), radius: 150, startAngle: -1.1 * CGFloat.pi, endAngle: -0.9 * CGFloat.pi, clockwise: true).stroke()

}
    func triangleWithHypotenuseAndSide() {
horizontalLineSegment(fromX: 100, toX: 250, y: 100)
horizontalLineSegment(fromX: 100, toX: 300, y: 150)

perpendicular()

UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 400, y: 350), radius: 150, startAngle: -1.1 * CGFloat.pi, endAngle: -0.9 * CGFloat.pi, clockwise: true).stroke()
UIBezierPath(arcCenter: CGPoint(x: 250, y: 350), radius: 200, startAngle: 0.1 * CGFloat.pi, endAngle: 0.3 * CGFloat.pi, clockwise: true).stroke()
}
func triangleWithHypotenuseAndSide() {
horizontalLineSegment(fromX: 100, toX: 250, y: 100)
horizontalLineSegment(fromX: 100, toX: 300, y: 150)

perpendicular()

UIColor.blue.setStroke()
UIBezierPath(arcCenter: CGPoint(x: 400, y: 350), radius: 150, startAngle: -1.1 * CGFloat.pi, endAngle: -0.9 * CGFloat.pi, clockwise: true).stroke()
UIBezierPath(arcCenter: CGPoint(x: 250, y: 350), radius: 200, startAngle: 0.1 * CGFloat.pi, endAngle: 0.3 * CGFloat.pi, clockwise: true).stroke()

let hypotenuse = UIBezierPath()
hypotenuse.move(to: CGPoint(x: 250, y: 350))
hypotenuse.addLine(to: CGPoint(x: 400, y: 350 + sqrt(17500))) // 200 * 200 - 150 * 150 = 17500
UIColor.brown.setStroke()
hypotenuse.lineWidth = 3
hypotenuse.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