Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 05:41
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AbrahamR, AndrewAMD), 1,278 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Physics cause difficulties measuring entity rotational speeds #258842
04/02/09 12:40
04/02/09 12:40
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Hi,
I have made a nice little demo, you will immediately see what is going wrong. Press up and down to let it rotate.

http://www.file-upload.net/download-1563899/rotspeed.rar.html

The most of the time the value of the speed is correct but its "fluttering" around. Try to press up or down for a bit longer.
It goes up to 4,5 (on my pc) and then I have the impression its switching for a few millisecs to other values like 2 or 3. That's wrong and deadly for my project ^^
And the sign (it should be the direction of the rotational speed) of the speed is pretty much random.

Keep in mind that without physics the speed has always exactly the right value.
(You can also find this (unresolved) problem here http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=257365&page=1 and here http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=258399#Post258399)

So, I can't explain this issue better then this, help would be great.


Last edited by theDust; 04/02/09 12:43.
Re: Physics cause difficulties measuring entity rotational speeds [Re: theDust] #259439
04/06/09 06:53
04/06/09 06:53
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
If I understand you right, your question was if the duration of a frame is different when running physics functions. Of course it is, and also depends on other engine functions, on your hardware and many other factors. Frame time can be totally different from one second to the other.

Re: Physics cause difficulties measuring entity rotational speeds [Re: theDust] #259464
04/06/09 10:08
04/06/09 10:08
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Ok, know its clear why the calculation returns these weird values. But how i can compensate this time changes ?
Here's the calculation:
Code:
function speed()
{
   while(1) 
   {
     vec_set(Old_Rot, my.pan); 
     wait(1);
     vec_set(Now_Rot, my.pan);   
     vec_diff(Rot_Speed, Old_Rot, Now_Rot);
     wait(1);
   }
}

This first wait(1) is the responsible code line I guess. I need a always constant thing in this wait. Maybe something with time_step ?

Re: Physics cause difficulties measuring entity rotational speeds [Re: theDust] #259465
04/06/09 10:12
04/06/09 10:12
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
You must always divide by time_frame when you want to get a speed.

Speed == distance over time.

Re: Physics cause difficulties measuring entity rotational speeds [Re: jcl] #259473
04/06/09 11:03
04/06/09 11:03
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
So JCL, are you saying the below change would (in theory) solve this calculation?
Or at least "smooth out" the roughness of Rot_Speed caused by physics frame-rate variations.
Code:
function speed()
{
   while(1) 
   {
     vec_set(Old_Rot, my.pan); 
     wait(1);
     vec_set(Now_Rot, my.pan);   
     vec_diff(Rot_Speed, Old_Rot, Now_Rot);
     vec_scale(Rot_Speed, time_frame);   //JCL-inspired frame-rate correction
     wait(1);
   }
}



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Physics cause difficulties measuring entity rotational speeds [Re: EvilSOB] #259475
04/06/09 11:14
04/06/09 11:14
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Nope. It all depends on what you want to calculate. If you want a speed, you need to take a distance and divide it by the time, because that's how the word "speed" is defined:

vec_scale(Rot_Speed,1/time_frame);

But if you don't want an angle speed but just the angle difference between frames, the original calculation was fine. I don't know what he really needed, but assume it was indeed a speed.

Re: Physics cause difficulties measuring entity rotational speeds [Re: jcl] #259495
04/06/09 14:09
04/06/09 14:09
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
What he is trying to get is a "change of angle" in "degrees per second".
(or at least a "degrees per 3DGS-constant-time-related-number".

So he/we are after an angular equivalent of speed. So if (pseudocode)
SPEED.X(quants/sec) = (Start.X - Finish.X) * (1/time_frame)
we want to find
ANGULAR_SPEED.pan(quants/sec) = (Start.pan - /Finish.pan) * (1/time_frame)(?)
where "physics" (and its variable frame rates) happens between "Start" and "Finish".
Wouldnt using time_step give smoother results?
I still have difficulties with time_step, time_fame, & time_smooth.

Thats what I understand theDust to want.

Yes, my previous code was in error, it should have been vec_scale(Rot_Speed, (1/time_frame));

Last edited by EvilSOB; 04/06/09 14:15. Reason: modify question to add time_step

"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Physics cause difficulties measuring entity rotational speeds [Re: EvilSOB] #259712
04/07/09 10:32
04/07/09 10:32
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Originally Posted By: EvilSOB

Thats what I understand theDust to want.

You know better then me what I want now wink

Ok,
vec_scale(Rot_Speed, (1/time_frame));
seems to improve the calculation, its more stable.
BUT the sign of the speed (very very very important) is switching all the time.
And its switching in a linear way. When the object is turning slow its switching slow and when its fast its switching fast. The sign should be the direction of the speed eek

You can try it out with my demo above.

Re: Physics cause difficulties measuring entity rotational speeds [Re: theDust] #259717
04/07/09 10:39
04/07/09 10:39
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thats because when you f.i. add 10 to an angle of 355, the result is 5 degrees.

Re: Physics cause difficulties measuring entity rotational speeds [Re: theDust] #259744
04/07/09 13:11
04/07/09 13:11
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
But without physics the direction of the speed gets calculated correctly. Actually we worked this angle-problem out (or not ?):

(Quote EvilSOB http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=257365&page=2)
vec_diff ignores the switching between 0...360 or -180...180 of the angles, when these values are being stored in a manually created VECTOR, they wont be treated as angles, and therefore wont suffer the +180, -180 clipping.

Maybe that's not he whole story ?


Moderated by  old_bill, Tobias 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1