Physics question

 Posts: 3400
 Joined: Jan 01, 2009 7:03
Re: Physics question
fig. 4 and fig. 5 and fig. 6 are taken from my latest program where I am using a single rocket motor that can be rotated.
fig. 6 I would suggest is equivalent to your first example where you have two fixed motors with one not firing.
I would suggest that the vector force would be divided up as shown in fig. 3
fig. 6 I would suggest is equivalent to your first example where you have two fixed motors with one not firing.
I would suggest that the vector force would be divided up as shown in fig. 3

 Posts: 2003
 Joined: Jan 02, 2017 0:34
 Location: UK
Re: Physics question
With sin(0) = 0, cos(0) = 1, sin(90) = 1 and cos(90) = 0
From second post with beta = 0 we have
towards centre = F
angular momentum = 0
This corresponds to BasicCoder2's fig. 5
With beta = 90 we have
towards centre = 0
angular momentum = F
This corresponds to BsicCoder2's fig. 4
fig. 3 corresponds with the second post.
I cannot see what BasicCoder2's last post is adding more to the conversation than the second post did; or am I missing something?
From second post with beta = 0 we have
towards centre = F
angular momentum = 0
This corresponds to BasicCoder2's fig. 5
With beta = 90 we have
towards centre = 0
angular momentum = F
This corresponds to BsicCoder2's fig. 4
fig. 3 corresponds with the second post.
I cannot see what BasicCoder2's last post is adding more to the conversation than the second post did; or am I missing something?
Re: Physics question
Neither did I.deltarho[1859] wrote:I cannot see what BasicCoder2's last post is adding more to the conversation than the second post did; or am I missing something?
As I don't see a real difference between the flying saucer and the borg cube, I expect both to move in ydirection only while rotating. (assuming the thruster fires shortly, like impulse). Working on some code now...
Actually I build a test setup: A piece of wood (40 cm long), hanging on a thin flexible wire (2 m long), with the wire connected to the center so the the piece of wood is exactly balanced. Then I hit it with an wooden spoon firmly, but short "tak". Although difficult to perform accurately, the suspended piece of wood seems to start swinging only in the direction of the wooden spoon movement. Plus rotation.
Last edited by badidea on Jul 18, 2019 22:24, edited 1 time in total.

 Posts: 3400
 Joined: Jan 01, 2009 7:03
Re: Physics question
badidea wrote:Neither did I.deltarho[1859] wrote:I cannot see what BasicCoder2's last post is adding more to the conversation than the second post did; or am I missing something?
As I don't see a real difference between the flying saucer and the borg cube, I expect both to move in ydirection only while rotating. (assuming the thruster fires shortly, like impulse). Working on some code now...
Some nice pictures to reference :) I tend to think visually.
Last night I was watching a documentary about Michael Faraday and how his lack of math limited his genius. Instead it was Maxwell that wrote the famous equations after reading the works of Faraday.
What I was hoping to do next is instead of having keys for linear and angular velocity control of separate rocket engines (which I think they use to work the lunar lander mother module) have keys that swivel the rocket engine and then fire an impulse from the rocket engine with a tap of the space bar to see how it looks. As I alluded to before, like outboard motors on a speed boat.
The borg cube is of course 3d and a lot more complicated. Hitting a circle is the same at any point. The angle you hit a square will depend on the orientation of the square. A frictional contact is also required I think to add angular momentum otherwise the force is entirely through the centre of mass. An attached rocket engine has 100% frictional contact.
Ideally someone who has done a course in math and physics should be able to write the code that can be used in an actual game.
Re: Physics question
BasicCoder2 wrote:The borg cube is of course 3d and a lot more complicated.
You are allowed to squeeze to borg cube to a height of nearly nothing :)
BasicCoder2 wrote:Hitting a circle is the same at any point.
I am not hitting the circle. I have attached engine which shortly applies thrust in ydirection.
BasicCoder2 wrote:The angle you hit a square will depend on the orientation of the square.
I hit the cube perpendicular. Haven't decided between firing a billiard ball at it or a picee of sticky gum.
Re: Physics question
dodicat wrote:Here is a general strike.
I have used the property of mass of a disc and moment of inertia of a disc.
...
Looking at you code, but I is a bit hard to follow. Not written for a beauty contest :)
Code: Select all
linearimpulse = impulse * Cos(a) / mass
angularimpulse = impulse * Sin(a) / anginertia
You assume that linear impulse is in cos(a) direction and angular impulse in sin(a) direction. But that is were a have my doubts, unless simulation pool billiard.

 Posts: 7825
 Joined: May 28, 2005 3:28
