Gamestudio Links
Zorro Links
Newest Posts
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
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Angular Velocity #15560
05/08/03 04:04
05/08/03 04:04
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline OP
Senior Expert
fastlane69  Offline OP
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
I'm trying to get an angular velocity reading fromt he phent_getvelocity() function. According to manual:

----------------------------------------------
If pointLocal is (0,0,0) this returns the linear velocity of the object. Otherwise it's a combination of linear and angular velocity at the given distance from the center.
-------------------------------------------------

How I read this is that if I place my vecpointlocal on my center of mass, I only get a linear velocity reading. Makes sense and works.

However, if I displace vecpointlocal, say 100 units on the x-axis, I expect to get some angular velocity information. I have torqued my entity, it's actually rotating, but I'm getting no angular velocity information. I have tried several approaches and nothing.

Is it angular velocity or tangential velocity that is returned when vecpointlocal DNE null?

(Vangular= Vtangential/Radius)

Since you have to displace vecpointlocal to get an "angular" velocity reading, I suspect it's tangential, not angular.

I've tried vec_to_angle() on vecoutvelocity while rotating but not displaceing and nothing.

Re: Angular Velocity #15561
05/08/03 06:10
05/08/03 06:10

A
Anonymous
Unregistered
Anonymous
Unregistered
A



It should be tangential velocity: vLinear+ (Crossproduct(vAngular x vDistance))

I have tested this function a while ago and it worked. Let me check if it has become broken..

Re: Angular Velocity #15562
05/08/03 13:18
05/08/03 13:18
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline OP
Senior Expert
fastlane69  Offline OP
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Just so I understand, to get angular velocity:

a) Get linear velocity at vecpointlocal = (0,0,0).

b) Get a velocity at vecpointlocal =(100,0,0).

c) Subtract a) from b). This leaves me with tangential velocity.

d) Divide result by radius, in this example, 100.

This is what I think I'm doing with:

----------------------------------------
//fixed_ang is a vector set to 100 units
//on the x axis. null_vec is zero.

phent_getvelocity(my,temp_vel1,null_vec);
phent_getvelocity(my,temp_vel2,fixed_ang);

//Subtracting a) from b)
vec_sub(temp_vel2,temp_vel1);

//Dividing by distance (100 units)
vec_scale(temp_vel2, .01);

//Copies into a skill displayed on panel
vec_set(player.ang_velocity_x,temp_vel2);
-------------------------------------------

......and nothing. I pick up linear velocity fine, but no angular velocity what so ever when I torque my entity up with addtorquelocal.

Re: Angular Velocity #15563
05/09/03 07:30
05/09/03 07:30
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline OP
Senior Expert
fastlane69  Offline OP
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Anyone else use the phent_getvelocity function? If so, are you getting a reading when vecpointlocal DNE 0?

I swear I'm getting nothing or just plain don't understand how to get an angular velocity from the _getvelocity function...

Re: Angular Velocity #15564
05/09/03 08:25
05/09/03 08:25

A
Anonymous
Unregistered
Anonymous
Unregistered
A



@fastlane:
Your algorithm seems right, so it should be working. This problem is on my list of things to check, but that list has some 10 other entries in front of it [Frown]

Re: Angular Velocity #15565
05/09/03 08:46
05/09/03 08:46
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline OP
Senior Expert
fastlane69  Offline OP
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Hi Marco

Thanks for your personal attention on the matter.

Totally understand your busy... compounded by the fact that not many people are using said feature.

We'll see if some solution doesn't present itself soon. Could be some local vs. global issues, I don't know.

Thanks and look forward to your reply!!!
In the meantime, if any users have any advice, please please pose! [Smile]

Re: Angular Velocity #15566
05/09/03 10:24
05/09/03 10:24

A
Anonymous
Unregistered
Anonymous
Unregistered
A



My mistake. A6.0 ignores the location parameter, and thus returns the value for phent_getvelocity(myObject, temp, vector(0,0,0));
This will be fixed in A6.1

Re: Angular Velocity #15567
05/09/03 14:07
05/09/03 14:07
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline OP
Senior Expert
fastlane69  Offline OP
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Gotcha!

Thanks Marco.... will start working on a stop gap solution in the meantime....

Re: Angular Velocity [Re: fastlane69] #15568
03/04/04 09:27
03/04/04 09:27
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline OP
Senior Expert
fastlane69  Offline OP
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
It's been 10 months now and 6.1 is here and gone, so it's time to reopen this thread.

