# Coordinate Calculations (Volume, Distance, and more!) [in 3d]

## Recommended Posts

Hello, I originally started writing these functions in autoit, because of how easy it was to debug my code (the algorithms are actually implemented in php, though the same functionality could be used without conversion by using aucgi).

My original intended purpose for these functions was to allow my web server to calculate if a player was between two points(inside a "region") in a game(minecraft).

Currently my functions can do the following:

• Calculate the absolute distance between two points
• Calculate the volume between two points(to the nearest whole number)
• Calculate all points between two points, including their volume(to the nearest whole numbers)
• Check is a point is between two points(to the nearest whole number)
• ​(Maybe more I haven't though of?)

I then expanded on the code to add some additional functionality. This code could be used with little modification to create a voxel style game engine. (It could actually even be further modified to support decimal values, though this would significantly slow it's performance exponentially per decimal place, though this shouldn't be necessary, except in rare cases such precision collision detection[ex: detect if a bullet hit a player or npc])

I encourage everyone to submit your modifications/optimizations to my code so everyone can use them. I know my code isn't perfect, and it's functions could be expanded on with the right knowledge(things like collision detection, world generation, etc).

So finally here's the code(including examples of all functions being used):

voxel.au3

Edited by nullschritt
##### Share on other sites

Known Bugs:
• Second set of coordinates cannot = 0,0,0
• -> (Fixed by conditionally swapping values)
• Quick count does not accuratley return the volume.
Edited by nullschritt

## Create an account

Register a new account

• ### Similar Content

• #### a problem when create a array 3d

By nacerbaaziz,

• 13 replies
• 1,716 views
• #### Examples for interactive coordinate selector or point picker?

By TheDcoder,

• 4 replies
• 2,233 views
• #### Change ControlClick coordinates - While loop

By tentacole,

• 9 replies
• 3,709 views
• #### 3D Sinus Wave (Javascript version)

By Gianni,

• 2,028 views
• #### 3D Sinus Wave (GDI / GDI+)

By UEZ,

• (and 2 more)

Tagged with:

• 3 replies
• 4,184 views
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...