SA-MP Forums How to know if a vector passes over a dot
 New Account Members List Search Today's Posts Mark Forums Read

 03/12/2011, 07:58 PM #1 KakarottoSSJ Little Clucker   Join Date: Nov 2011 Posts: 3 Reputation: 0 How to know if a vector passes over a dot 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.
 04/12/2011, 01:49 AM #2 KakarottoSSJ Little Clucker   Join Date: Nov 2011 Posts: 3 Reputation: 0 Respuesta: How to know if a vector passes over a dot Nobody answers? I need it please.
 04/12/2011, 02:32 AM #3 [HiC]TheKiller High-roller   Join Date: Mar 2008 Location: New Zealand Posts: 2,629 Reputation: 410 Re: How to know if a vector passes over a dot 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 . __________________ https://revctrl.com

 Thread Tools Display Modes Linear Mode

 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 Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Teprey Plugin Development 64 12/12/2015 10:36 PM [XST]O_x Scripting Help 3 14/07/2012 02:03 PM vakhtang Help Archive 1 19/03/2011 01:32 PM PoWerZ Help Archive 1 13/10/2009 07:43 PM

All times are GMT. The time now is 12:51 PM.

 -- (EN) English -- (RU) Русски SA-MP - Archive - Top