Re: Physics question
May be force are not with you if you don't understand :lol:dodicat wrote:(The laws of physics apply everywhere), maybe not here.
Again the cross product (d,F) was and is the key
d=direction from center to point of interaction
F = the force acting on the point
In 3D space the result of the cross product is an vector and the most important property of this vector are the magnitude.
if
Speed = magnitude(velocity)/timestep
then
AngularVelocity = magnitude( cross(d, F) ) ' in radiant per second
here from my code:
Code: Select all
...
' german: Winkelgeschwindigkeit
type tAngularVelocity as tReal ' = cross(d,F)
' german: Drehmoment
' Torque is a measure of how much a force acting on an object causes that object to rotate.
type tTorque as tVector ' = angular acceleration
...
here from my 2d vector class
Code: Select all
' pseudo cross product last row from 3D cross product !
operator \(l as tVector, r as tVector) as tReal
return l.x*r.y  l.y*r.x
end operator
Joshy
Do you know ?
from: Video Game Physics Tutorial  Part I: An Introduction to Rigid Body Dynamics

 Posts: 3400
 Joined: Jan 01, 2009 7:03
Re: Physics question
badidea wrote:I expect both to move in ydirection only while rotating.
You may be right with an object hitting a Borg ship. The boat and it's motor interacts with the water it is not skidding along a frictionless frozen lake with a rocket for propulsion.
https://www.youtube.com/watch?v=qaIqanZ00uo
However if there was a rocket engine on the block it would turn with the block and thus change the direction of the force in absolute space?
So to test this you would need to have a rocket of some kind (water bottle with vinegar and baking soda dissolved in water?) and a low friction setup such as a disc on an ice rink.
Re: Physics question
badidea wrote:dodicat wrote:Here is a general strike.
I have used the property of mass of a disc and moment of inertia of a disc.
...
Looking at you code, but I is a bit hard to follow. Not written for a beauty contest :)Code: Select all
linearimpulse = impulse * Cos(a) / mass
angularimpulse = impulse * Sin(a) / anginertia
You assume that linear impulse is in cos(a) direction and angular impulse in sin(a) direction. But that is were a have my doubts, unless simulation pool billiard.
When the angle is zero all goes into the linear, so cos.
When the angle is 90 all goes into the turning so sin.
To use a cross product in I just add a .z component.
I only use the vector products here to deduce an angle in the range 0 to 360.
The cross product uses a bit more cpu, but with the cross product the dot product is not really needed to return an angle.
Angle example:
Code: Select all
Type pt
As Single x,y,z
End Type
Function length(p1 As pt) As Single
Return Sqr( (p1.x)^2 + (p1.y)^2+ (p1.z)^2)
End Function
Function unit(p1 As pt) As pt '=normalize
Dim As Single L=length(p1)
Return Type(p1.x/L,p1.y/L,p1.z/L)
End Function
#define dround(n,places) mid((str(int((n)*10^(places)+.5)/10^(places))),1,instr(ltrim(str((n)),""),".")+(places)+1)
#define onscreen (mx>0) and (mx<xres) and (my>0) and (my<yres)
#define incircle(cx,cy,radius,x,y) (cxx)*(cxx) +(cyy)*(cyy)<= radius*radius
Const pi=4*Atn(1)
Function cross(v1 As pt,v2 As pt) As pt 'cross product= v1 * v2 *sin(angle between v1 and v2)
Return Type(v1.y*v2.zv2.y*v1.z,(v1.x*v2.zv2.x*v1.z),v1.x*v2.yv2.x*v1.y)
End Function
Function getangle(p() As pt) As Single
Dim As pt L1=(p(1).xp(2).x,p(1).yp(2).y)'leg 1
Dim As pt L2=(p(3).xp(2).x,p(3).yp(2).y)'leg 2
Dim As Single angle=Asin(length(cross(unit(L1),unit(L2))))*(180/pi)'angle between legs in degrees
If cross(l1,l2).z>0 Then angle=360angle
Return angle
End Function
#macro display
angle=getangle(p())
Screenlock
Cls
Color 15
Draw String (20,20), "Drag circles by leftmouse button"
Color 3
Draw String (20,40), "Angle from red to green line (clockwise) in degrees"
Color 15
For z As Long=1 To 3
Circle (p(z).x,p(z).y),5,7,,,,f
Next
Line(p(2).x,p(2).y)(p(1).x,p(1).y),2
Line(p(2).x,p(2).y)(p(3).x,p(3).y),4
Color 3
Draw String(p(2).x+20,p(2).y),Iif(Instr(dround(angle,2),"."),Rtrim(dround(angle,2),"0"),dround(angle,2))+chr(248)
Screenunlock
#endmacro
#macro mouse(m)
Dim As Long x=mx,y=my,dx,dy
While mb = 1
Display():Sleep 1,1
Getmouse mx,my,,mb
If onscreen Then
If mx<>x Or my<>y Then
dx = mx  x
dy = my  y
x = mx
y = my
p(m).x=x+dx
p(m).y=y+dy
End If
End If
Wend
#endmacro
Screen 19
Dim As Integer xres,yres
Screeninfo xres,yres
Dim As pt p(1 To 3)={(100,100),(300,200),(200,400)} 'arbitary starting points
Dim As Integer mx,my,mb
dim as single angle
Do
Getmouse(mx,my,,mb)
display:Sleep 1,1
For n As Long=1 To 3
If incircle(p(n).x,p(n).y,10,mx,my) And mb=1 Then
mouse(n)
End If
Next n
Loop Until Len(Inkey)
Re: Physics question
BasicCoder2 wrote:badidea wrote:I expect both to move in ydirection only while rotating.
You may be right with an object hitting a Borg ship. The boat and it's motor interacts with the water it is not skidding along a frictionless frozen lake with a rocket for propulsion.
https://www.youtube.com/watch?v=qaIqanZ00uo
However if there was a rocket engine on the block it would turn with the block and thus change the direction of the force in absolute space?
So to test this you would need to have a rocket of some kind (water bottle with vinegar and baking soda dissolved in water?) and a low friction setup such as a disc on an ice rink.
A sailing ship can move into the wind (Move towards the force)
If you put a spoon on a level table (curved side up) and force directly down on it with a pencil, the spoon will move at 90 degrees along the table to your force.
If you now put a book under the table thus tilting it up, and force the pencil directly down on the spoon will now ride up the table.
So the spoon has a motion component in the opposite direction to the force moving it.
But these two examples need a third interaction, the sea and the table.
I don't think you have a third thing in space.
On your own out there you could be stuck in the one place no matter how much you thrashed around.
Re: Physics question
BasicCoder2 wrote:However if there was a rocket engine on the block it would turn with the block and thus change the direction of the force in absolute space?
So to test this you would need to have a rocket of some kind (water bottle with vinegar and baking soda dissolved in water?) and a low friction setup such as a disc on an ice rink.
Yes, I understand that the direction eventually changes, but the key part of my original question was an thruster firing shortly. The reason for this is that the game will run in small time steps (milliseconds). For each small time step the physics need to be correct. The game does not know yet what the situation will be in the next time step.
With Joshy's 'd' I think I can solve the problem, roughly:
* Add center mass + the apparent mass (by the moment of inertia and this distance d)
* Determine a and (acceleration and velocity vector)where the force is acting
* Determine change in position and rotation
* Next time step
Something like that, to be worked out further...
dodicat wrote:I don't think you have a third thing in space.
Certainly, no tables and spoons in space :)

 Posts: 3400
 Joined: Jan 01, 2009 7:03
