Getting a Center point from 2 Co-ordinates -
Lorenc_ - 02.07.2011
Title says it all, does anyone have a solution?
Re: Getting a Center point from 2 Co-ordinates -
Skylar Paul - 02.07.2011
Seems like you're going to need an algorithm.. Oh how I hate mathematics..
Re: Getting a Center point from 2 Co-ordinates -
Lorenc_ - 02.07.2011
Well of course I do xD, though I don't know any particular algorithm for this...
Re: Getting a Center point from 2 Co-ordinates -
Skylar Paul - 02.07.2011
Quote:
Originally Posted by Lorenc_
Well of course I do xD, though I don't know any particular algorithm for this...
|
If I knew advanced mathematics I would help you, but I don't think I have any chance at it considering I still managed to fail Geometry, lol. Good luck finding someone.
Re: Getting a Center point from 2 Co-ordinates -
Shadoww5 - 02.07.2011
Try this:
PHP код:
stock GetCenterPoint(Float:Pos1, Float:Pos2)
{
new Float:dist;
if(Pos1 > Pos2) { dist = Pos1+((Pos1-Pos2)/2); }
else { dist = Pos2+((Pos2-Pos1)/2); }
return dist;
}
How to use:
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
new Float:F[3], Float:FF[3];
GetPlayerPos(playerid, F[0], F[1], F[2]);
GetPlayerPos(killerid, FF[0], FF[1], FF[2]);
new Float:X = GetCenterPoint(F[0], FF[0]);
new Float:Y = GetCenterPoint(F[1], FF[1]);
printf("Medium point: %f X & %f Y", X, Y);
return 1;
}
Re: Getting a Center point from 2 Co-ordinates -
Lorenc_ - 02.07.2011
Quote:
Originally Posted by Shadoww5
Try this:
PHP код:
stock GetCenterPoint(Float:Pos1, Float:Pos2)
{
new Float:dist;
if(Pos1 > Pos2) { dist = Pos1+((Pos1-Pos2)/2); }
else { dist = Pos2+((Pos2-Pos1)/2); }
return dist;
}
How to use:
PHP код:
public OnPlayerDeath(playerid, killerid, reason)
{
new Float:F[3], Float:FF[3];
GetPlayerPos(playerid, F[0], F[1], F[2]);
GetPlayerPos(killerid, FF[0], FF[1], FF[2]);
new Float:X = GetCenterPoint(F[0], FF[0]);
new Float:Y = GetCenterPoint(F[1], FF[1]);
printf("Medium point: %f X & %f Y", X, Y);
return 1;
}
|
Not for that, I want to find the center location from the X, Y to the other X, Y.
stock GetCenterPoint(Float:Pos1_X, Float:Pos1_Y, Float:Pos2_X, Float:Pos2_Y)
Re: Getting a Center point from 2 Co-ordinates -
Calgon - 02.07.2011
Is
this relevant?
Re: Getting a Center point from 2 Co-ordinates -
Mauzen - 02.07.2011
Here it is, isnt that hard:
pawn Код:
stock GetMiddlePos(Float:x_1, Float:y_1, Float:x_2, Float:y_2, &Float:x_mid, &Float:y_mid)
{
x_mid = (x_1 + x_2) / 2; // Arithmetic mean value is all you need
y_mid = (y_1 + y_2) / 2;
}
Re: Getting a Center point from 2 Co-ordinates -
Sasino97 - 02.07.2011
I studied analytic geometry at school:
SR = Square Root
| = Absolute value
**2 = Squared
x1, x2, y1, y2 = The variables
PHP код:
SR[|x1-x2|**2 - |y1-y2|**2]
-------------
EDIT: Wrong, thats the formula to find the distance

, sorry.
The right formula is
PHP код:
[(x1+x2)/2], [(y1+y2)/2]
Re: Getting a Center point from 2 Co-ordinates -
Lorenc_ - 02.07.2011
Quote:
Originally Posted by Mauzen
Here it is, isnt that hard:
pawn Код:
stock GetMiddlePos(Float:x_1, Float:y_1, Float:x_2, Float:y_2, &Float:x_mid, &Float:y_mid) { x_mid = (x_1 + x_2) / 2; // Arithmetic mean value is all you need y_mid = (y_1 + y_2) / 2; }
|
Ill try this out and post my results (Edit this post), yes calgon, thats what i was looking for.