# phisical forces... (emulating the reality) VR ENGINE FOR MSX!!!!!!

Pagina 2/2
1 |

Forces, kinetics, weight and MSX? Eh... Fly, you really don't like make your life too easy?

Well, I made a very basic example that you maybe like to study: (X-BASIC and Mouse required)

```10 _TURBO ON
20 DIM DX(10)
30 DIM DY(10)
40 DIM X(10)
50 DIM Y(10)
60 DE=.01 'DELTAT fixed time step, no relation to real time
70 SL=10 'SEGLEN size of one spring in pixels
80 SK=10 'SPRINGK spring constant, stiffness of springs
90 MS=1 'Mass
100 XG=0 'Positive XGRAVITY pulls right, negative pulls left
110 YG=20 'Positive YGRAVITY pulls down, negative up
120 RS=9 'RESISTANCE determines a slowing force proportional to velocity
130 SV=.1 'STOPVEL stopping criteria to prevent endless jittering
140 SA=.1 'STOPACC stopping criteria to prevent endless jittering
150 DS=8 ' DOTSIZE
160 BO=.75 'BOUNCE is percent of velocity retained when bouncing off a wall
170 ND=7 ' Number of dots
180 HE=211
190 WI=255
200 SCREEN 5
210 SPRITE\$(0)=STRING\$(8,255)
230 IF MY>HE-DS-1 THEN MY=HE-DS-1
240 IF MY<0 THEN MY=0
250 IF MX>WI-DS-1 THEN MX=WI-DS-1
260 IF MX<0 THEN MX=0
270 X(0)=MX:Y(0)=MY
280 PUT SPRITE 0,(MX,MY),15,0
290 FOR I=1 TO ND
300 SX=0:SY=0
310 IF I>0 THEN Q1=I-1:GOSUB 510
320 IF IHE-DS-1 THEN Y(I)=HE-DS-1:DY(I)=BO*-DY(I)
430 IF X(I)=>WI-DS-1 THEN X(I)=WI-DS-1:DX(I)=BO*-DX(I)
440 IF X(I)<0 THEN X(I)=0:DX(I)=BO*-DX(I)
450 R=Y(I):IF R<-DS-1 THEN R=-DS-1
460 PUT SPRITE I,(X(I),R),I+2,0
470 NEXT I
480 IF STRIG(1)=0 THEN 220
490 END
500 'SpringForce
510 QX=X(Q1)-X(I):QY=Y(Q1)-Y(I)
520 L=SQR(QX*QX + QY*QY)
530 IF L=
I think, that I leave rest of the physics out of MSX. Playing with SodaPlay is enough for me :-) (www.sodaplay.com/)
```

i want to calculate the force spend in the impact to calculate the possible damage caused to the object...
i want to be simplist, so i have all precalc funtion SIN/COS, and fast multiplication/ div function in assembler....
firsts all object will be treated as spheres....
i have the current speed, wheight, mass, trayectory, of each object....
now, when 2 objects impacts.... i want an acuracy calculation of the impact force , to calculate the damage of the objects.... but also that depends of the weight of each object ....
how are the general purpose formulas?

Somehow I get the feeling, fly, that these are not YOUR words/questions. What about that? And what Biljard game can we expect soon ?

For instance, p1 = m1 * (u1, v1)
where m1 is the mass, u1 the velocity parallel to the x-axis and v1 the velocity parallel to the y-axis (the speed is then given by SQRT(u1*u1 + v1*v2).)

is it correctly or you means SQRT(u1*u2 + v1*v2) ?
Oops, you're right! It's SQRT(u1*u2 + v1*v2).

About the relative directions: it's already in the vectors! As long as both vectors use the same base (i.e. axes) the angle between both vectors is given by p1 . p2 = |p1| |p2| * cos (angle). Where . = inner product and |...| the norm of the vector.

About the relative directions: it's already in the vectors! As long as both vectors use the same base (i.e. axes) the angle between both vectors is given by p1 . p2 = |p1| |p2| * cos (angle). Where . = inner product and |...| the norm of the vector.

(@_@)... what a technical post!

Oops, you're right! It's SQRT(u1*u2 + v1*v2).
Oops 2, actually the speed of an object with velocity vector (u1, v1) is equal to SQRT(u1*u1 + v1*v1), or to put it differently: the square root of the inner product of itself: SQRT ( (u1,v1) . (u1, v1) ), the dot denoting the inner product.

The inner product is very simple to compute;
If one has a vector V = (a, b, c) and another vector W = (d, e, f) the inner product is given by V . W = a*d + b*e + c*f. The result is always a scalar (1D "vector" ).

Impact schematic of to balls

```
v2 \  |  / w2
\ | /
O m2
------+------ t
O m1
/ |\
v1 /  | \ w1
n
```

The n-components of the velocity vectors (v1,v2,w1,w2) are calculated by
using the following expression (as mentioned before):

m1 v1 + m2 v2 = m1 w1 + m2 w2

The t-components are calculated the two following expressions:

m1 v1 = m1 w1 ---> v1 = w1
and m2 v2 = m2 w2 ---> v2 = w2 (t-components!)

Now we still need another expression because :
Unknowns != Number of Expressions

This expression is:

e = (w2 - w1)/(v1-v2) (n-components!)

If e = 1 then we have an fully elastic collision.
If e = 0 then fully plastic.

It is probebly needless to say that the angles follow out the geometry
of the velocity vectors.

Something tells me this website contains some very useful information for you, flyguille :)

m1 v1 = m1 w1 ---> v1 = w1
and m2 v2 = m2 w2 ---> v2 = w2 (t-components!)

I guess it's my fault that I read that nothing has changed after the collision according to the above? v1 = w1 and v2 = w2?!

Anyway, http://www.walter-fendt.de/ph11e/collision.htm is a nice java applet. Try it.

Maby I should have mentiond that these formulas only hold for frictionless
situations.
With this assumption in mind it is logical that the t-components of the velocities (components tangent to the normal line of impact) are unaffected.
Wich does not say nothing changes in the n-direction.

I guess I could have be more clear if had used subscipts like v1t, v1n, w2t, etc.

Right, I understand. You use a slightly different approach, i.e. another axis.

Of course there can't be friction as we make use of conservation of momentum.

Pagina 2/2
1 |