Golden Thumb Parenting Tips [013]
Draw perpendicular in Xcode
School Geometry with Ruler, Compass and Coding (04) Parallel
School Geometry with Ruler, Compass and Coding (05) Triangle
School Geometry with Ruler, Compass and Coding (06) Circle through three points
School Geometry with Ruler, Compass and Coding (07) Pythagorean theorem
School Geometry with Ruler, Compass and Coding (08) Irrational numbers √2
School Geometry with Ruler, Compass and Coding (09) Right triangle from given hypotenuse and one side
School Geometry with Ruler, Compass and Coding (10) Circle tangent to circle
We created the Xcode project RulerCompass in Ruler and Compass (01), and demonstrated line segment bisector in Ruler and Compass (02).
First, let draw a perpendicular through a point on an existing line.
override func draw(_ rect: CGRect) {
// lineSegmentBisector()
// angleBisector()
perpendicular()
}
func perpendicular() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 500, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
}
func perpendicular() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 500, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
let compassPath1 = UIBezierPath()
compassPath1.addArc(withCenter: CGPoint(x: 400, y: 350), radius: 100, startAngle: -0.1 * CGFloat.pi, endAngle: 0.1 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath1.stroke()
let compassPath2 = UIBezierPath()
compassPath2.addArc(withCenter: CGPoint(x: 400, y: 350), radius: 100, startAngle: 0.9 * CGFloat.pi, endAngle: 1.1 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath2.stroke()
}
func perpendicular() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 500, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
let compassPath1 = UIBezierPath()
compassPath1.addArc(withCenter: CGPoint(x: 400, y: 350), radius: 100, startAngle: -0.1 * CGFloat.pi, endAngle: 0.1 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath1.stroke()
let compassPath2 = UIBezierPath()
compassPath2.addArc(withCenter: CGPoint(x: 400, y: 350), radius: 100, startAngle: 0.9 * CGFloat.pi, endAngle: 1.1 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath2.stroke()
let compassPath3 = UIBezierPath()
compassPath3.addArc(withCenter: CGPoint(x: 300, y: 350), radius: 300, startAngle: -0.5 * CGFloat.pi, endAngle: -0.25 * CGFloat.pi, clockwise: true)
UIColor.green.setStroke()
compassPath3.stroke()
let compassPath4 = UIBezierPath()
compassPath4.addArc(withCenter: CGPoint(x: 500, y: 350), radius: 300, startAngle: -0.5 * CGFloat.pi, endAngle: -0.75 * CGFloat.pi, clockwise: false)
UIColor.green.setStroke()
compassPath4.stroke()
}
func perpendicular() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 500, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 350 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 350 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
let compassPath1 = UIBezierPath()
compassPath1.addArc(withCenter: CGPoint(x: 400, y: 350), radius: 100, startAngle: -0.1 * CGFloat.pi, endAngle: 0.1 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath1.stroke()
let compassPath2 = UIBezierPath()
compassPath2.addArc(withCenter: CGPoint(x: 400, y: 350), radius: 100, startAngle: 0.9 * CGFloat.pi, endAngle: 1.1 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath2.stroke()
let compassPath3 = UIBezierPath()
compassPath3.addArc(withCenter: CGPoint(x: 300, y: 350), radius: 300, startAngle: -0.5 * CGFloat.pi, endAngle: -0.25 * CGFloat.pi, clockwise: true)
UIColor.green.setStroke()
compassPath3.stroke()
let compassPath4 = UIBezierPath()
compassPath4.addArc(withCenter: CGPoint(x: 500, y: 350), radius: 300, startAngle: -0.5 * CGFloat.pi, endAngle: -0.75 * CGFloat.pi, clockwise: false)
UIColor.green.setStroke()
compassPath4.stroke()
let bisectorPath = UIBezierPath()
bisectorPath.move(to: CGPoint(x: 400, y: 50))
bisectorPath.addLine(to: CGPoint(x: 400, y: 600))
bisectorPath.lineWidth = 2
UIColor.red.setStroke()
bisectorPath.stroke()
}
Second, let draw a perpendicular through a point outside an existing line.
override func draw(_ rect: CGRect) {
// lineSegmentBisector()
// angleBisector()
// perpendicular()
perpendicular2()
}
func perpendicular2() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 600, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
}
func perpendicular2() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 600, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
let compassPath1 = UIBezierPath()
compassPath1.addArc(withCenter: CGPoint(x: 400, y: 200), radius: 200, startAngle: 0.25 * CGFloat.pi, endAngle: 0.75 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath1.stroke()
}
func perpendicular2() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 600, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
let compassPath1 = UIBezierPath()
compassPath1.addArc(withCenter: CGPoint(x: 400, y: 200), radius: 150 * sqrt(2), startAngle: 0.2 * CGFloat.pi, endAngle: 0.8 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath1.stroke()
let compassPath2 = UIBezierPath()
compassPath2.addArc(withCenter: CGPoint(x: 400 + 150, y: 350), radius: 300, startAngle: 0.5 * CGFloat.pi, endAngle: 0.75 * CGFloat.pi, clockwise: true)
UIColor.green.setStroke()
compassPath2.stroke()
let compassPath3 = UIBezierPath()
compassPath3.addArc(withCenter: CGPoint(x: 400 - 150, y: 350), radius: 300, startAngle: 0.25 * CGFloat.pi, endAngle: 0.5 * CGFloat.pi, clockwise: true)
UIColor.green.setStroke()
compassPath3.stroke()
}
func perpendicular2() {
let linePath = UIBezierPath()
linePath.move(to: CGPoint(x: 200, y: 350))
linePath.addLine(to: CGPoint(x: 600, y: 350))
linePath.lineWidth = 3
linePath.stroke()
let pointPath = UIBezierPath()
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 - 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 + 10))
pointPath.move(to: CGPoint(x: 400 - 10, y: 200 + 10))
pointPath.addLine(to: CGPoint(x: 400 + 10, y: 200 - 10))
pointPath.lineWidth = 1
pointPath.stroke()
let compassPath1 = UIBezierPath()
compassPath1.addArc(withCenter: CGPoint(x: 400, y: 200), radius: 150 * sqrt(2), startAngle: 0.2 * CGFloat.pi, endAngle: 0.8 * CGFloat.pi, clockwise: true)
UIColor.brown.setStroke()
compassPath1.stroke()
let compassPath2 = UIBezierPath()
compassPath2.addArc(withCenter: CGPoint(x: 400 + 150, y: 350), radius: 300, startAngle: 0.5 * CGFloat.pi, endAngle: 0.75 * CGFloat.pi, clockwise: true)
UIColor.green.setStroke()
compassPath2.stroke()
let compassPath3 = UIBezierPath()
compassPath3.addArc(withCenter: CGPoint(x: 400 - 150, y: 350), radius: 300, startAngle: 0.25 * CGFloat.pi, endAngle: 0.5 * CGFloat.pi, clockwise: true)
UIColor.green.setStroke()
compassPath3.stroke()
let bisectorPath = UIBezierPath()
bisectorPath.move(to: CGPoint(x: 400, y: 50))
bisectorPath.addLine(to: CGPoint(x: 400, y: 700))
bisectorPath.lineWidth = 2
UIColor.red.setStroke()
bisectorPath.stroke()
}
[001] Golden Thumb who?
[002] Play 24 Game if kids know + − × ÷
[003] Kids love challenges. Don’t ruin their day with quick answers.
[004] Finger gymnastics on keyboard
[005] Install Xcode on mac and create an empty runnable app
[006] Install Eclipse on Windows PC and create Hello World app
[007] Draw and fill shapes with Java in Eclipse
[008] Use straightedge and compass correctly
[009] Ongoing stories of An
[010] 让数学与编程伴随孩子成长
[011] Line segment bisector in Xcode
[012] Angle bisector in Xcode
[013] Draw perpendicular in Xcode
[019] Ongoing stories of Peter
[029] Ongoing stories of Nicole
[039] Ongoing stories of Willa
[059] Ongoing stories of Ethan
[049] Ongoing stories of Lucas
[069] Ongoing stories of Lambert
[079] Ongoing stories of Felix
[089] Ongoing stories of Hal
[099] Ongoing stories of Michael
[109] Ongoing stories of Marius
[119] Ongoing stories of Bowen
[129] Ongoing stories of Oliver
[139] Ongoing stories of Grace
[149] Ongoing stories of Ryan
[159] Ongoing stories of Angie
[169] Ongoing stories of Elaine
[179] Ongoing stories of Andy