Mathematical Problem! Who can help me out?
#1

Hi, i am not very good in maths (and english ) so i need your help.

I want to calculate some coordinates in 3d space. I think i can explain it the best with a drawing:



Lets say i know the coordinates (XYZ) of point A and point B
Now draw (virtually) a line between point A and point B (the red line).
Point C is on the red line and i know the distance between point A and point C.
How do i calculate the coordinates (XYZ) of point C

I hope someone can help me..

Reply
#2

As you're Dutch, so am I, this will help you out a bit:
http://www.pandd.nl/stereo/kubus.htm
This is also Dutch, and very usefull.
http://www.flashcollection4u.com/dat...pythagoras.swf
Reply
#3

How do you calculate the distance between points A and C, if you don't know the coords of the point C?
Reply
#4

Quote:
Originally Posted by Finn
How do you calculate the distance between points A and C, if you don't know the coords of the point C?
I use a default distance for example 2.0.

So basically: I want to calculate the coords of point C which is 2.0 coords away from point A, towards point B
Reply
#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
#6

Thanks it works!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)