Jump to content

Distance Between Two 2D Points


gamecreator
 Share

Recommended Posts

Or you just can you two Vector3, with each Z value = 0

and just give X and Y for these two Vector3

 

There's no point using a 3 component vector for 2D calculations because the Z will never be used. It's the same reason we don't usually use 4 component vectors for points in 3D space.

  • Upvote 1

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Oh sorry ! Well it is strange that std::sqrt does not work since it is from the c++ standard library.

 

You can use this square root function then it should work if you dont need a very accurate precision smile.png

 

float sqrt(float x)
{
union
{
int i;
float x;
} u;
u.x = x;
u.i = (1<<29) + (u.i >> 1) - (1<<22);

u.x = u.x + x/u.x;
u.x = 0.25f*u.x + x/u.x;

return u.x;
} 

  • Upvote 1
You guys are going to be the death of me. Josh
Link to comment
Share on other sites

Math::Sqrt() is also there.

I'm 99% sure it wasn't in the header but I'll look again when I get home. It's definitely not here though.

 

Thanks! Will try this. And thanks, YouGroove, for originally suggesting it.

Link to comment
Share on other sites

Thanks! Will try this. And thanks, YouGroove, for originally suggesting it.

 

Oh, I see what YouGroove was saying now. I thought he was saying to use Franck's code, but with three component vectors as the parameters.

 

I feel a bit silly now...

LE Version: 2.50 (Eventually)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...