Re: Physics question
dodicat wrote:On your own out there you could be stuck in the one place no matter how much you thrashed around.
https://www.youtube.com/watch?v=960CsCg ... be&t=1m44s
https://www.youtube.com/watch?v=RtWbpyjJqrU
Re: Physics question
Looks like a useful resource. I will be camping for the next 2 weeks, so don't expect much coding progress from me, but I can at least read this on my phone and make some notes.
Re: Physics question
Happy camping.
Code: Select all
Const pi=4*Atn(1)
Const BoxSize=100
Const systemconstant=1/boxsize
#define incircle(cx,cy,radius,x,y) (cxx)*(cxx) +(cyy)*(cyy)<= radius*radius
#define onscreen (mx>0) and (mx<xres) and (my>0) and (my<yres)
Type pt
As Double x,y,z
End Type
Redim Shared As pt msg()
Operator (p1 As pt,p2 As pt) As pt
Return Type(p1.xp2.x,p1.yp2.y)
End Operator
Operator +(p1 As pt,p2 As pt) As pt
Return Type(p1.x+p2.x,p1.y+p2.y)
End Operator
Operator *(f As Single,p As pt) As pt
Return Type(f*p.x,f*p.y)
End Operator
Function length(p1 As pt,p2 As pt) As Single
Dim As Single diffx=p1.xp2.x,diffy=p1.yp2.y
Return Sqr(diffx*diffx+diffy*diffy)
End Function
Function unit(p1 As pt) As pt
#define lngth(p) Sqr( (p1.x)^2 + (p1.y)^2+ (p1.z)^2)
Dim As Single L=lngth(p1)
Return Type(p1.x/L,p1.y/L,p1.z/L)
End Function
Function dot(v1 As pt,v2 As pt) As Single 'dot product v1 * v2 *cos(angle between v1 and v2)
Return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z
End Function
Function cross(v1 As pt,v2 As pt) As pt 'cross product= v1 * v2 *sin(angle between v1 and v2)
Return Type(v1.y*v2.zv2.y*v1.z,(v1.x*v2.zv2.x*v1.z),v1.x*v2.yv2.x*v1.y)
End Function
Function getangle(p() As pt) As Single
Dim As pt L1=(p(1).xp(2).x,p(1).yp(2).y)'leg 1
Dim As pt L2=(p(3).xp(2).x,p(3).yp(2).y)'leg 2
Dim As Single angle=Acos(dot(unit(L1),unit(L2)))*(180/pi)'angle between legs in degrees
If cross(l1,l2).z>0 Then angle=360angle
Return angle
End Function
'=========================
Function inpolygon(p1() As Pt,Byval p2 As Pt) As Long
#macro Winder(L1,L2,p)
((L1.xL2.x)*(p.yL2.y)(p.xL2.x)*(L1.yL2.y))
#endmacro
Dim As Integer index,nextindex,k=Ubound(p1)+1,wn
For n As Integer=1 To Ubound(p1)
index=n Mod k:nextindex=(n+1) Mod k
If nextindex=0 Then nextindex=1
If p1(index).y<=p2.y Then
If p1(nextindex).y>p2.y Andalso Winder(p1(index),p1(nextindex),p2)>0 Then wn+=1
Else
If p1(nextindex).y<=p2.y Andalso Winder(p1(index),p1(nextindex),p2)<0 Then wn=1
End If
Next n
Return wn
End Function
Sub drawpolygon(b() As pt,p() As Pt,rotmsg() As pt,Byref col As Ulong,Byval im As Any Pointer=0)
Dim k As Long=Ubound(p)+1
Dim As Long index,nextindex
Dim As Long cx,cy
For n As Long=1 To Ubound(p)
cx+=p(n).x:cy+=p(n).y
index=n Mod k:nextindex=(n+1) Mod k
If nextindex=0 Then nextindex=1
Line im,(p(index).x,p(index).y)(p(nextindex).x,p(nextindex).y),col
Next
cx/=Ubound(p):cy/=Ubound(p)
Paint (cx,cy),col,col
For n As Long=Lbound(rotmsg) To Ubound(rotmsg)
Pset(rotmsg(n).x,rotmsg(n).y),rotmsg(n).z'rgb(200,0,0)
Next n
End Sub
Function rotate(pivot As pt,p As pt,a As Single,d As Single=1) As pt
Return Type<pt>(d*(Cos(a)*(p.xpivot.x)Sin(a)*(p.ypivot.y)) +pivot.x,_
d*(Sin(a)*(p.xpivot.x)+Cos(a)*(p.ypivot.y)) +pivot.y)
End Function
Sub setUpPolygon(b() As pt,sz As Long,x As Long,y As Long,num As Long)
Redim b(1 To num)
Dim As Long ctr
For n As Single=0 To 3*pi Step 2*pi/num
ctr+=1
If ctr>num Then Exit For
b(ctr).x=x+sz*Cos(n)
b(ctr).y=y+sz*Sin(n)
Next n
End Sub
Sub turnpolygon(b() As pt,rot() As pt,rotmsg() As pt,a As Single,f As pt,translate As pt)
For n As Long=Lbound(rot) To Ubound(rot)
rot(n)= rotate(f,b(n),a)
rot(n)+=translate
Next n
For n As Long=Lbound(rotmsg) To Ubound(rotmsg)
rotmsg(n)= rotate(f,msg(n),a)
rotmsg(n)+=translate
rotmsg(n).z=msg(n).z
Next n
End Sub
Function movepolygon(b() As pt,msg() As pt,dirn As pt) As pt
Dim As pt p
For n As Long=Lbound(b) To Ubound(b)
b(n).x+=dirn.x
b(n).y+=dirn.y
p.x+=b(n).x
p.y+=b(n).y 'get centre
Next
For n As Long=Lbound(msg) To Ubound(msg)'move message
msg(n).x+=dirn.x
msg(n).y+=dirn.y
Next
Dim As Long size=Ubound(b)Lbound(b)+1
Return Type(p.x/size,p.y/size)
End Function
Function shortline(fp As pt,p As pt,Ln As Long) As pt 'line of ln length
Dim As Single diffx=p.xfp.x,diffy=p.yfp.y
Dim As Single L=Sqr(diffx*diffx+diffy*diffy)
Return Type(fp.x+Ln*diffx/L,fp.y+Ln*diffy/L)
End Function
Function drawline(x As Long,y As Long,angle As Single,dist As Long) As pt'line by angle
Var x2=x+dist*Cos(angle)
Var y2=y+dist*Sin(angle)
Return Type(x2,y2)
End Function
'all the lines
Function lineto(c As pt,_out As pt,p2() As pt,dirn As pt,Byref strike As Long,b() As pt) As Single
Var L=length(p2(1),p2(2))
Var ang=Atan2(p2(2).yp2(1).y,p2(2).xp2(1).x)
Dim As pt p=p2(1)
Dim As Long ic,ctr
Do
p=shortline(p,p2(2),1)
ic=inpolygon(b(),p)
ctr+=1
If ic Then strike=1 Else strike=0
Loop Until ic Or ctr>L 'when it hits the box at p
Line(p.x,p.y)(p2(1).x,p2(1).y),Rgb(0,200,0) 'surface to the red point
If strike Then Line(c.x,c.y)(p.x,p.y)
Dim As pt eq=drawline(c.x,c.y,ang,200)
Dim As pt q=Type(c.x,c.y)
ctr=0
Do
q=shortline(q,eq,1)
ic=inpolygon(b(),q)
ctr+=1
Loop Until ic=0 Or ctr>400 'when exits the box at q
If strike Then Line(c.x,c.y)(q.x,q.y)
Dim As pt pp(1 To 3)={c+(cq),c,c+(cp)} 'array to hold three points (two legs metting at t)
_out=p 'out the intersection wth box
dirn=unit(pc) 'out the direction
Dim As pt d=.3333*(p+q+c)'to show the angle
Dim As Single angle=getangle(pp())
If strike Then Draw String(d.x,d.y),Str(Int(angle))
Return angle*pi/180 'return in radians
End Function
Function Regulate(Byval MyFps As Long,Byref fps As Long=0) As Long
Static As Double timervalue,_lastsleeptime,t3,frames
Var t=Timer
frames+=1
If (tt3)>=1 Then t3=t:fps=frames:frames=0
Var sleeptime=_lastsleeptime+((1/myfps)T+timervalue)*1000
If sleeptime<1 Then sleeptime=1
_lastsleeptime=sleeptime
timervalue=T
Return sleeptime
End Function
Sub HandleRain(rain As Any Ptr)
Var max=100
Static As Single xx(max),yy(max)
For i As Long = 0 To max
xx(i) = Rnd*1024
yy(i) = Rnd*768
Put(xx(i),yy(i)),Rain,Alpha,200+Rnd*50
Next
End Sub
#macro display
flag2=0
Screenlock
Cls
Draw String(20,20),"Move the small circles by mouse"
Draw String(20,50),"Press spacebar for impulse"
Draw String(20,80),"Right mouse click to reset"
Draw String(20,110),"Angular speed " &abs(angularimpulse*180/pi)
Draw String(20,140),"Linear speed " &speed
Draw String(20,170),"framerate = " &fps,Rgb(0,200,0)
pivot=movepolygon(b(),msg(),Type(dx,dy))
turnpolygon(b(),rot(),rotmsg(),turn,pivot,Type(dx,dy))
drawpolygon(b(),rot(),rotmsg(),Rgb(0,100,255))'draw the polygon and return the centre
c=Type<pt>(xres\2,yres\2) 'centre
If flag=0 Then
Locate 15
Print " weight "; impulse
flag2=1
a= lineto(c,_out,p2(),dirn,strike,rot()) 'a=angle return as shown in radians
End If
If Len(Inkey) And flag2 And strike Then
flag=1
linearimpulse=impulse*Cos(a)/mass
If a>pi/2 And a<3*pi/2 Then dirn=1*dirn
dx=dirn.x*linearimpulse
dy=dirn.y*linearimpulse
angularimpulse=impulse*Sin(a)/anginertia
speed=Sqr(dx*dx+dy*dy) 'to show value on screen
End If
For z As Long=1 To 2 'the two drag spots
Dim As Ulong clr=Iif(z=1,Rgb(200,0,0),Rgb(0,200,0))
Circle (p2(z).x,p2(z).y),5,clr,,,,f
Next
If flag=0 Then impulse=length(p2(1),_out) 'arbitrary weight as a function of mouse potition
turn+=angularimpulse
handlerain(rain)
Screenunlock
Sleep regulate(60,fps),1
'====================
#endmacro
#macro mouse(m)
Scope
Dim As Long x=mx,y=my,dx2,dy2
While btn = 1 Or btn=2
Display
Getmouse mx,my,,btn
If onscreen Then
If mx<>x Or my<>y Then
dx2 = mx  x
dy2 = my  y
x = mx
y = my
p2(m).x=x+dx2
p2(m).y=y+dy2
End If
End If
Wend
End Scope
#endmacro
Sub MakeMsg(msg() As pt,xres As Long,yres As Long)
Cls
Redim msg(0)
Print " Gone"+Chr(10)+"Fishing"
Dim As Long ctr
Var c=Point(1,1)
For x As Long=0 To 60
For y As Long=0 To 45
If Point(x,y)<>c Then
ctr+=1
Redim Preserve msg(1 To Ubound(msg)+1)
msg(Ubound(msg))=Type(x+xres/2,y+yres/2,Rgb(.75*ctr,255.75*ctr,ctr/6))
End If
Next
Next
End Sub
Function pickanumber As Long
Cls
Locate 12
Print "click a number"
#define map(a,b,_x_,c,d) ((d)(c))*((_x_)(a))/((b)(a))+(c)
Dim As Long mx,my,mb,ret
Do
Getmouse mx,my,,mb
Locate 15
If my>220 And my<235 Then
Color ,Rgb(100,0,0)
var n=Int(map(5,655,mx,3,30))
If mx<675 Then Print Tab(90);"Choose ";n;" ?"
If mb Then ret=map(0,660,mx,3,30)
Else
Color ,Rgb(0,0,0)
End If
Locate 15
For n As Long=3 To 30
Print Right("0"+Str(n),2)+" ";
Next
Print
sleep 10
Loop Until ret
Color ,Rgb(0,0,0)
Return ret
End Function
Screen 20,32
Dim As Integer xres,yres
Screeninfo xres,yres
Dim As Single dx,dy,a,turn,angularimpulse,impulse,linearimpulse,speed
Dim As Single mass
Dim As Single anginertia
Dim As Long mx,my,btn,flag,flag2,fps,strike
Dim As pt c
Dim As pt _out,p2(1 To 2)={(200,200),(650,500)},dirn
Redim As pt b()
Dim As Long numsides
start:
numsides=pickanumber
'area of a regular polygon
mass= systemconstant*boxsize^2*numsides*sin(2*pi/numsides)/2
'moment of inertia of a regular polygon
anginertia=systemconstant*((mass*boxsize^2)/6)*(1+2*(Cos(pi/numsides)^2))
MakeMsg(msg(),xres40,yres40)'create a string message
setUpPolygon(b(),boxsize*Sqr(2),xres\2,yres\2,numsides)
Redim As pt rot(Lbound(b) To Ubound(b)) 'to hold rotated shape
Redim As pt rotmsg(Lbound(msg) To Ubound(msg))''to hold rotated message
Dim As pt pivot
Dim As Any Ptr Rain=Imagecreate(5,20)
Line rain,(0,0)(5,20),Rgb(50,50,55)
Do
Getmouse mx,my,,btn
strike=0
display
For n As Long=1 To 2
If incircle(p2(n).x,p2(n).y,10,mx,my) And btn=1 And flag2=1 Then
mouse(n)
End If
Next n
If btn=2 Or pivot.x<BoxSize Or pivot.x>xresBoxSize Or pivot.y<BoxSize Or pivot.y>yresBoxSize Then 'reset
Screenunlock
sleep 1
dx=0
dy=0
a=0:flag=0
angularimpulse=0
speed=0
turn=0
Goto start
End If
Loop Until Multikey(1)
Imagedestroy rain
Sleep
Last edited by dodicat on Jul 20, 2019 7:46, edited 1 time in total.

 Posts: 2003
 Joined: Jan 02, 2017 0:34
 Location: UK
Re: Physics question
@dodicat
I am having problems running some of your code. Your very first code is working fine as is you code where we can drag & drop one of three circles. However, every other code where we should be able to drag & drop either the red or green circle sees the CPU max out on a core, I have four plus hyperthreading, and the Windows busy icon is displayed. The Task Manager displays 'not responding'. Eventually the system settles down but the circle that I dragged does not end up where I expected it to be and sometimes is offscreen.
I would have a bash at debugging but my graphics knowledge is woefully poor.
If anyone else is having issues please shout up so that we can eliminate my machine from any enquiries.
Ta much. <smile>
I am having problems running some of your code. Your very first code is working fine as is you code where we can drag & drop one of three circles. However, every other code where we should be able to drag & drop either the red or green circle sees the CPU max out on a core, I have four plus hyperthreading, and the Windows busy icon is displayed. The Task Manager displays 'not responding'. Eventually the system settles down but the circle that I dragged does not end up where I expected it to be and sometimes is offscreen.
I would have a bash at debugging but my graphics knowledge is woefully poor.
If anyone else is having issues please shout up so that we can eliminate my machine from any enquiries.
Ta much. <smile>
Who is online
Users browsing this forum: No registered users and 31 guests