Mathematical Problem! Who can help me out?
#5

Try this:
pawn Код:
/*Parameters
start[] : point A's coords
end[]  : point B's coords
lenght : distance from point A to point C
coords : array where will be stored point C's coords
*/

GetCoordsOnLine3D(Float:start[], Float:end[], Float:length, Float:coords[])
{
  coords[0] = start[0] - end[0];
  coords[1] = start[1] - end[1];
  coords[2] = start[2] - end[2];

  new Float:sqrt = floatsqroot((coords[0] * coords[0]) + (coords[1] * coords[1]) + (coords[2] * coords[2]));

  if (sqrt < 0.01)
    sqrt = 0.01;

  coords[0] = -length * (coords[0] / sqrt) + start[0];
  coords[1] = -length * (coords[1] / sqrt) + start[1];
  coords[2] = -length * (coords[2] / sqrt) + start[2];
}
Reply


Messages In This Thread
Mathematical Problem! Who can help me out? - by Sandra18[NL] - 12.03.2009, 13:56
Re: Mathematical Problem! Who can help me out? - by Marcel - 12.03.2009, 14:07
Re: Mathematical Problem! Who can help me out? - by Finn - 12.03.2009, 14:43
Re: Mathematical Problem! Who can help me out? - by Sandra18[NL] - 12.03.2009, 15:03
Re: Mathematical Problem! Who can help me out? - by Nubotron - 12.03.2009, 20:46
Re: Mathematical Problem! Who can help me out? - by Sandra18[NL] - 13.03.2009, 22:52

Forum Jump:


Users browsing this thread: 1 Guest(s)