For inspiration, notice the D1 and D2 are ortogonal everytime.
Code: Select all
InitMouse():InitSprite():InitKeyboard()
RX.u=1024:RY.u=768
OpenWindow(0,0,0,RX,RY,"circunf",#PB_Window_BorderLess|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,RX,RY,0,0,0,#PB_Screen_WaitSynchronization)
Procedure DrawVector2D(CX.f,CY.f,X.f,Y.f,color.l=$CCCCCC,long.w=13,transv.w=5,n$="")
Protected modc.f=Sqr(X*X+Y*Y),BX.f=CX+X,BY.f=CY+Y
LineXY(CX,CY,BX,BY,color)
If modc<>0:X/modc:Y/modc:EndIf
LineXY(BX,BY,BX-X*long+Y*transv,BY-Y*long-X*transv,color):LineXY(BX,BY,BX-X*long-Y*transv,BY-Y*long+X*transv,color)
DrawText(BX-long*X*2-8,BY-long*Y*2-8,n$,color)
EndProcedure
CX.f=RX/2:CY.f=RY/2
D.f=500
D1.f=0
D2.f=D
Repeat
While WaitWindowEvent(4):Wend
ClearScreen(0)
ExamineKeyboard():ExamineMouse():mdx.f=MouseDeltaX():mdy.f=MouseDeltaY()
lmb.b=MouseButton(#PB_MouseButton_Left):rmb.b=MouseButton(#PB_MouseButton_Right):mmb.b=MouseButton(#PB_MouseButton_Middle)
If rmb:D+mdy
ElseIf mmb:CX+mdx:CY+mdy
EndIf
relacionD1D2.f-mdy/1000:ABSrelacionD1D2.f=Abs(relacionD1D2.f):If ABSrelacionD1D2>1.0:relacionD1D2.f/ABSrelacionD1D2:EndIf
StartDrawing(ScreenOutput()):DrawingMode(#PB_2DDrawing_Transparent|#PB_2DDrawing_Outlined)
Line(CX-D/2,CY,D,1,$22FEee)
D1.f=D*Sqr(2)/2*relacionD1D2
D2.f=D*Sqr(2)/2/relacionD1D2
Circle(CX,CY,D/2,$77EE33)
DrawVector2D(CX-D/2,CY,Pow(D1,2)/D,-D1*Sqr(1-Pow(D1/D,2)),$22FEee,13,5,"D1")
DrawVector2D(CX+D/2,CY,Pow(D1,2)/D-D,-D1*Sqr(1-Pow(D1/D,2)),$22FEee,13,5,"D2")
DrawVector2D(CX+D/2,CY,-Pow(D1,2)/D,D1*Sqr(1-Pow(D1/D,2)),$22FEee,13,5,"D1_")
DrawVector2D(CX-D/2,CY,D-Pow(D1,2)/D,D1*Sqr(1-Pow(D1/D,2)),$22FEee,13,5,"D2_")
StopDrawing()
FlipBuffers():Delay(11)
Until KeyboardPushed(#PB_Key_Escape)