Raised This Month: $ Target: $400
 0% 

Vector to angles, angles to vector [Solved]


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
.Dare Devil.
Veteran Member
Join Date: Sep 2010
Old 01-23-2014 , 19:55   Vector to angles, angles to vector [Solved]
Reply With Quote #1

Hello Alliedmodders!

Quote:
Solved: https://forums.alliedmods.net/showth...51#post2090551
Also look those are things what you may looking for
vector.inc
native vector_to_angle(const Float:fVector[3], Float:vReturn[3]);
native angle_vector(const Float:vector[3], FRU, Float:ret[3]);

After some long research ive been able to create this:
PHP Code:
// v - direction, an - angles
stock vector_to_anglesFloat:v[3], Float:an[3] )
{
    
an[0] = floatsqroot((v[0]*v[0]) + (v[1]*v[1])) / v[2]
    
an[1] = floatatan(v[1]/v[0], degrees)
    

Problem is that this wont work.
an[0] wont work at all.
an[1] is correct in 180 degrees.
90 > will turn -90 not 91
-90 < will turn 90 not -91

uh. Some much tries and no solution : /

I dont have code for 'angles to vector' yet. Never tried it because working on this stupid thing what eat all my time.

Also. I know there are functions for this but for where i want, cant use those. There are no amxmodx functions.

Edit:
PHP Code:
static cell AMX_NATIVE_CALL vector_to_angle(AMX *amxcell *params)
{
    
cell *cAddr get_amxaddr(amxparams[1]);

    
REAL fX amx_ctof(cAddr[0]);
    
REAL fY amx_ctof(cAddr[1]);
    
REAL fZ amx_ctof(cAddr[2]);

    
Vector vVector Vector(fXfYfZ);
    
Vector vAngle Vector(000);
    
VEC_TO_ANGLES(vVectorvAngle); // where it came from?

    
cell *vRet get_amxaddr(amxparams[2]);

    
vRet[0] = FloatToCell(vAngle.x);
    
vRet[1] = FloatToCell(vAngle.y);
    
vRet[2] = FloatToCell(vAngle.z);

    return 
1;


Last edited by .Dare Devil.; 01-24-2014 at 20:01. Reason: Solved
.Dare Devil. is offline
 



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 10:04.


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