Raised This Month: $ Target: $400
 0% 

Solved Line僕ine intersection


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-03-2019 , 06:34   Re: Line僕ine intersection
Reply With Quote #2

Check this out I wrote it on phone and didn't test tell me if it has any bug, basically it will return bitsum value depends on the intersection in each axis and it also return the intersection point.

PHP Code:

#define X_AXIS 0
#define Y_AXIS 1
#define Z_AXIS 2

#define VECTORS_DONT_INTERSECT 0
#define VECTORS_INTERSECT_XY (1<<0)
#define VECTORS_INTERSECT_YZ (1<<1)
#define VECTORS_INTERSECT_ZX (1<<2)
#define VECTORS_INTERSECT_3D (1<<0)|(1<<1)|(1<<2)

new const iaDimensions[ ][ ] = {
     { 
X_AXISY_AXIS },
     { 
Y_AXISZ_AXIS },
     { 
Z_AXISX_AXIS }
}

DoesVectorsIntersect(const Float:fV1Init[3], const Float:fV1Final[3], const Float:fV2Init[3], const Float:fV2Final[3], Float:tolerance=1.0Float:fPoint[3])
{
    new 
Float:fFactorV1[3], Float:fFactorV2[3], g_return;
    
    for(new 
Float:XFloat:YV1Float:YV2Float:fDis_xv[2], Float:fDis_yv[2], i3i++)
    {
          
fDis_xv[0] = (fV1Final[iaDimensions[i][0]] - fV1Init[iaDimensions[i][0]]);
          
fDis_xv[1] = (fV2Final[iaDimensions[i][0]] - fV2Init[iaDimensions[i][0]]);
          
fDis_yv[0] = (fV1Final[iaDimensions[i][1]] - fV1Init[iaDimensions[i][1]]);
          
fDis_yv[1] = (fV2Final[iaDimensions[i][1]] - fV2Init[iaDimensions[i][1]])

          if(
fDis_xv[0] != 0.0fFactorV1[i] = fDis_yv[0] / fDis_xv[0];
          if(
fDis_xv[1] != 0.0fFactorV2[i] = fDis_yv[1] / fDis_xv[1];
          
          if( (
fDis_yv[0] == 0.0 && fDis_yv[1] == 0.0) || (!fDis_xv[0] && !fDis_xv[1]) || (fFactorV1[i] == fFactorV2[i] && fFactorV1[i] != 0.0) ) continue;

          if((
fFactorV1[i] == fFactorV2[i] && fFactorV1[i] != 0.0)) = ((fV1Init[iaDimensions[i][0]] * fFactorV1[i]) - (fV2Init[iaDimensions[i][0]] *  fFactorV2[i]) + fV2Init[iaDimensions[i][1]] - fV1Init[iaDimensions[i][1]]) / (fFactorV1[i] - fFactorV2[i]);
          else 
fV1Final[iaDimensions[i][0]];
          
YV1 = (fFactorV1[i] * ( fV1Init[iaDimensions[i][0]] ) + fV1Init[iaDimensions[i][1]]);
          
YV2 = (fFactorV2[i] * ( fV2Init[iaDimensions[i][0]] ) + fV2Init[iaDimensions[i][1]]);

          if( 
YV1 == YV2 || ((YV1 tolerance) <= YV2 <= (YV1 tolerance)) || ((YV2 tolerance) <= YV1 <= (YV2 tolerance)) )
           {
                   
fPoint[iaDimensions[i][0]] = X;
                   switch( 
)
                   {
                          case 
0g_return |= VECTORS_INTERSECT_XY;
                          case 
1g_return |= VECTORS_INTERSECT_YZ;
                          case 
2g_return |= VECTORS_INTERSECT_ZX;
                   }
           }

           
    }
    return 
g_return;

__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-23-2021 at 05:06.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
 



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 17:21.


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