Jump to content

is mouse over triangle[help]


cs8898

Recommended Posts

You can try this (I haven't tested it):

function isPointInTriangle( x,y, x1,y1, x2,y2, x3,y3 )  
    if sign( x,y, x1,y1, x2,y2 ) < 0 or 
        sign( x,y, x2,y2, x3,y3 ) < 0 or 
        sign( x,y, x3,y3, x1,y1 ) < 0 
    then 
        return false; 
    end 
    return true; 
end 
  
function sign( x1,y1, x2,y2, x3,y3) 
    return (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3); 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...