An intriguing challenge with physics

Blitz3D Forums/Blitz3D Programming/An intriguing challenge with physics

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Dr. is it something like this?
SetBuffer BackBuffer()

Type arm
	Field x#,y#
	Field s#,l#
	Field parent.arm
End Type

parm.arm = Null

;
; s# indicates how fast each joint can turn
s# = 0.02

For i = 0 To 5
	arm.arm = New arm
	arm\parent = parm
	If parm = Null
		arm\x = 200
		arm\y = 150
	End If
	arm\l	= 20.0
	arm\s	= s#
	
	;
	; Set the next arm's parent to be this one
	parm = arm
	;
	; Increase s# for each new arm
	s# = s# * 1.5
Next

Repeat

	Cls
	
	a#	= a+2.0
	tx# = MouseX()
	ty# = MouseY()

	For arm.arm = Each arm
		If arm\parent<>Null
			;
			; Vector between this arm's joint and the mouse
			dx# = tx-arm\x
			dy# = ty-arm\y
			d# = Sqr(dx*dx + dy*dy)
			If d = 0 Then d = 1.0
			dx# = arm\parent\x+((dx/d)*arm\l)
			dy# = arm\parent\y+((dy/d)*arm\l)
		
			;
			; Turn the arm to be closer to the mouse
			arm\x = arm\x-(arm\parent\x-dx)*arm\s
			arm\y = arm\y-(arm\parent\y-dy)*arm\s
			
			;
			; Make sure the arm doesn't change length
			dx# = arm\x-arm\parent\x
			dy# = arm\y-arm\parent\y 
			d# = Sqr(dx*dx + dy*dy)
			If d = 0 Then d = 1.0			
			arm\x# = arm\parent\x+((dx/d)*arm\l)
			arm\y# = arm\parent\y+((dy/d)*arm\l)
			
			;
			; Draw the arm
			Oval arm\x-2,arm\y-2,5,5,True
			Line arm\x,arm\y,arm\parent\x,arm\parent\y
		Else
			;
			; Just move the first joint around in a circle
			arm\x = 200+(Sin(a)*20.0)
			arm\y = 150+(Cos(a)*20.0)
			Oval arm\x-6,arm\y-6,13,13,False
			Oval arm\x-2,arm\y-2,5,5,True
		End If
	Next
	
	Flip
	
Until KeyHit(1)
End
And the funny thing is I don't really know what I'm doing either :) I don't really know about any books, just get some basic maths books about vectors, they will get you far if you are interested in it!