Raised This Month: $ Target: $400
 0% 

Collision of two line


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 06-23-2012 , 12:14   Collision of two line
Reply With Quote #1

How to check if the red line collison the blue square / is inside of blue square.
Blue square created in player spawn origin.
I have this datas value for red line:
PHP Code:
new Float:fStart// contain the start origin of RED LINE
new Float:fEnd// contain tha end origin of RED LINE

// I tried to calculate when red line is inside of  blue square
new Float:fTest]
fTest] = fStart] * fEnd] / fStart] - fEnd]
fTest] = fStart] * fEnd] / fStart] - fEnd]
fTest] = fStart] * fEnd] / fStart] - fEnd]
// but doesn't wok! 
Attached Thumbnails
Click image for larger version

Name:	square.PNG
Views:	292
Size:	1.5 KB
ID:	105471  

Last edited by dFF; 06-25-2012 at 10:32. Reason: update wrong information! sorry!
dFF is offline
Neeeeeeeeeel.-
Some Guy Yellin'
Join Date: Jul 2010
Location: Argentina
Old 06-23-2012 , 22:14   Re: Collision of two line
Reply With Quote #2

If you are talking about tracelines... you should read this.
__________________
Neeeeeeeeeel.- is offline
Send a message via Skype™ to Neeeeeeeeeel.-
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 06-24-2012 , 05:42   Re: Collision of two line
Reply With Quote #3

Too bad
I found a math calculation http://local.wasp.uwa.edu.au/~pbourk...try/planeline/ , but my knowledge is poor .
dFF is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-24-2012 , 05:49   Re: Collision of two line
Reply With Quote #4

xs_plane_rayintersect()
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 06-25-2012 , 10:15   Re: Collision of two line
Reply With Quote #5

Exolent when you have time, can you write an example or tutorial ? Thank you!
dFF is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-25-2012 , 10:35   Re: Collision of two line
Reply With Quote #6

The blue box is your plane. You can create the plane variable by using 3 points of that box.

Code:
new Float:plane[4]; xs_plane_3p(plane, box_point1, box_point2, box_point3);

Then you need the start position of the line and the direction it goes.
If all you have is 2 points, then you need to calculate the direction.

Code:
new Float:line_direction[3]; xs_vec_sub(line_point2, line_point1, line_direction);

Finally, apply variables to check if the line intersects the plane.
Code:
new Float:intersection[3]; if( xs_plane_rayintersect(plane, line_point1, line_direction, intersection) ) {     // Line intersects the plane at "intersection" point }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
dFF
sıɹɹoɥɔ ʞɔnu
Join Date: Oct 2009
Old 06-25-2012 , 16:56   Re: Collision of two line
Reply With Quote #7

Thank you Exolent ! You are the man .
dFF is offline
Reply



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 06:06.


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