Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Rotation speed #257365
03/22/09 22:15
03/22/09 22:15
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Hi, I need the rotation speed (x,y,z-vector) of an object. I know how to calculate speed in general:
Code:
while(1) 
{
  copy = my.x;
  wait(1);
  speedX = my.x - copy; 
  wait(1);
}

The problem is that the pan, roll and tilt takes values that are going up and down and up and down (0=>360=>0 or 0=>90=>0=>-90 or 0=>180=>-180=>0). It's not possible to calculate the right speed then. Any idea ?

Re: Rotation speed [Re: theDust] #257367
03/22/09 22:41
03/22/09 22:41
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
You only need the difference of both values.

abs() gives you always the positive value, independently of the sign of your value.

"speedX = abs(my.pan - copy); "

Re: Rotation speed [Re: Pappenheimer] #257411
03/23/09 09:30
03/23/09 09:30
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Additionally you can also use ang() to shift the angles into an -180 to 180 range.
See: http://www.conitec.net/beta/avar-ang.htm

Re: Rotation speed [Re: Xarthor] #257473
03/23/09 14:06
03/23/09 14:06
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Ok, but I need the exact vector. For example:
x: 0,5 y: -0,3 z: 0,1
A negative rotation is needed to know if the object is turning the other way.

"tilt" is a bit weird, it goes:
0 up to 179.999 and then it switchs to -179.999 and then up to 0 again. So the difference is wrong when one variable is in the positive area and one in the negative. For example:
copy = 179
my.pan = -160
speedX = abs(my.pan - copy);
SpeedX is 339 then.

It's all a bit more complex as it seems frown

Re: Rotation speed [Re: theDust] #257476
03/23/09 14:24
03/23/09 14:24
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
abs() gives you the amount of the speed.
sign() gives you the sign.

Maybe, you can explain what you want to achieve in the end.
As long as you speak of speed, I understand that you want to know an amount, because minus or plus is about the 'direction' of a speed.

To get the differences of whole vector:

vec_set(vector_of_copied_speed, my.pan);
wait(1);
vec_diff(vector_of_speed, vector_of_copied_speed, my.pan);

Re: Rotation speed [Re: Pappenheimer] #257482
03/23/09 14:53
03/23/09 14:53
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Oh sorry, I see...I want the speed and the direction in one ^^
x: 0,5 y: -0,3 z: 0,1
0,5 rotation speed in x-direction, -0.3 rotation speed in y-direction and 0.1 rotation speed in y-direction.
Hmmm...is that possible ?

Re: Rotation speed [Re: theDust] #257543
03/23/09 20:52
03/23/09 20:52
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Its already there using Pappenheimer's vec_diff. Lets say the result of the formula is like so.
vector_of_speed.x = -5
vector_of_speed.y = 10
vector_of_speed.z = 15
That means the object has a
X-SPEED = rotating at 5 degrees per frame.(because abs(X) = 5)
X-DIRECTION = rotating anti-clockwise (because X is a negative number)
Y-SPEED = tilting at 10 degrees per frame.(because abs(Y) = 10)
Y-DIRECTION = tilting clockwise(upwards?) (because Y is a positive number)
Z-SPEED = tilting at 15 degrees per frame.(because abs(Z) = 15)
Z-DIRECTION = rolling clockwise (because Z is a positive number)


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Rotation speed [Re: EvilSOB] #257691
03/24/09 22:10
03/24/09 22:10
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
vec_set(vector_of_copied_speed, my.pan) creates really weird values, not very usefull ^^

With "speed = abs(my.pan - copy)" I can't get the direction, but its the (only ?) way to calculate the speed. And tilt and roll are again different things, with values that are not only going down and up but that are jumping around.

It's possible to calculate the speed and direction without pan, tilt and roll ? Cause these properties are behaving very unhandy.


Last edited by theDust; 03/24/09 22:12.
Re: Rotation speed [Re: theDust] #257694
03/24/09 22:43
03/24/09 22:43
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Not really, because pan, tilt, and roll ARE the rotation you are trying to measure.
So how can we measure anything if we ignore them?

Try taking a step back, and try to get the problem sorted out for JUST pan.
And extend the coding to tilt and roll only after PAN is working.

Also, try re-phrasing your question again. I think all us "experts" may have mis-understood
what it is that you actually want.
Do you want to find out how fast it is turning?
OR
Do you want to know its speed IN-SPACE, as in a sum of SpeedX & SpeedY & SpeedZ = TrueSpeed?
(that is its speed as a true distance, as-the-crow-flies)


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Rotation speed [Re: EvilSOB] #257776
03/25/09 13:19
03/25/09 13:19
Joined: Mar 2008
Posts: 104
theDust Offline OP
Member
theDust  Offline OP
Member

Joined: Mar 2008
Posts: 104
Ok, taking a step back is a good idea wink At the end I want a vector that does exactly this what you wrote:

X-SPEED = rotating at 5 degrees per frame.(because abs(X) = 5)
X-DIRECTION = rotating anti-clockwise (because X is a negative number)
Y-SPEED = tilting at 10 degrees per frame.(because abs(Y) = 10)
Y-DIRECTION = tilting clockwise(upwards?) (because Y is a positive number)
Z-SPEED = tilting at 15 degrees per frame.(because abs(Z) = 15)
Z-DIRECTION = rolling clockwise (because Z is a positive number)

(The speed in-space is already done ^^)

Ok, we can get the speed of the rotation (of pan) and we need abs() for that. But the direction of the speed cannot be calculated with this method, because the differents between the pan's can be negative or positive, independently from the direction.

Page 1 of 2 1 2

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