Raised This Month: $ Target: $400
 0% 

Circular Rotation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
madeitout
Member
Join Date: Jun 2008
Old 08-11-2009 , 23:09   Circular Rotation
Reply With Quote #1

I have 2 ents and I want 1 to rotate 360 degrees around the other, kind of like the moon orbits around the earth but I need sure how to get the origins.
thank you
madeitout is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-11-2009 , 23:45   Re: Circular Rotation
Reply With Quote #2

Code:
new g_iRotationAngle; new Float:g_fRadius = 100.0; new Float:g_vCenter[ 3 ]; new bool:g_bClockwise; StartRotation( iCenterEntity, iRotatingEntity, Float:fRadius, bool:bClockwise, Float:fSpeed ) {     entity_get_vector( iCenterEntity, EV_VEC_origin, g_vCenter );         g_fRadius = fRadius;         g_bClockwise = bClockwise;         new Float:fCircumference = 2.0 * M_PI * fRadius;         // speed = distance / time     // time = distance / speed         set_task( ( fCircumference / fSpeed ), "TaskDoRotate", iRotatingEntity, _, _, "b" ); } public TaskDoRotate( iEntity ) {     if( g_bClockwise )     {         if( g_iRotationAngle-- <= 0 )         {             g_iRotationAngle = 359;         }     }     else     {         g_iRotationAngle = ++g_iRotationAngle % 360;     }         new Float:vVector[ 3 ];         new iAngle = g_iRotationAngle % 90;         new Float:fSin = 1.0;     new Float:fCos = 1.0;         if( iAngle == 0 )     {         switch( g_iRotationAngle )         {             case 180: fCos = -1.0;             case 270: fSin = -1.0;         }     }     else if( g_iRotationAngle < 90 )     {         // all are positive     }     else if( g_iRotationAngle < 180 )     {         // sin is positive, others negative                 iAngle = 90 - iAngle;         fCos = -1.0;     }     else if( g_iRotationAngle < 270 )     {         // tan is positive, others negative                 fSin = -1.0;         fCos = -1.0;     }     else //if( g_iRotationAngle < 360 )     {         // cos is positive, others negative                 iAngle = 90 - iAngle;         fSin = -1.0;     }         vVector[ 0 ] = floatcos( float( iAngle ), degrees ) * g_fRadius * fCos;     vVector[ 1 ] = floatsin( float( iAngle ), degrees ) * g_fRadius * fSin;         vVector[ 0 ] += g_vCenter[ 0 ];     vVector[ 1 ] += g_vCenter[ 1 ];     vVector[ 2 ] += g_vCenter[ 2 ];         entity_set_origin( iEntity, vVector ); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 08-12-2009 at 02:42.
Exolent[jNr] is offline
madeitout
Member
Join Date: Jun 2008
Old 08-12-2009 , 00:24   Re: Circular Rotation
Reply With Quote #3

much appriciated, +karma
madeitout is offline
madeitout
Member
Join Date: Jun 2008
Old 08-12-2009 , 01:10   Re: Circular Rotation
Reply With Quote #4

it seems that the adjacent angles go opposite ways so if i set it to clock ways, angles < 270 and < 90 rotate clockways and < 360 and < 180 rotate counterclock ways. Viceversa if i set it to counterclockways. any ideas?
madeitout is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-12-2009 , 02:43   Re: Circular Rotation
Reply With Quote #5

Sorry about that. Should be fixed.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply


Thread Tools
Display Modes

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 18:19.


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