100 XC = 160: YC = 80: RC = 60 110 SCREEN 0: WIDTH 80 120 PI = 3.1415926535# 125 RANDOMIZE TIMER 130 BLK\$ = " " 132 CLS : COLOR 12: PRINT "DELTOID": PRINT 134 COLOR 5: PRINT "THE DELTOID IS A HYPOCYCLOID FORMED BY A CIRCLE OF RADIUS R" 136 PRINT "ROLLING ON THE INSIDE OF A CIRCLE OF RADIUS 3R." 138 COLOR 14: PRINT : PRINT "THE DELTOID HAS ANOTHER INTERESTING PROPERTY: IT IS THE" 140 PRINT "ENVELOPE OF ALL THE SIMSON'S LINES OF A TRIANGLE" 142 COLOR 10: PRINT : PRINT "SIMSON'S LINES ARE GENERATED THUS:" 144 PRINT "PICK A POINT ON THE CIRCUMFERENCE OF THE CIRCUMCIRCLE OF THE TRIANGLE." 146 PRINT "FROM THIS POINT, DROP PERPENDICULARS TO EACH OF THE THREE SIDES." 148 PRINT "EXTEND THE SIDES, IF NECESSARY. THE FEET OF THE THREE PERPENDICULARS" 150 PRINT "WILL LIE ON A STRAIGHT LINE." 152 COLOR 3: PRINT : PRINT "THIS LINE IS A SIMSON'S LINE." 154 PRINT : PRINT "ALTITUDES OF THE TRIANGLE ARE SIMSON'S LINES FOR SOME POINT (WHY?)" 156 PRINT : PRINT "EDGES OF THE TRIANGLE ARE SIMSON'S LINES FOR SOME POINT (WHY?)" 158 COLOR 6: PRINT : PRINT "ALL THE SIMSON'S LINES OF A GIVEN TRIANGLE TRACE OUT THE DELTOID." 160 COLOR 4: PRINT : PRINT "PRESS ANY KEY TO CONTINUE" 162 U\$ = INPUT\$(1) 163 CLS 166 COLOR 13: PRINT : PRINT "THE DELTOID ALWAYS HAS REGULAR THREE-FOLD SYMMETRY REGARDLESS OF HOW" 168 PRINT "ASYMETRICAL THE GENERATING TRIANGLE IS" 172 COLOR 11: PRINT : PRINT "THERE'S ONE OTHER SURPRISING THREEFOLD SYMMETRY HERE. IF YOU TRISECT" 173 PRINT "THE ANGLES OF THE GENERATING TRIANGLE, LOCATE THE INTERSECTIONS OF" 175 PRINT "ADJACENT TRISECTORS, AND CONNECT THOSE THREE POINTS, YOU GET A TRIANGLE" 176 PRINT "CALLED MORLEY'S TRIANGLE. MORLEY'S TRIANGLE IS ALWAYS EQUILATERAL" 177 PRINT "REGARDLESS OF THE SHAPE OF THE GENERATING TRIANGLE. THE VERTICES OF" 178 PRINT "MORLEY'S TRIANGLE POINT AWAY FROM THE CUSPS OF THE DELTOID." 182 COLOR 12: PRINT : PRINT "PROVING THIS MUST HAVE BEEN A BEAR. PROVING THAT AN ENVELOPE RESULTS" 183 PRINT "IN A GIVEN CURVE IS FAIRLY COMPLEX CALCULUS. THE MATHEMATICS OF SIMSON'S" 185 PRINT "LINE IS COMPLEX. PUTTING THE TWO TOGETHER MUST HAVE BEEN A REAL BEAST." 186 COLOR 14: PRINT : PRINT "THE PROOF WAS ESTABLISHED BY J. STEINER IN 1858. STEINER IS ALSO" 187 PRINT "REMEMBERED FOR STEINER CHAINS, ANOTHER VERY SUBTLE GEOMETRICAL TIDBIT." 188 PRINT "STEINER MUST HAVE HAD A REAL LOVE FOR GEOMETRY AS WELL AS DIFFICULT PROOFS" 189 COLOR 10: PRINT : PRINT "THE DELTOID AS ENVELOPE OF SIMSON'S LINE IS SOMETIMES (JUSTLY)" 190 PRINT "CALLED STEINER'S HYPOCYCLOID" 198 COLOR 4: PRINT : PRINT "PRESS ANY KEY TO CONTINUE" 200 U\$ = INPUT\$(1) 201 CLS : COLOR 14: PRINT "IT IS VERY HARD TO PREDICT JUST WHERE A GIVEN LINE INTERSECTS" 202 PRINT "THE DELTOID. THE ALGORITHM IN THIS PROGRAM CALCULATES SIMSON'S LINE" 203 PRINT "BETWEEN THE FEET OF THE PERPENDICULARS AND EXTENDS IT SOME DISTANCE" 204 PRINT "BEYOND. THEREFORE THE SIMSON'S LINES EXTEND BEYOND THE DELTOID" 205 COLOR 12: PRINT : PRINT "IF YOU CONSTRUCT YOUR OWN TRIANGLE, THE LINES MAY NOT BE LONG" 206 PRINT "ENOUGH IF THE TRIANGLE IS VERY SMALL OR NARROW. IN SUCH CASES PART" 207 PRINT "OF THE DELTOID WILL BE CUT OFF. FOR BEST RESULTS PICK TRIANGLES" 208 PRINT "THAT INCLUDE THE CENTER OF THE CIRCUMCIRCLE" 218 COLOR 11: PRINT : PRINT "TYPE D TO SEE A DEMONSTRATION OF SIMSON'S LINE" 219 PRINT "OR ANY OTHER KEY TO CONSTRUCT THE DELTOID" 220 U\$ = INPUT\$(1) 225 IF U\$ <> "D" AND U\$ <> "d" THEN 4000 230 REM RUN DEMO 240 GOSUB 5000 245 SCREEN 1 255 GOSUB 4500 260 GOSUB 5200 3000 REM DEMONSTRATE SIMSON'S LINE 3010 LOCATE 22, 1: PRINT "START WITH A TRIANGLE" 3020 LOCATE 23, 1: PRINT "PRESS ANY KEY FOR NEXT STEP" 3030 U\$ = INPUT\$(1) 3040 GOSUB 5200: REM DRAW TRIANGLE 3050 LOCATE 22, 1: PRINT BLK\$ 3060 LOCATE 22, 1: PRINT "CONSTRUCT CIRCUMCIRCLE" 3070 REM DRAW CIRCUMCIRCLE 3080 CX = XCC: CY = YCC: RAD = RO: CC = 3: GOSUB 9200 3090 U\$ = INPUT\$(1) 3100 T = 2 * PI * RND(1): XSG = XCC + RO * COS(T): YSG = YCC + RO * SIN(T) 3110 LOCATE 21, 1: PRINT "SELECT A POINT ON CIRCUMCIRCLE" 3120 LOCATE 22, 1: PRINT "OR ENTER FOR RANDOM POINT " 3130 LOCATE 23, 1: INPUT "INPUT AZIMUTH OF POINT "; AZ\$ 3140 IF AZ\$ = "" THEN 3160 3150 AZ = PI * VAL(AZ\$) / 180: XSG = XCC + RO * COS(AZ): YSG = YCC + RO * SIN(AZ) 3160 REM END IF 3170 LINE (XSG - 2, YSG - 2)-(XSG + 2, YSG + 2), 3, B 3180 LOCATE 21, 1: PRINT BLK\$ 3190 LOCATE 22, 1: PRINT "POINT SELECTED " 3220 LOCATE 23, 1: PRINT "PRESS ANY KEY FOR NEXT STEP " 3230 U\$ = INPUT\$(1) 3270 REM CALCULATIONS FOR GENERATION 3300 GOSUB 12000 3500 REM NOW DROP PERPENDICULARS 3510 LOCATE 21, 1: PRINT BLK\$ 3515 LOCATE 22, 1: PRINT BLK\$: LOCATE 23, 1: PRINT BLK\$ 3520 LOCATE 22, 1: PRINT "DROPPING PERPENDICULARS TO SIDES" 3530 LOCATE 23, 1: PRINT "PRESS ANY KEY FOR NEXT STEP " 3540 REM SHOW PERPENDICULARS 3550 LINE (XSG, YSG)-(XSL12, YSL12), 1, , 13107 3560 LINE (XSG, YSG)-(XSL23, YSL23), 1, , 13107 3570 LINE (XSG, YSG)-(XSL31, YSL31), 1, , 13107 3571 LINE (X1, Y1)-(XSL12, YSL12), 2, , 3855 3575 LINE (X2, Y2)-(XSL23, YSL23), 2, , 3855 3577 LINE (X3, Y3)-(XSL31, YSL31), 2, , 3855 3580 LINE (XSL23 - 2, YSL23 - 2)-(XSL23 + 2, YSL23 + 2), 3, B 3582 LINE (XSL31 - 2, YSL31 - 2)-(XSL31 + 2, YSL31 + 2), 3, B 3585 LINE (XSL12 - 2, YSL12 - 2)-(XSL12 + 2, YSL12 + 2), 3, B 3590 U\$ = INPUT\$(1) 3595 LOCATE 22, 1: PRINT BLK\$: LOCATE 23, 1: PRINT BLK\$ 3600 LOCATE 22, 1: PRINT "DRAWING SIMSON'S LINE" 3603 LOCATE 23, 1: PRINT "PRESS ANY KEY FOR NEXT STEP" 3620 LINE (XSL31, YSL31)-(XSL23, YSL23), 3 3630 LINE (XSL31, YSL31)-(XSL12, YSL12), 3 3640 REM NOW SHOW SIMSON'S LINE 3650 U\$ = INPUT\$(1) 3670 LOCATE 22, 1: PRINT BLK\$ 3675 LOCATE 23, 1: PRINT BLK\$ 3680 LOCATE 22, 1: PRINT "ANOTHER DEMO WITH THIS" 3685 LOCATE 23, 1: PRINT "DIAGRAM - Y/N ?": U\$ = INPUT\$(1) 3710 IF U\$ = "N" OR U\$ = "n" THEN 3717 3715 CLS : GOSUB 5200: GOTO 3000 3717 REM END IF 3720 LOCATE 22, 1: PRINT BLK\$ 3725 LOCATE 23, 1: PRINT BLK\$ 3730 LOCATE 22, 1: PRINT "DRAW A DIFFERENT" 3735 LOCATE 23, 1: PRINT "DIAGRAM - Y/N ?": U\$ = INPUT\$(1) 3740 IF U\$ = "N" OR U\$ = "n" THEN 3760 3745 GOSUB 5000 3747 GOSUB 4500 3750 CLS : GOSUB 5200: GOTO 3000 3760 REM END IF 4000 REM MAIN DISPLAY 4005 SCREEN 1: CLS 4010 LOCATE 23, 1: PRINT "USER- OR COMPUTER-GENERATED - U/C?": U\$ = INPUT\$(1) 4015 GOSUB 5000 4020 IF U\$ = "U" OR U\$ = "u" THEN GOSUB 5300 4025 CLS 4030 REM DRAW TRIANGLE 4035 GOSUB 5200 4040 GOSUB 4500 4045 REM 4050 REM DRAW CIRCUMCIRCLE 4055 CX = XCC: CY = YCC: RAD = RO: CC = 2: GOSUB 9200 4060 FOR T = 0 TO 2 * PI STEP PI / 20 4065 XSG = XCC + RO * COS(T): YSG = YCC + RO * SIN(T) 4070 GOSUB 12000 4075 LF = (ABS(XSL12 - XSL23) + ABS(YSL12 - YSL23)) 4077 IF LF = 0 THEN LF = 2 ELSE LF = 80 / LF 4080 XP1 = (LF + 1) * XSL12 - LF * XSL23: YP1 = (LF + 1) * YSL12 - LF * YSL23 4085 XP2 = (LF + 1) * XSL23 - LF * XSL12: YP2 = (LF + 1) * YSL23 - LF * YSL12 4090 LINE (XP1, YP1)-(XP2, YP2), 3 4092 LF = (ABS(XSL31 - XSL23) + ABS(YSL31 - YSL23)) 4095 IF LF = 0 THEN LF = 2 ELSE LF = 80 / LF 4100 XP1 = (LF + 1) * XSL31 - LF * XSL23: YP1 = (LF + 1) * YSL31 - LF * YSL23 4105 XP2 = (LF + 1) * XSL23 - LF * XSL31: YP2 = (LF + 1) * YSL23 - LF * YSL31 4110 LINE (XP1, YP1)-(XP2, YP2), 3 4115 LF = (ABS(XSL12 - XSL31) + ABS(YSL12 - YSL31)) 4117 IF LF = 0 THEN LF = 2 ELSE LF = 80 / LF 4120 XP1 = (LF + 1) * XSL31 - LF * XSL12: YP1 = (LF + 1) * YSL31 - LF * YSL12 4125 XP2 = (LF + 1) * XSL12 - LF * XSL31: YP2 = (LF + 1) * YSL12 - LF * YSL31 4130 LINE (XP1, YP1)-(XP2, YP2), 3 4135 NEXT T 4140 LOCATE 23, 1: PRINT "PRESS ANY KEY TO CONTINUE" 4145 U\$ = INPUT\$(1) 4150 CLS : LOCATE 1, 1: PRINT "AND NOW, BART SIMPSON'S LINE..." 4155 LINE (100, 100)-(100, 50), 3 4160 LINE (100, 50)-(120, 70), 3 4165 LINE (120, 70)-(140, 50), 3 4170 LINE (140, 50)-(160, 70), 3 4175 LINE (160, 70)-(180, 50), 3 4180 LINE (180, 50)-(200, 70), 3 4185 LINE (200, 70)-(220, 50), 3 4190 LINE (220, 100)-(220, 50), 3 4195 LOCATE 14, 10: PRINT "DON'T HAVE A COW, MAN" 4200 LOCATE 22, 1: PRINT "TYPE Q TO QUIT" 4210 LOCATE 23, 1: PRINT "PRESS OR ANY OTHER KEY TO CONTINUE" 4220 U\$ = INPUT\$(1) 4225 IF U\$ = "Q" OR U\$ = "q" THEN 4240 4230 SCREEN 0: WIDTH 80: CLS 4235 GOTO 218 4240 SCREEN 0: WIDTH 80: CLS 4290 END 4500 REM CALCULATE PARTS OF TRIANGLE 4510 S12 = SQR((X2 - X1) ^ 2 + (Y2 - Y1) ^ 2) 4512 IF S12 = 0 THEN S12 = .01 4515 S23 = SQR((X3 - X2) ^ 2 + (Y3 - Y2) ^ 2) 4517 IF S12 = 0 THEN S12 = .01 4520 S31 = SQR((X1 - X3) ^ 2 + (Y1 - Y3) ^ 2) 4522 IF S12 = 0 THEN S12 = .01 4525 S = (S12 + S23 + S31) / 2 4530 RI = SQR((S - S12) * (S - S23) * (S - S31) / S) 4535 A12 = 2 * ATN(RI / (S - S12)) 4540 A23 = 2 * ATN(RI / (S - S23)) 4545 A31 = 2 * ATN(RI / (S - S31)) 4565 REM CENTROID 4570 XCTD = (X1 + X2 + X3) / 3: YCTD = (Y1 + Y2 + Y3) / 3 4580 REM CENTROID 4600 REM PRINCIPAL LINES OF TRIANGLE 4625 REM CALCULATE CIRCUMCIRCLE 4630 P1 = X1: Q1 = Y1: P2 = X2: Q2 = Y2: P3 = X3: Q3 = Y3: GOSUB 8700 4635 XCC = PCC: YCC = QCC: RO = RCC 4690 RETURN 5000 REM COMPUTER CREATED TRIANGLE 5005 A = 2 * PI * RND(1) 5010 T = A + PI * RND(1) / 2: X1 = RC * COS(T): Y1 = RC * SIN(T) 5020 T = A + PI * (2 + RND(1)) / 2: X2 = RC * COS(T): Y2 = RC * SIN(T) 5025 T = A + PI * RND(1) / 2: X1 = RC * COS(T): Y1 = RC * SIN(T) 5030 T = A + PI * (4 + RND(1)) / 2: X3 = RC * COS(T): Y3 = RC * SIN(T) 5040 XCTD = (X1 + X2 + X3) / 3: YCTD = (Y1 + Y2 + Y3) / 3 5050 X1 = X1 - XCTD + XC: Y1 = Y1 - YCTD + YC: X2 = X2 - XCTD + XC: Y2 = Y2 - YCTD + YC 5060 X3 = X3 - XCTD + XC: Y3 = Y3 - YCTD + YC 5090 RETURN 5200 REM DRAW TRIANGLE 5210 LINE (X1, Y1)-(X2, Y2), 2 5220 LINE (X3, Y3)-(X2, Y2), 2 5230 LINE (X1, Y1)-(X3, Y3), 2 5290 RETURN 5300 REM USER CREATED TRIANGLE 5310 CLS : CX = XC: CY = YC: RAD = RC: CC = 1: GOSUB 9200 5320 LOCATE 21, 1: INPUT "INPUT AZIMUTH 1 "; AZ\$ 5325 AZ1 = VAL(AZ\$) * PI / 180 5330 X1 = XC + RC * COS(AZ1): Y1 = YC - RC * SIN(AZ1) 5335 LINE (X1 - 2, Y1 - 2)-(X1 + 2, Y1 + 2), 2, B 5350 LOCATE 22, 1: INPUT "INPUT AZIMUTH 2 "; AZ\$ 5355 AZ2 = VAL(AZ\$) * PI / 180 5360 IF SIN(AZ2) = SIN(AZ1) AND COS(AZ2) = COS(AZ1) THEN 5350 5365 X2 = XC + RC * COS(AZ2): Y2 = YC - RC * SIN(AZ2) 5370 LINE (X1, Y1)-(X2, Y2) 5375 LINE (X2 - 2, Y2 - 2)-(X2 + 2, Y2 + 2), 2, B 5390 LOCATE 23, 1: INPUT "INPUT AZIMUTH 3 "; AZ\$ 5395 AZ3 = VAL(AZ\$) * PI / 180 5400 IF SIN(AZ3) = SIN(AZ1) AND COS(AZ3) = COS(AZ1) THEN 5390 5405 IF SIN(AZ3) = SIN(AZ2) AND COS(AZ3) = COS(AZ2) THEN 5390 5415 X3 = XC + RC * COS(AZ3): Y3 = YC - RC * SIN(AZ3) 5425 LINE (X3 - 2, Y3 - 2)-(X3 + 2, Y3 + 2), 2, B 5430 LINE (X2, Y2)-(X3, Y3) 5435 LINE (X3, Y3)-(X1, Y1) 5450 REM RESET TRIANGLE 5455 DX = XC - (X1 + X2 + X3) / 3 5460 DY = (Y1 + Y2 + Y3) / 3 - YC 5470 X1 = X1 - DX: Y1 = Y1 - DY 5475 X2 = X2 - DX: Y2 = Y2 - DY 5480 X3 = X3 - DX: Y3 = Y3 - DY 5590 RETURN 8700 REM COMPUTE CIRCUMCENTER PCC,QCC FOR P1,Q1 P2,Q2 P3,Q3 8705 A = (P1 * (Q2 - Q3) + P2 * (Q3 - Q1) + P3 * (Q1 - Q2)) 8710 R1 = (P1 * P1 + Q1 * Q1): R2 = (P2 * P2 + Q2 * Q2): R3 = (P3 * P3 + Q3 * Q3) 8715 D = -(R1 * (Q2 - Q3) + R2 * (Q3 - Q1) + R3 * (Q1 - Q2)) / (2 * A) 8720 E = (R1 * (P2 - P3) + R2 * (P3 - P1) + R3 * (P1 - P2)) / (2 * A) 8725 F = -(R1 * (P2 * Q3 - P3 * Q2) + R2 * (P3 * Q1 - P1 * Q3) + R3 * (P1 * Q2 - P2 * Q1)) / A 8730 RCC = SQR(D * D + E * E - F): PCC = -D: QCC = -E 8740 RETURN 9200 REM DRAW CIRCLES 9230 X00 = RAD: Y00 = 0: FOR T = 0 TO .52 * PI STEP .02 * PI 9235 X01 = RAD * COS(T): Y01 = RAD * SIN(T) 9237 LINE (CX + X00, CY + Y00)-(CX + X01, CY + Y01), CC: LINE (CX - X00, CY + Y00)-(CX - X01, CY + Y01), CC 9240 LINE (CX + X00, CY - Y00)-(CX + X01, CY - Y01), CC: LINE (CX - X00, CY - Y00)-(CX - X01, CY - Y01), CC 9242 X00 = X01: Y00 = Y01: NEXT T 9290 RETURN 12000 REM SIMSON'S LINE 12100 REM GENERATE SIMSON'S LINE GIVEN XSG,YSG 12175 S1 = S12: S2 = SQR((XSG - X1) ^ 2 + (YSG - Y1) ^ 2): S3 = SQR((XSG - X2) ^ 2 + (YSG - Y2) ^ 2) 12180 S = (S1 + S2 + S3) / 2 12181 IF S = S1 THEN S = S + .01 12182 IF S = S2 THEN S = S + .01 12183 IF S = S3 THEN S = S + .01 12184 A1 = 2 * ATN(SQR((S - S2) * (S - S3) / (S * (S - S1)))) 12185 A2 = 2 * ATN(SQR((S - S3) * (S - S1) / (S * (S - S2)))) 12190 A3 = 2 * ATN(SQR((S - S1) * (S - S2) / (S * (S - S3)))) 12195 XSL12 = (X1 * S3 * COS(A2) + X2 * S2 * COS(A3)) / S1 12200 YSL12 = (Y1 * S3 * COS(A2) + Y2 * S2 * COS(A3)) / S1 12210 S1 = S23: S2 = SQR((XSG - X2) ^ 2 + (YSG - Y2) ^ 2): S3 = SQR((XSG - X3) ^ 2 + (YSG - Y3) ^ 2) 12215 S = (S1 + S2 + S3) / 2: A1 = 2 * ATN(SQR((S - S2) * (S - S3) / (S * (S - S1)))) 12220 A2 = 2 * ATN(SQR((S - S3) * (S - S1) / (S * (S - S2)))) 12225 A3 = 2 * ATN(SQR((S - S1) * (S - S2) / (S * (S - S3)))) 12230 XSL23 = (X2 * S3 * COS(A2) + X3 * S2 * COS(A3)) / S1 12235 YSL23 = (Y2 * S3 * COS(A2) + Y3 * S2 * COS(A3)) / S1 12250 S1 = S31: S2 = SQR((XSG - X3) ^ 2 + (YSG - Y3) ^ 2): S3 = SQR((XSG - X1) ^ 2 + (YSG - Y1) ^ 2) 12251 S = (S1 + S2 + S3) / 2: 12252 IF S = S1 THEN S = S + .01 12253 IF S = S2 THEN S = S + .01 12254 IF S = S3 THEN S = S + .01 12255 A1 = 2 * ATN(SQR((S - S2) * (S - S3) / (S * (S - S1)))) 12260 A2 = 2 * ATN(SQR((S - S3) * (S - S1) / (S * (S - S2)))) 12265 A3 = 2 * ATN(SQR((S - S1) * (S - S2) / (S * (S - S3)))) 12270 XSL31 = (X3 * S3 * COS(A2) + X1 * S2 * COS(A3)) / S1 12275 YSL31 = (Y3 * S3 * COS(A2) + Y1 * S2 * COS(A3)) / S1 12295 RETURN