Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Akow), 1,371 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
one object rotating around another wih vec_rotateaxis #332931
07/13/10 01:18
07/13/10 01:18
Joined: Jan 2002
Posts: 300
Usa
Rich Offline OP
Senior Member
Rich  Offline OP
Senior Member

Joined: Jan 2002
Posts: 300
Usa
Hi,

I am having trouble getting this to work properly, so I assume I am doing it wrong. I have two objects, one one which I need to rotates around the axis of another. I thought the function vec_rotateaxis did this, but it doesn't seem to be working as I expected. It seems to rotate it around the level's axis, but I am sure I am doing it incorrectly. Any suggestions would be appreciated, thanks!


Object B needs to rotate around Object A's (roll) Axis.


A8 com / A7 free
Re: one object rotating around another wih vec_rotateaxis [Re: Rich] #332934
07/13/10 02:30
07/13/10 02:30
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi, this code rotates 'you' around 'me'.

Code:
vec_diff ( vtemp, you.x, my.x ); 
vec_rotate ( vtemp, vector ( 0, AngSpeed * time_step, 0 ) );
// or
// vec_rotateaxis ( vtemp, vector ( 0, 1, 0 ), AngSpeed * time_step );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );



PD: rotation around Y axis is tilt wink

EDITED*Re: one object rotating around another wih vec_rotateaxis [Re: txesmi] #332977
07/13/10 11:42
07/13/10 11:42
Joined: Jan 2002
Posts: 300
Usa
Rich Offline OP
Senior Member
Rich  Offline OP
Senior Member

Joined: Jan 2002
Posts: 300
Usa
Originally Posted By: txesmi
Hi, this code rotates 'you' around 'me'.

Code:
vec_diff ( vtemp, you.x, my.x ); 
vec_rotate ( vtemp, vector ( 0, AngSpeed * time_step, 0 ) );
// or
// vec_rotateaxis ( vtemp, vector ( 0, 1, 0 ), AngSpeed * time_step );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );



PD: rotation around Y axis is tilt wink


Thanks laugh I will test those out soon! Much appreciated!

And about the tilt thing, oops! I made a mistake, was in a hurry wink.

EDIT******

It seems to be working :), but the object also slowly spirals inward towards the axis. I'll keep playing with it.

Last edited by Rich; 07/13/10 12:17.

A8 com / A7 free
Re: one object rotating around another wih vec_rotateaxis [Re: Rich] #332987
07/13/10 13:29
07/13/10 13:29
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
blush you'll need to normalize

Code:
vec_diff ( vtemp, you.x, my.x ); 
vec_rotate ( vtemp, vector ( 0, AngSpeed * time_step, 0 ) );
// or
// vec_rotateaxis ( vtemp, vector ( 0, 1, 0 ), AngSpeed * time_step );
vec_normalize ( vtemp, Radius );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );



or use a variable as angle holder

Code:
nAngle += AngSpeed * time_step;
nAngle %= 360;
vec_for_angle ( vtemp, vector ( 0, nAngle, 0 ) );
vec_normalize ( vtemp, Radius );
vec_add ( vtemp, my.x );
vec_set ( you.x, vtemp );



Salud!


Re: EDITED*Re: one object rotating around another wih vec_rotateaxis [Re: txesmi] #332990
07/13/10 13:48
07/13/10 13:48
Joined: Jan 2002
Posts: 300
Usa
Rich Offline OP
Senior Member
Rich  Offline OP
Senior Member

Joined: Jan 2002
Posts: 300
Usa
Works perfect! Thanks again grin!!


A8 com / A7 free

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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