I need to know the distance a point on the circumference of a wheel travels in one revolution. The following code shows what I'm after clearly, except for that distance.
Code:
#PBFORMS CREATED V1.51 '-------------------------------------------------------------------------------------------------- ' The first line in this file is a PB/Forms metastatement. ' It should ALWAYS be the first line of the file. Other ' PB/Forms metastatements are placed at the beginning and ' end of "Named Blocks" of code that should be edited ' with PBForms only. Do not manually edit or delete these ' metastatements or PB/Forms will not be able to reread ' the file correctly. See the PB/Forms documentation for ' more information. ' Named blocks begin like this: #PBFORMS BEGIN ... ' Named blocks end like this: #PBFORMS END ... ' Other PB/Forms metastatements such as: ' #PBFORMS DECLARATIONS ' are used by PB/Forms to insert additional code. ' Feel free to make changes anywhere else in the file. '-------------------------------------------------------------------------------------------------- #COMPILE EXE #DIM ALL '-------------------------------------------------------------------------------------------------- ' ** Includes ** '-------------------------------------------------------------------------------------------------- #PBFORMS BEGIN INCLUDES %USEMACROS = 1 #IF NOT %DEF(%WINAPI) #INCLUDE "WIN32API.INC" #ENDIF #IF NOT %DEF(%COMMCTRL_INC) #INCLUDE "COMMCTRL.INC" #ENDIF #INCLUDE "PBForms.INC" #PBFORMS END INCLUDES '-------------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------------- ' ** Constants ** '-------------------------------------------------------------------------------------------------- #PBFORMS BEGIN CONSTANTS %IDCANCEL = 2 %IDD_DIALOG1 = 101 %IDC_LABEL1 = 1001 %IDC_LABEL2 = 1002 %IDC_LABEL3 = 1003 %IDC_LABEL4 = 1004 %IDC_GRAPHIC1 = 1005 %IDC_START = 1006 #PBFORMS END CONSTANTS '-------------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------------- ' ** Declarations ** '-------------------------------------------------------------------------------------------------- DECLARE CALLBACK FUNCTION ShowDIALOG1Proc() DECLARE FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG #PBFORMS DECLARATIONS '-------------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------------- ' ** Main Application Entry Point ** '-------------------------------------------------------------------------------------------------- FUNCTION PBMAIN() PBFormsInitComCtls (%ICC_WIN95_CLASSES OR %ICC_DATE_CLASSES OR %ICC_INTERNET_CLASSES) ShowDIALOG1 %HWND_DESKTOP END FUNCTION '-------------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------------- ' ** CallBacks ** '-------------------------------------------------------------------------------------------------- CALLBACK FUNCTION ShowDIALOG1Proc() STATIC pi AS DOUBLE LOCAL xx,yy,spot AS DOUBLE LOCAL count AS LONG pi=4*ATN(1) SELECT CASE AS LONG CBMSG CASE %WM_INITDIALOG ' Initialization handler CASE %WM_NCACTIVATE STATIC hWndSaveFocus AS DWORD IF ISFALSE CBWPARAM THEN ' Save control focus hWndSaveFocus = GetFocus() ELSEIF hWndSaveFocus THEN ' Restore control focus SetFocus(hWndSaveFocus) hWndSaveFocus = 0 END IF CASE %WM_COMMAND ' Process control notifications SELECT CASE AS LONG CBCTL CASE %IDC_LABEL1 CASE %IDC_LABEL2 CASE %IDC_LABEL3 CASE %IDC_LABEL4 CASE %IDC_GRAPHIC1 CASE %IDC_START IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN GRAPHIC ATTACH CBHNDL, %IDC_GRAPHIC1 GRAPHIC ELLIPSE (11,30)-(111,130), %RED GRAPHIC ARC (11,30)-(111,130),0,.5*pi,%BLUE spot=6.28 FOR xx=11 TO 325 spot=spot-.02 IF xx=325-78 THEN GRAPHIC ELLIPSE (xx,30)-(100+xx,130), %RED:GRAPHIC ARC (xx,30)-(100+xx,130),.5*pi,pi,%BLUE IF xx=325-157 THEN GRAPHIC ELLIPSE (xx,30)-(100+xx,130), %RED:GRAPHIC ARC (xx,30)-(100+xx,130),pi,1.5*pi,%BLUE IF xx=325-235 THEN GRAPHIC ELLIPSE (xx,30)-(100+xx,130), %RED:GRAPHIC ARC (xx,30)-(100+xx,130),1.5*pi,2*pi,%BLUE SLEEP 30 'GRAPHIC ELLIPSE (xx,30)-(100+xx,130), %BLACK GRAPHIC ARC (xx,30)-(100+xx,130),spot/pi*pi,yy,%YELLOW GRAPHIC SET PIXEL (xx+50,80),%GREEN yy=spot/pi*pi NEXT xx GRAPHIC ELLIPSE (325,30)-(425,130), %RED GRAPHIC ARC (325,30)-(425,130),0,.5*pi,%BLUE GRAPHIC SET POS (10,5) GRAPHIC PRINT " EAST SOUTH WEST NORTH EAST" GRAPHIC SET POS (60,60) GRAPHIC PRINT "A" GRAPHIC SET POS (115,60) GRAPHIC PRINT "B" GRAPHIC SET POS (135,135) GRAPHIC PRINT "C" GRAPHIC SET POS (155,60) GRAPHIC PRINT "D" GRAPHIC SET POS (310,60) GRAPHIC PRINT "E" GRAPHIC SET POS (370,60) GRAPHIC PRINT "F" GRAPHIC SET POS (430,60) GRAPHIC PRINT "G" GRAPHIC FONT "MS Sans Serif",12,0 GRAPHIC SET POS (10,160) GRAPHIC PRINT "The green line A-F= circumference of a red/blue circle. Also equal to dist B-G" GRAPHIC SET POS (10,185) GRAPHIC PRINT "The yellow line BCG marks a point on the circumference of the red circle" GRAPHIC SET POS (10,210) GRAPHIC PRINT "through the course of one revolution of a wheel (the red/blue circle) and" GRAPHIC SET POS (10,235) GRAPHIC PRINT "travels along the x axis an amount equal to the circumference of the" GRAPHIC SET POS (10,260) GRAPHIC PRINT "red/blue circle, and on the y axis two diameters of the circle." GRAPHIC SET POS (10,300) GRAPHIC PRINT "Is there a formula for the length of the yellow line?" END IF CASE %IDCANCEL IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN DIALOG END CBHNDL, 0 END IF END SELECT END SELECT END FUNCTION '-------------------------------------------------------------------------------------------------- '-------------------------------------------------------------------------------------------------- ' ** Dialogs ** '-------------------------------------------------------------------------------------------------- FUNCTION ShowDIALOG1(BYVAL hParent AS DWORD) AS LONG LOCAL lRslt AS LONG #PBFORMS BEGIN DIALOG %IDD_DIALOG1->-> LOCAL hDlg AS DWORD LOCAL hFont1 AS DWORD LOCAL hFont2 AS DWORD DIALOG NEW PIXELS, hParent, "WHEEL", 105, 114, 645, 681, %WS_POPUP OR %WS_BORDER OR _ %WS_DLGFRAME OR %WS_SYSMENU OR %WS_MINIMIZEBOX OR %WS_CLIPSIBLINGS OR %WS_VISIBLE OR _ %DS_ABSALIGN OR %DS_MODALFRAME OR %DS_3DLOOK OR %DS_NOFAILCREATE OR %DS_SETFONT, _ %WS_EX_CONTROLPARENT OR %WS_EX_LEFT OR %WS_EX_LTRREADING OR %WS_EX_RIGHTSCROLLBAR, TO hDlg DIALOG SET COLOR hDlg, -1, RGB(208, 153, 253) CONTROL ADD LABEL, hDlg, %IDC_LABEL1, "", 8, 8, 630, 8 CONTROL SET COLOR hDlg, %IDC_LABEL1, -1, RGB(128, 0, 128) CONTROL ADD LABEL, hDlg, %IDC_LABEL2, "", 8, 16, 7, 618 CONTROL SET COLOR hDlg, %IDC_LABEL2, -1, RGB(128, 0, 128) CONTROL ADD LABEL, hDlg, %IDC_LABEL3, "", 8, 634, 630, 8 CONTROL SET COLOR hDlg, %IDC_LABEL3, -1, RGB(128, 0, 128) CONTROL ADD LABEL, hDlg, %IDC_LABEL4, "", 630, 16, 8, 618 CONTROL SET COLOR hDlg, %IDC_LABEL4, -1, RGB(128, 0, 128) CONTROL ADD GRAPHIC, hDlg, %IDC_GRAPHIC1, "", 15, 16, 615, 618 GRAPHIC ATTACH hDlg, %IDC_GRAPHIC1 GRAPHIC COLOR %WHITE, %BLACK GRAPHIC CLEAR CONTROL ADD BUTTON, hDlg, %IDC_START, "START", 112, 650, 76, 24 CONTROL ADD BUTTON, hDlg, %IDCANCEL, "EXIT", 390, 650, 75, 24 hFont1 = PBFormsMakeFont("Kristen ITC", 10, 400, %FALSE, %FALSE, %FALSE, %ANSI_CHARSET) hFont2 = PBFormsMakeFont("Arial", 10, 400, %FALSE, %FALSE, %FALSE, %ANSI_CHARSET) CONTROL SEND hDlg, %IDC_LABEL1, %WM_SETFONT, hFont1, 0 CONTROL SEND hDlg, %IDC_LABEL2, %WM_SETFONT, hFont1, 0 CONTROL SEND hDlg, %IDC_LABEL3, %WM_SETFONT, hFont1, 0 CONTROL SEND hDlg, %IDC_LABEL4, %WM_SETFONT, hFont1, 0 CONTROL SEND hDlg, %IDC_GRAPHIC1, %WM_SETFONT, hFont1, 0 CONTROL SEND hDlg, %IDC_START, %WM_SETFONT, hFont2, 0 CONTROL SEND hDlg, %IDCANCEL, %WM_SETFONT, hFont2, 0 #PBFORMS END DIALOG DIALOG SHOW MODAL hDlg, CALL ShowDIALOG1Proc TO lRslt #PBFORMS BEGIN CLEANUP %IDD_DIALOG1 DeleteObject hFont1 DeleteObject hFont2 #PBFORMS END CLEANUP FUNCTION = lRslt END FUNCTION '--------------------------------------------------------------------------------------------------
Comment