Raised This Month: $ Target: $400
 0% 

Distance between two lines


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 09-27-2012 , 19:09   Re: Distance between two lines
Reply With Quote #4

Quote:
Originally Posted by ConnorMcLeod View Post
Try this :

PHP Code:
Float:lines_distance(Float:flPoint1[3], Float:vecDir1[3], Float:flPoint2[3], Float:vecDir2[3])
{
    
xs_vec_normalize(vecDir1vecDir1)
    
xs_vec_normalize(vecDir2vecDir2)
    if( 
xs_vec_equal(vecDir1vecDir2) )
    {
        new 
Float:vecPoint1Point2[3]
        
xs_vec_sub(flPoint2flPoint1vecPoint1Point2)
        
        new 
Float:vecDirCross[3]
        
xs_vec_cross(vecPoint1Point2vecDir1vecDirCross)
        
        return 
xs_vec_len(vecDirCross) / xs_vec_len(vecDir1)
    }

    new 
Float:vecPoint1Point2[3]
    
xs_vec_sub(flPoint2flPoint1vecPoint1Point2)
    
    new 
Float:vecDirCross[3]
    
xs_vec_cross(vecDir1vecDir2vecDirCross)

    return 
floatabsdet3(vecPoint1Point2vecDir1vecDir2) ) / xs_vec_len(vecDirCross)
}

Float:det3Float:vec0[3] , Float:vec1[3] , Float:vec2[3] )
{
    return ( 
vec0[0]*vec1[1]*vec2[2] + vec1[0]*vec2[1]*vec0[2] + vec2[0]*vec0[1]*vec1[2] - vec0[0]*vec2[1]*vec1[2] - vec1[0]*vec0[1]*vec2[2] - vec2[0]*vec1[1]*vec0[2] )

The bad thing is that I need to pass a direction instead of another position, there exists a possibility for making it with and start pos and a end post for both?
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross
meTaLiCroSS 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:20.


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