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 );
__________________