Distance between two lines
I've tried to find such thing in the forum and I would not able to find something to answer my question, at least I've found this(http://forums.alliedmods.net/showpos...28&postcount=2) and it's useful at least, but it's close of what I want.
I wanted to check with a math code (welcome, not my speciality) the "distance" between two lines on the game, for being accurate, 2 players and 2 objects flying on air, both players owns one of these entities, and I wanted to check (by think forward) if one of these objects intersects with anyother's player object, a virtual collision, to be specific, to check if it crosses anyother's players invisible line to it's flying object, I'm not sure if I spelled it right what i've tried to say, but would be nice to see some math art in action here n.n Anyway, thanks in advance! :) |
Re: Distance between two lines
I have an idea of what you want but I am in doubt. You could put a picture to understand.
|
Re: Distance between two lines
Try this :
PHP Code:
|
Re: Distance between two lines
Quote:
|
Re: Distance between two lines
If I am right, this should be fine.
PHP Code:
|
Re: Distance between two lines
Quote:
|
Re: Distance between two lines
I am getting director vector from two points in one line and getting director vector from two lines.
|
Re: Distance between two lines
Put a drawing about what you need.
You write the distance between 2 lines, so you have to get 2 vectors and get the difference. The result will be a vector (vector - vector = vector). If you want a distance in units, just get the lenght of the resulting vector. Remember that 2 lines will not always be parallel. If you wan't distance between 2 "always parallel" lines, then it's fair easy to get it but it's the same principle. |
Re: Distance between two lines
Quote:
PHP Code:
This subtraction only finds a relationship between lines. Real distance are calculate like I did in my example. Also it return a number, you must proportionate the correct unit type. |
Re: Distance between two lines
Quote:
What happens if both lines are not parallel? Somewhere they will be closer and somewhere not. |
| All times are GMT -4. The time now is 08:20. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.