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
Simple question. #324274
05/20/10 05:24
05/20/10 05:24
Joined: May 2010
Posts: 4
dallas,tx
Y
yokel Offline OP
Guest
yokel  Offline OP
Guest
Y

Joined: May 2010
Posts: 4
dallas,tx
Hi everyone, I've been playing aroung with gamestudio for about a month and this is my first post. I have a simple question. I would like to convert my local vectors to global vectors to perform a calculation, but I'm having problems with the angle system, specifcally that different angles can represent the same vector. I can get one vector easily, but the other two elude me. Can anyone help?

Re: Simple question. [Re: yokel] #324329
05/20/10 13:09
05/20/10 13:09
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
???

Re: Simple question. [Re: Widi] #324334
05/20/10 13:18
05/20/10 13:18
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
When you convert an angle (i.e. pan, tilt and roll) to a position vector you've got an infinite number of position vectors that correspond to this angle. So I guess there is a misunderstanding here. Can you explain what you mean with "the other two" ?


Always learn from history, to be sure you make the same mistakes again...
Re: Simple question. [Re: Uhrwerk] #324425
05/20/10 18:50
05/20/10 18:50
Joined: May 2010
Posts: 4
dallas,tx
Y
yokel Offline OP
Guest
yokel  Offline OP
Guest
Y

Joined: May 2010
Posts: 4
dallas,tx
Sure. It's easy enough to translate one vector from local to global by simply applying the calculation:
x = cosv(my.pan) * cosv(my.tilt)
y = sinv(my.pan) * cosv(my.tilt)
z = sinv(my.tilt)
vector(x,y,z)

This works everytime and refers to the vector that extends along the x-axis at the identity matrix. The other two vectors, the ones that point along the Y and Z axes are more elusive because the effect of roll has to be considered along with pan and tilt, and ??the order they were applied in??.

I have been combing the internet for a solution, and also the several math books I have and they all generally give me the same recommendation: these "Euler angles" are a poor choice to represent 3d orientation, choose something else. I'm using what I'm given, do I have another choice? Is there a simpler way to convert from local to global?

Re: Simple question. [Re: yokel] #324430
05/20/10 19:42
05/20/10 19:42
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
why don't you use vec_rotate()?

euler angles are the most intuitive representation to humans and in many cases they work just fine. if you do something like a space ship simulator where you always have arbitrary rotations about 3 axes at the same time then you have to use something else since euler angles will cause gimbal lock.

Re: Simple question. [Re: ventilator] #324437
05/20/10 20:17
05/20/10 20:17
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Are you aware of the engine functions vec_for_ent and vec_to_ent ?


Always learn from history, to be sure you make the same mistakes again...
Re: Simple question. [Re: Uhrwerk] #324469
05/21/10 00:13
05/21/10 00:13
Joined: May 2010
Posts: 4
dallas,tx
Y
yokel Offline OP
Guest
yokel  Offline OP
Guest
Y

Joined: May 2010
Posts: 4
dallas,tx
Thanks, guys, for the suggestions...

@ventilator: the problem I'm having with vec_rotate is that it still uses Euler angles and they're so hard to predict. Some further help would be appreciated.

@Uhrwerk: no, I wasn't aware of those functions, thanks for bringing them to my attention. I'm not sure its what I'm looking for but its definately worth a look.

Last edited by yokel; 05/21/10 00:18.
Re: Simple question. [Re: yokel] #324471
05/21/10 00:51
05/21/10 00:51
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
if you're trying to move away from Euler angles have you looked at quaternion angles?

see e.g vec_rotateaxis

Re: Simple question. [Re: MrGuest] #324486
05/21/10 07:24
05/21/10 07:24
Joined: May 2002
Posts: 7,441
ventilator Offline
Senior Expert
ventilator  Offline
Senior Expert

Joined: May 2002
Posts: 7,441
vec_rotate() isn't hard to predict.
vec_for_ent() does the same but also takes position and scale into account.

you should describe what exactly you are trying to do. what do you need this for? then it is easier to help.

Re: Simple question. [Re: ventilator] #324560
05/21/10 18:05
05/21/10 18:05
Joined: May 2010
Posts: 4
dallas,tx
Y
yokel Offline OP
Guest
yokel  Offline OP
Guest
Y

Joined: May 2010
Posts: 4
dallas,tx
My character moves when the stick is pushed down, then when released it's momentum tapers off. this is fine until it hits a wall and the movement stops but the momentum calculaions continue to taper off. So, obviously, momentum in the direction of impact needs to be canceled, but not in other directions, meaning that only one or two elements of a local movement vector need to be corrected. If I can break down each element into its XYZ components I can perform a dot product comparison with hit data provided by c_move and discover how much each vector needs to be corrected.

I have to disagree about vec_rotate, I can get the rotation to work from one particular position to another, but as I try to do it dynamically thru a full range of movement it will work in certain portions of the arc and not others.

I still haven't had time to try and implement vec_for_ent yet, but I will soon.

Thanks for your interest, any help will be greatly appreciated.


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