Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
3 registered members (Grant, TipmyPip, AndrewAMD), 12,724 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Trigonometry help. angle effecting X/Y movment? #151103
08/30/07 05:51
08/30/07 05:51
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
I knew I should have paid more attention in trig' class. But for some reason I cant seem to remember this rather simple problem.

I have an angle value (-180 to 180) from the camera.pan property. I want to change the application of x/y movment so that it is relitive to this angle.


my_speed.x = 25 * (key_cur - key_cul) * cos(camera.pan);
my_speed.y = 25 * (key_cuu - key_cud) * sin(camera.pan);


I know this isn't the full calculation I need, but I realy cant think of what I'm missing. Anyone less tired then myself remeber trig 101?

Last edited by jfizer; 08/30/07 06:37.
Re: Trigonometry help. angle effecting X/Y movment [Re: jfizer] #151104
08/30/07 07:40
08/30/07 07:40
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
Part of the problem is that I need to apply velocity to both the X and Y axis for just a single direction of movement.



my_speed.x = 25 * (key_cuu - key_cud) * cos(camera.pan);
my_speed.y = 25 * (key_cuu - key_cud) * sin(camera.pan);


This works for forwards and backwards, but how do I then factor in lateral movment (left & right)? Basic sin/cos calculations are for a single vector of force along an angle. Adding in a second vector makes my brain hurt.

perhaps...

my_speed.x = (key_cuu - key_cud) * cos(camera.pan);
my_speed.y = (key_cuu - key_cud) * sin(camera.pan);
my_speed.x += (key_cul - key_cur) * sin(camera.pan);
my_speed.y += (key_cul - key_cur) * cos(camera.pan);
my_speed.x *= 25;
my_speed.y *= 25"

Or somthing to that effect?

Re: Trigonometry help. angle effecting X/Y movment [Re: jfizer] #151105
08/30/07 07:52
08/30/07 07:52
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
You could create a vector with the x and y components to the speed you want, and rotate it around the entity with vec_rotate.

Re: Trigonometry help. angle effecting X/Y movment [Re: Excessus] #151106
08/30/07 08:32
08/30/07 08:32
Joined: Aug 2007
Posts: 21
J
jfizer Offline OP
Newbie
jfizer  Offline OP
Newbie
J

Joined: Aug 2007
Posts: 21
Quote:

You could create a vector with the x and y components to the speed you want, and rotate it around the entity with vec_rotate.




Well that sure is simpler. Almost feels like cheating.


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

Gamestudio download | 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