Raised This Month: $51 Target: $400
 12% 

Rotating Vector


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-13-2020 , 05:06   Rotating Vector
Reply With Quote #1

Hello.

I was wondering how I will be able to rotate a vector up and down and also roll it right or left. I heard about rotation matrices but so far I'm so confused about it.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-13-2020 , 07:47   Re: Rotating Vector
Reply With Quote #2

Multiply the vector by a rotation matrix for the corresponding plane.
__________________

Last edited by HamletEagle; 04-13-2020 at 07:47.
HamletEagle is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-13-2020 , 10:55   Re: Rotating Vector
Reply With Quote #3

Quote:
Originally Posted by HamletEagle View Post
Multiply the vector by a rotation matrix for the corresponding plane.
so far nothing but fails

PHP Code:
#define Cosine(%1) floatcos(%1,degrees)
#define Sine(%1) floatsin(%1,degrees)

//  ......

        
case DRONE_CONTROL:
        {
            static 
Float:fAngle[2] = {0.00.0};
            
fAngle[0] = entity_get_float(entDRONE_ROTATION_UPWARDS);
            
fAngle[1] = entity_get_float(entDRONE_ROTATION_SIDEWAY);
            
            
entity_get_vector(entEV_VEC_anglesfvAngles);
            
            
angle_vector(fvAnglesANGLEVECTOR_FORWARDfVector);
            
xs_vec_mul_scalar(fVectorfSpeedfVector);
            
xs_vec_add(fVectorfVelocityfVelocity);
            
            if(
iButtons IN_FORWARD)
            {
                
entity_set_float(entEV_FL_speedfloatmin(fSpeed 10.0fMaxSpeed));
            }
            else if(
iButtons IN_BACK)
            {
                
entity_set_float(entEV_FL_speedfloatmax(fSpeed 10.00.01));
            }
            
            if(
iButtons IN_MOVERIGHT)
            {
                
fAngle[1] += 0.8;
                
//if(fAngle[1] >= 360.0) fAngle[1] -= 360.0;
                
                
entity_set_float(entDRONE_ROTATION_SIDEWAYfAngle[1]);
            }
            else if(
iButtons IN_MOVELEFT)
            {
                
fAngle[1] -= 0.8;
                
//if(fAngle[1] <= 0.0) fAngle[1] += 360.0;
                
                
entity_set_float(entDRONE_ROTATION_SIDEWAYfAngle[1]);
            }
            
            if(
iButtons IN_RIGHT)
            {
                
angle_vector(fvAnglesANGLEVECTOR_RIGHTfVector);
                
xs_vec_mul_scalar(fVectorfSpeed 0.01fVector);
                
xs_vec_add(fVectorfVelocityfVelocity);
            }
            else if(
iButtons IN_LEFT)
            {
                
angle_vector(fvAnglesANGLEVECTOR_RIGHTfVector);
                
xs_vec_mul_scalar(fVector, -fSpeed 0.01fVector);
                
xs_vec_add(fVectorfVelocityfVelocity);
            }
            
            if(
iButtons IN_DUCK)
            {
                
fAngle[0] -= 0.5;
                
//if(fAngle[0] >= 360.0) fAngle[0] -= 360.0;
                
entity_set_float(entDRONE_ROTATION_UPWARDSfAngle[0]);
            }
            else if(
iButtons IN_JUMP)
            {
                
fAngle[0] += 0.5;
                
entity_set_float(entDRONE_ROTATION_UPWARDSfAngle[0]);
            }
            
            static 
Float:fLenFloat:xFloat:yFloat:zFloat:AFloat:B;
            
fLen floatmax(xs_vec_len(fVelocity),0.1);
            
= (fVelocity[0] = fVelocity[0] / fLen);
            
= (fVelocity[1] = fVelocity[1] / fLen);
            
= (fVelocity[2] = fVelocity[2] / fLen);
            
fAngle[0];
            
fAngle[1];
            
            
fvAngles[0] = (Cosine(B)) - (Sine(B));
            
fvAngles[1] = (Cosine(A) * Sine(B)) + (Cosine(A) * Cosine(B)) - (Sine(A));
            
fvAngles[2] = (Sine(A) * Sine(B)) + (Sine(A) * Cosine(B)) + (Cosine(A));
            
            
xs_vec_mul_scalar(fVelocityfSpeedfVelocity);
            
entity_set_vector(entEV_VEC_velocityfVelocity);
            
entity_set_vector(entEV_VEC_anglesfvAngles);
            
entity_set_float(entEV_FL_nextthinkget_gametime() + 0.01);
        } 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-13-2020 at 10:56.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-13-2020 , 19:16   Re: Rotating Vector
Reply With Quote #4

https://forums.alliedmods.net/showth...61#post2502361
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-14-2020 , 05:12   Re: Rotating Vector
Reply With Quote #5

Sorry George but that's not what I needed.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 04-14-2020 , 12:52   Re: Rotating Vector
Reply With Quote #6

Quote:
Originally Posted by georgik57 View Post
Code:
    fVecTemp[0] = 0.0; // forward or backward rolling     fVecTemp[1] = random_num(0, 1) ? 50.0 : -50.0; //random_float(-50.0, 50.0) sideways turning     fVecTemp[2] = 0.0; // sideways rolling
This is what I gave you the link for.
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-14-2020 , 13:39   Re: Rotating Vector
Reply With Quote #7

Quote:
Originally Posted by georgik57 View Post
This is what I gave you the link for.
sadly georgik57 this will not going to work cause im not changing only one angle axis. but two its going to differs in which axis is about to pitch and yaws
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Natsheh
Veteran Member
Join Date: Sep 2012
Old 04-14-2020 , 15:01   Re: Rotating Vector
Reply With Quote #8

can someone translate this sourcepawn plugin to amxx and get the calculations of how is he doing the rotations.

https://forums.alliedmods.net/showthread.php?t=163676
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 04-14-2020 at 15:09.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 04-14-2020 , 15:25   Re: Rotating Vector
Reply With Quote #9

I made a post where I explained how to use a rotation matrix for rotating a lasermine beam. I can't seem to find it again, but maybe you can.
__________________
HamletEagle is offline
SHIELD755
Veteran Member
Join Date: Feb 2018
Location: FROM MARVEL STUDIO
Old 04-14-2020 , 23:21   Re: Rotating Vector
Reply With Quote #10

Quote:
Originally Posted by HamletEagle View Post
I made a post where I explained how to use a rotation matrix for rotating a lasermine beam. I can't seem to find it again, but maybe you can.
Well i remember you explained in a post which was by atthar(i am not sure ) his account is banned and all his posts deleted

I was also searching for it
__________________
SED LYF !!!

Last edited by SHIELD755; 04-14-2020 at 23:23.
SHIELD755 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 09:46.


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