How to know if a vector passes over a dot
#1

I know how to get the distance with cross product, but I don't know that.
I want to know when a vector passes over a dot, in a "x y z" position.
I don't know too much of physics.
Reply
#2

Nobody answers?
I need it please.
Reply
#3

OK, I take it you mean find if the line crosses a certain point. I'm not fully sure on 3d scales but I know how to do 2d using just x and y.

So, all we need to do is find the equation of the line then plug our values into that line to see if it is anywhere on there. We are going to need to find the gradient (y2 - y1 / x2 - x1) and the equation formula y - y1 = m(x - x1). An example is the line with the points (2, 5) and (6, 9). We are going to find if the point (3 , 6) lies on that line.

Code:
gradient
= (9 - 5) / (6 - 2)
= 4 / 4
= 1

Equation 
y - y1 = m(x - x1)
y - 5 = 1(x - 2)
y - 5 = x - 2
y = x + 3

Then plug in our values.
6 = 3 + 3
6 = 6
The point is on our line
So, now to do this using PAWN.

pawn Code:
stock IsPointOnLine(Float:Line1x, Float:Line1y, Float:Line2x, Float:Line2y, Float:Pointx, Float:Pointy)
{
    if( (Pointy - Line1y) == ( ( (Line2y - Line1y) / (Line2x - Line1x) ) * (Pointx - Line1x) ) ) return true;
    return false;
}
Hope this helps .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)