1) Off-center phent_getvel() does seem to be working now. When I use the approach above (sample at center and offset; subtract and rescale), I do get what seems to be a constant angular velocity....but...

2) This velocity seems to be what I can best describe as globally referenced (?). Hence, I may see ang_velocity_x at 35 q/s and zero ang_velocity_y and later my ang_velocity_y is at 35 and _x is at 0, which is consitent with a tangential angular velocity vector attached at a fixed radius and rotating relative to a global fixed coordinate system.

Short of calculating the speed and then artificially inserting a direction, is there anyway that I can get angular velocity relative to a euler angle or relative to a local coordinate? I would really like to make one call and get a singular constant value; so if I'm rotating perfectly around the z-axis, similar to the ubiquious figure skater doing turns, I could get a constant value for their rotational speed and not a constantly changing one.

I know the mathematical way get a constant value; just want to know if there is an easy call or couple of calls I can make and avoid some of the nasty maths that will crop up in dealing with cross products. Or perhaps I'm missing the point altogether; either way, I'd like to hear what others and Conitec has to say.


Re: Angular Velocity [Re: fastlane69] #15569
03/10/04 13:28
03/10/04 13:28
Joined: Dec 2003
Posts: 61
Funkytown, USA
feature_creature Offline
Junior Member
feature_creature  Offline
Junior Member

Joined: Dec 2003
Posts: 61
Funkytown, USA
I think you're right.
The formula above gives the tagential velocity only if the angular velocity vector is perpendicular to the vector from the origin to the point being tested (radius).

It is much more complicated in the general case.

It seems easier to manually keep track of the angular difference between the last frame and the current frame and divide by time -- voila: angular velocity in degrees per second.

One thing I notice about this last method:
It works fine when I don't have physics turned on.
But when physics is turned on, and I set damping to 0, gravity to 0, and apply an initial torque in more than one direction -- the angular velocity is not constant.

This makes me suspicious about the physics system!

This code produces results I would expect:
Code:

string db[15];

action rotate {
var prev[3];
var total = 0;
vec_set(prev,my.pan);

while(1) {
vec_diff( temp, my.pan, prev );
vec_set(prev,my.pan);
vec_scale( temp, 1/time );
total = vec_length(temp);

str_for_num( db, total );
draw_text( db, 50, 170, vector(100,100,255));

str_for_num( db, temp[0] );
draw_text( db, 50, 50, vector(255,100,100));
str_for_num( db, temp[1] );
draw_text( db, 50, 90, vector(255,100,100));
str_for_num( db, temp[2] );
draw_text( db, 50, 130, vector(255,100,100));

my.pan += 3*time;
my.tilt += 3*time;
my.roll += 3*time;
wait(1);
} //while

} //



Here is the "equivalent" with physics:
Code:

action physics_rotate {
ph_setgravity( nullvector );
phent_settype( my, PH_RIGID, PH_BOX );
phent_setmass( my, 1, PH_SPHERE );
phent_setdamping( my, 0, 0 );

var prev[3];
var total = 0;

vec_set(prev,my.pan);

phent_addtorqueglobal( my, vector( 30, 30, 30 ) );

//for this to work make sure object is not on the floor
while(1) {
vec_diff( temp, my.pan, prev );
vec_set(prev,my.pan);
vec_scale( temp, 1/time );
total = vec_length(temp);

str_for_num( db, total );
draw_text( db, 50, 170, vector(100,100,255));

str_for_num( db, temp[0] );
draw_text( db, 50, 50, vector(255,100,100));
str_for_num( db, temp[1] );
draw_text( db, 50, 90, vector(255,100,100));
str_for_num( db, temp[2] );
draw_text( db, 50, 130, vector(255,100,100));

wait(1);
} //while

} //



The physics version fluctuates much more -- even with mass type set to PH_SPHERE.

Now, with the same settings and mass type set to PH_BOX, the model will actually spin out of control and then freeze within a few seconds. I know that this has something to do with setting damping to 0, but that would be case in a space game, right?

So, even if your code accurately measures angular velocity, when you're using physics, it will still fluctuate a lot so it may not be a reliable measure for determining how constant angular velocity is.

That's enough research for one night!

(Should be 1/time -- not time!)






Last edited by feature_creature; 03/11/04 01:16.

Curious, but not overwhelmed...demlehwrevo ton tub ,suoiruC
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

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