Getting a Center point from 2 Co-ordinates
#1



Title says it all, does anyone have a solution?
Reply
#2

Seems like you're going to need an algorithm.. Oh how I hate mathematics..
Reply
#3

Well of course I do xD, though I don't know any particular algorithm for this...
Reply
#4

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.
Reply
#5

Try this:

PHP код:
stock GetCenterPoint(Float:Pos1Float: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(playeridkilleridreason)
{
    new 
Float:F[3], Float:FF[3];
    
GetPlayerPos(playeridF[0], F[1], F[2]);
    
GetPlayerPos(killeridFF[0], FF[1], FF[2]);
    new 
Float:GetCenterPoint(F[0], FF[0]);
    new 
Float:GetCenterPoint(F[1], FF[1]);
    
printf("Medium point: %f X & %f Y"XY);
    return 
1;

Reply
#6

Quote:
Originally Posted by Shadoww5
Посмотреть сообщение
Try this:

PHP код:
stock GetCenterPoint(Float:Pos1Float: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(playeridkilleridreason)
{
    new 
Float:F[3], Float:FF[3];
    
GetPlayerPos(playeridF[0], F[1], F[2]);
    
GetPlayerPos(killeridFF[0], FF[1], FF[2]);
    new 
Float:GetCenterPoint(F[0], FF[0]);
    new 
Float:GetCenterPoint(F[1], FF[1]);
    
printf("Medium point: %f X & %f Y"XY);
    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)
Reply
#7

Is this relevant?
Reply
#8

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;
}
Reply
#9

I studied analytic geometry at school:

SR = Square Root
| = Absolute value
**2 = Squared
x1, x2, y1, y2 = The variables

PHP код:
SR[|x1-x2|**- |y1-y2|**2
-------------

EDIT: Wrong, thats the formula to find the distance , sorry.

The right formula is

PHP код:
[(x1+x2)/2], [(y1+y2)/2
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)