physics issue. Sphere physics(collision)

Blitz3D Forums/Blitz3D Programming/physics issue. Sphere physics(collision)

poopla(Posted 2004) [#1]
I understand how to compute the resultant linear reflection force, and result velocity of a sphere/body after making contact with a body at rest or in motion. But how would you calculate the rotational effect of this? I've only found broken, or extremely complex examples(almost never anything with code) on the subject, and it's killing me not knowing how to do this.

Thanks for any help.


Stevie G(Posted 2004) [#2]
I second that. I've tried for days to get something which seems realistic ...


Bot Builder(Posted 2004) [#3]
Yeah. I don't know how to do it either, without resorting to some stupid aproximations. Its even hard in 2d to be able to apply an impulse at an arbitrary location with arbitrary strength.


poopla(Posted 2004) [#4]
Graphics3D 800, 600
SetBuffer BackBuffer()

SeedRnd MilliSecs()

Ball = CreateSphere(8)
EntityFX Ball, 4

g = CreatePlane()
MoveEntity g, 0, -1, 0

tex = CreateTexture(8, 8)
SetBuffer TextureBuffer(tex)
For x = 0 To 8
	For y = 0 To 8
		Color Rnd(0, 255), Rnd(0, 255), Rnd(0, 255)
		Plot x, y
	Next
Next
EntityTexture(g, tex)
SetBuffer BackBuffer()

C = CreateCamera()
CameraRange(C, .001, 100)
MoveEntity C, 0, 10, -16

V = CreateLight()
MoveEntity V, -2, 4, 6

While Not KeyHit(1)

	If KeyDown(30) vx# = vx - .005
	If KeyDown(32) vx# = vx + .005
	If KeyDown(17) vz# = vz + .005
	If KeyDown(31) vz# = vz - .005
	
	PointEntity C, Ball
	TranslateEntity Ball, vx, 0, vz

	rx# = -vx / 1
	rxa# = ((rx*180)/5.0)

	rz# = vz / 1
	rza# = ((rz*180)/5.0)
	
	TurnEntity Ball, rza, 0, rxa, 1

	RotateEntity C, EntityPitch(C), EntityYaw(C), 1
	RenderWorld()
	Flip()

Wend


Heres a start, I'm using the velocity of the ball as the arc length, and the balls radius to get a angular displacement(which we have to convert from radians to degrees as I've done here).

This should technically work perfectly in a more advanced implementation. I just have to figure out how to add movement in the y axis, as it effects the rotation on the z and x axis as well.