Raised This Month: $ Target: $400
 0% 

Calculating velocity from angles


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Blinx
Senior Member
Join Date: Oct 2013
Old 03-01-2017 , 12:34   Calculating velocity from angles
Reply With Quote #1

How do I calculate an entity's velocity if I want to push it in a direction with given angles? FF2 partially has the answer but not for the Z velocity:
PHP Code:
velocity[0]+=Cosine(DegToRad(angles[0]))*Cosine(DegToRad(angles[1]))*500*multiplier;
velocity[1]+=Cosine(DegToRad(angles[0]))*Sine(DegToRad(angles[1]))*500*multiplier;
velocity[2]=(750.0+175.0*charge/70+2000)*multiplier
Blinx is offline
Weetabix
Member
Join Date: Feb 2017
Location: United Kingdom
Old 03-01-2017 , 13:59   Re: Calculating velocity from angles
Reply With Quote #2

Maybe:

PHP Code:
stock void AnglesToVelocity(float vAngles[3], float fScalefloat vOut[3])
{
    
float vDirection[3];
    
GetAngleVectors(vAnglesvDirectionNULL_VECTORNULL_VECTOR);
    
    
ScaleVector(vDirectionfScale);
    
    
fOut vDirection;

Weetabix is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 03-02-2017 , 11:36   Re: Calculating velocity from angles
Reply With Quote #3

I have this, which I happen to use for some things.

PHP Code:
stock AnglesToVelocity(Float:fAngle[3], Float:fVelocity[3], Float:fSpeed 1.0)
{
    
fVelocity[0] = Cosine(DegToRad(fAngle[1]));
    
fVelocity[1] = Sine(DegToRad(fAngle[1]));
    
fVelocity[2] = Sine(DegToRad(fAngle[0])) * -1.0;
    
    
NormalizeVector(fVelocityfVelocity);
    
    
ScaleVector(fVelocityfSpeed);

I dunno the difference.
__________________

Last edited by Chdata; 03-02-2017 at 11:37.
Chdata is offline
Blinx
Senior Member
Join Date: Oct 2013
Old 03-03-2017 , 15:49   Re: Calculating velocity from angles
Reply With Quote #4

Weetabix' solution is correct and works dandy, ty for that.
Blinx is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 21:08.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode