# Distance to picked point

## Recommended Posts

Is there any command to get distance from point x, y, z to x2, y2, z2. I need to get distance from camera position to picked position.

##### Link to post

Use 3D pythagorus and make it own utility function. There is no LE get distance between points only between entities:

##### Link to post

```PointDistance(p1:TVec3, p2:TVec3)
```

or just do what it is doing and perform the math yourself

distance = ( (x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2 )^0.5

##### Link to post

Point distance??? is that an wiki'd command? didn't know it existed. I made my own lol.

##### Link to post

no its not listed as a command but i found it in lua a long time ago by accident when i tried to make my own function as well and used the obvious name for the function, PointDistance()... and i noticed it turned blue in the ScriptEditor as it was recognized... i mentioned it to josh at the time and he didnt seem too concerned about putting it in the wiki / forum docs... i assume since its basic math...

##### Link to post

I dont think its on the wiki index, hard to tell amongst all the new commands like CheapKarelaPills() and EnhanceYour beautyByWearingJoeRodeoDiamond () .. I think the index needs an enima.

##### Link to post

Is there any command to get distance from point x, y, z to x2, y2, z2. I need to get distance from camera position to picked position.

If you put a pivot at your picked position you could use EntityDistance(camera, pivot);.

##### Link to post

Thanks everyone. I placed pivot and works great.

##### Link to post

Wait... let me get this right.... instead of steps like this:

1. PointDistance(TVec3. LE::TVec3) // If you are in bmax or LUA, otherwise simple math funciton in C++

You do this:

1. CreatePivot();

2. PositionEntity(pivot, Vec3);

3. GetEntityDistance(pivot, camera);

.... I don't see the logic here.

##### Link to post

Looks like he tagged this post as BMax. Sounded like PointDistance() is a Lua function? Could be wrong, but that's how I read the post by macklebee. If the language/library I was using already had the function, then for sure use it. If not then for me, it's about not having to think about it or implementing it every time I do a new project (which is often). I'm not very organized so I don't keep a library of common code really. I know the function already exists in LE but it just so happens it needs an entity, so this is a way to do that with using just LE code that's easier for me to remember.

So I guess for me it's not about logic, it's about laziness.

##### Link to post

Well for anyone who wants a function for C++ that they can re-use every time its pretty simple:

```#include [itex]

float GetDistance(LE::TVec3 start, LE::TVec3 end){

return sqrt(pow(start.X-end.X, 2) + pow(start.Y-end.Y, 2) + pow(start.Z-end.Z, 2));
}
```

##### Link to post

I dont think its on the wiki index, hard to tell amongst all the new commands like CheapKarelaPills() and EnhanceYour beautyByWearingJoeRodeoDiamond () .. I think the index needs an enima.

lol thats funny.

##### Link to post

its in lua because it was in bmax... its not in the dll i assume because its basic math as i and ken have both shown...

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×
• ### Recent Topics

• #### vzsrtm

By hoswcr, in General Discussion

• 0 replies
• 12 views
• #### UI multiple button.

By Vince, in Programming

• 0 replies
• 19 views
• #### Minimap Generator

By martyj, in Programming

• 9 replies
• 1,073 views
• #### Question: Character Controller Physics

By TYFKO, in Technical Assistance

• Has best answer
• #### A couple of questions regarding localization and platform support in LE 4

By Krystal, in General Discussion

• 3 replies
• 207 views
×

• Pages

• Back
• Store

• #### Support

• Projects
×
• Create New...