3 registered members (7th_zorro, Aku_Aku, 1 invisible),
579
guests, and 1
spider. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Rotation speed
#257365
03/22/09 22:15
03/22/09 22:15
|
Joined: Mar 2008
Posts: 104
theDust
OP
Member
|
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:
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: Xarthor]
#257473
03/23/09 14:06
03/23/09 14:06
|
Joined: Mar 2008
Posts: 104
theDust
OP
Member
|
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
|
|
|
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
Senior Expert
|
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: theDust]
#257543
03/23/09 20:52
03/23/09 20:52
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
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
OP
Member
|
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
Expert
|
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
OP
Member
|
OP
Member
Joined: Mar 2008
Posts: 104
|
Ok, taking a step back is a good idea 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.
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|