Raised This Month: $ Target: $400
 0% 

Get origin from ½ distance


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-04-2010 , 12:31   Re: Get origin from ½ distance
Reply With Quote #3

Code:
new Float:vTraceStart[ 3 ]; new Float:vTraceEnd[ 3 ]; new Float:fDistance; // vTraceStart = "Trace Start" // vTraceEnd = "Trace End" // fDistance = "L" new Float:fOffset = floatmax( ( fDistance / 6.0 ), 76.0 ); new Float:fAngleFormedByPoint = floattan( ( fOffset / ( fDistance / 2.0 ) ), degrees ); new Float:vDirection[ 3 ]; xs_vec_sub( vTraceEnd, vTraceStart, vDirection ); new Float:vAngles[ 3 ]; vector_to_angle( vDirection, vAngles ); // for left fAngleFormedByPoint = vAngles[ 1 ] - fAngleFormedByPoint; while( fAngleFormedByPoint < -180.0 ) {     fAngleFormedByPoint += 360.0; } // end left // for right fAngleFormedByPoint = vAngles[ 1 ] + fAngleFormedByPoint; while( fAngleFormedByPoint > 180.0 ) {     fAngleFormedByPoint -= 360.0; } // end right vAngles[ 1 ] = fAngleFormedByPoint; angle_vector( vAngles, ANGLEVECTOR_FORWARD, vDirection ); new Float:fHypotenuse = floatsqroot( floatpower( fOffset, 2.0 ) + floatpower( ( fDistance / 2.0 ), 2.0 ) ); xs_vec_mul_scalar( vDirection, fHypotenuse, vDirection ); new Float:vCalcOrigin[ 3 ]; xs_vec_add( vTraceStart, vDirection, vCalcOrigin );

EDIT:

Here's Arkshine's method:
Code:
new Float:vTraceStart[ 3 ]; new Float:vTraceEnd[ 3 ]; new Float:fDistance; // vTraceStart = "Trace Start" // vTraceEnd = "Trace End" // fDistance = "L" new Float:fOffset = floatmax( ( fDistance / 6.0 ), 76.0 ); new Float:vDirection[ 3 ]; xs_vec_sub( vTraceEnd, vTraceStart, vDirection ); xs_vec_normalize( vDirection, vDirection ); xs_vec_mul_scalar( vDirection, ( fDistance / 2.0 ), vDirection ); new Float:vCenter[ 3 ]; xs_vec_add( vTraceStart, vDirection, vCenter ); new Float:vAngles[ 3 ]; vector_to_angle( vDirection, vAngles ); angle_vector( vAngles, ANGLEVECTOR_RIGHT, vDirection ); // left xs_vec_mul_scalar( vDirection, -fOffset, vDirection ); // right xs_vec_mul_scalar( vDirection, fOffset, vDirection ); new Float:vCalcOrigin[ 3 ]; xs_vec_add( vCenter, vDirection, vCalcOrigin );
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 03-04-2010 at 12:37.
Exolent[jNr] 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 08:37.


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