ENIGMA Forums

Sharing is caring => Tips, Tutorials, Examples => Topic started by: The 11th plague of Egypt on September 18, 2010, 09:50:19 am

Title: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 18, 2010, 09:50:19 am
I guess you need something simple yet effective. I think I've got a solid solution to your problems,
wheter you are coding top-down shooters, RPG or a RTS games, this engine can help you moving
your units fast and reliably.

Doesn't matter how big your maps are, or how big your armies are, this thing is designed to SCALE
for all your needs. I've tested labyrinthic maps full of bottlenecks and get it to work smoothly.

I won't lie to you, this thing is pretty advanced, but I've worked to make it as easy to use, but with
a radical design in mind, you are the one in control. You get to know how it works when you design
map, but you can change the most important parameters of your units without a need to understand
all the underlying math. However, if you are curious to know how it works, the code is commented.

Still i suggest you watching this video tutorial (http://www.youtube.com/watch?v=oFVEvKGa4_s) in order to get started. BTW Can't incorporate vieo in post?

Download (http://www.mediafire.com/?7a89a15pya47rgw)

Here is a partial list of features:

Path-finding:
- quick and simple BFS algorithm
- incorporated smoothing
- GM-functions free (no mp_grids)
- full GML, no dlls

Path following
- units can avoid each other without smashing into walls
- can handle queues and bottlenecks
- customizable steering options

Collision engine:
- doesn't use sprites (will be easy to port on Enigma)
- can handle really fast units
- "collision_line_width" like functions
- "collision_line_first" like functions can be implemented
- splits the maps into cells to cut down pointless checks

Editor:
- easy to use
- lets you build your own paths
- eliminates the need of having dozens of wall objects

Others:
- supports units of various sizes
- GM save and load won't work, use the custom replacement

To do:
- 3d support, can be achieved through layers
- more tutorials, on demand

Notes:
- units will never give up seeking their way until they can see their destination, can be changed on demand
- if the destination point is too close to a wall, units won't even try to get there, no quick fix
Title: Re: Chesee finder - pathfinding and collision engine
Post by: freezway on September 19, 2010, 12:12:35 am
FUCK YES! is it bbox or pixel or both, I'll check it out when I have time.

EDIT: Your Indian?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 19, 2010, 06:30:39 am
No BBox nor pixels, your units are treated as circles by the collision system so that they can and turn in place when needed, like in most RTS games,
but, unlike in most RTS, units will never overlap.
However, this may not be good for a car race game because of the simplified physics.

I'm Italian, btw, sorry for the accent.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Fede-lasse on September 21, 2010, 01:17:24 am
Ah, yes. Waypoint pathfinding. Valve's solution to bots :P.

Good job. No, I'm not being sarcastic.

So... you won't post this on GMC?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 21, 2010, 05:29:01 am
Ah, yes. Waypoint pathfinding. Valve's solution to bots :P.
Units can go outside of the waypoints connections as long as they don't cross walls.
It has some similarities to a navgraph.

I'll post this on the GMC when I'll get some input from this community. I posted on the U3D forum too.

So, any suggestions?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Fede-lasse on September 22, 2010, 01:14:18 pm
A generator.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 23, 2010, 05:17:08 pm
Sigh, no time to do that. I'm already trying to port this in a 3d environment.

I need 2 script (pure gml please):
- one to measure the distance of a segment from a given triangle in 3d (needed to know if a bullet pierced the floor) <- more difficult
- one to find the z value of a triangle point given its x and y (needed to move units according to the height of the floor)
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 24, 2010, 11:08:14 am
I've been making some projects. I found a site (http://web.archive.org/web/20061018144221/www.geometrictools.com/Distance.html) full of useful C++ code. Now I need to convert this C++ code to GML.

Here's the code for a segment-triangle distance script. .cpp (http://web.archive.org/web/20060703203939/http://www.geometrictools.com/Foundation/Distance/Wm3DistSegment3Triangle3.cpp) and .h (http://web.archive.org/web/20060703203939/http://www.geometrictools.com/Foundation/Distance/Wm3DistSegment3Triangle3.h) <- more important

Here's the code for a rectangle-triangle distance script. .cpp (http://web.archive.org/web/20060703203939/http://www.geometrictools.com/Foundation/Distance/Wm3DistSegment3Rectangle3.cpp) and .h (http://web.archive.org/web/20060703203939/http://www.geometrictools.com/Foundation/Distance/Wm3DistSegment3Rectangle3.h)

If somebody needs a prize in order to help me, we can talk about that.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: IsmAvatar on September 24, 2010, 11:21:37 am
I thought I might be able to be of help, so I opened up the .cpp file and started reading. About 2 lines in I said "Oh... guess not." C != C++.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 24, 2010, 03:34:32 pm
Thanks for trying, that's some complex C++ indeed. I know some of it, but objects and classes are out of my reach.

btw is Josh still around?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: retep998 on September 24, 2010, 06:03:05 pm
I understand all the syntax in that shit, but my mind does not follow what is going on there.
If I spent an hour or so analyzing the code thoroughly I'd have you a beautiful gml script in no time.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on September 24, 2010, 08:09:17 pm
No, Josh went to college and abandoned everyone. Twice.

Don't worry Ism, that's not even what I'd consider "good" C++. I'm sure someone out there appreciates it. Rusky probably does. But I'm not a fan of making a template to do a regular class's job. Especially when it makes that many assumptions about what class Real contains.

They seem to have, however, circumvented my biggest beef with templates, being the lack of extern-ability. How did they do this? wellfuckifiknowillbetitwontevencompileinenigma

Furthermore, I can't retrieve the first .cpp file, or I'd tell you what it did. As for the second source, the first thing I notice is that it won't compile with -pedantic. Not that I make ENIGMA do so, but I've found that serious collaborations compile with -Wall -Werror -pedantic, meaning if the compiler even glances at anything funny, compile fails.

My synopsis is that they whore everything new unceremoniously. I doubt it'll compile in GCC or VStudio due to the lack of extern template in either of them. Not that they explicitly denoted that, anyway. "Wild Magic" is about the size of it.

As far as distance calculations go, the math is like all others. Except encased in uncompilable filth. I would sooner get GLibC to compile in G++ than this project.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 25, 2010, 01:09:13 am
Thank you for the extensive answer. Somebody probably tryed too hard to "be smart" with that cryptic coding. What a pity.
I found the new distance functions (http://www.geometrictools.com/LibMathematics/Distance/Distance.html) from Wild Magic 5, maybe these work properly, although I doubt it.

segment to segment .cpp (http://www.geometrictools.com/LibMathematics/Distance/Wm5DistSegment3Segment3.cpp) and .h (http://www.geometrictools.com/LibMathematics/Distance/Wm5DistSegment3Segment3.h)
segment to triangle .cpp (http://www.geometrictools.com/LibMathematics/Distance/Wm5DistSegment3Triangle3.cpp) and .h (http://www.geometrictools.com/LibMathematics/Distance/Wm5DistSegment3Triangle3.h)
segment to triangle .cpp (http://www.geometrictools.com/LibMathematics/Distance/Wm5DistSegment3Rectangle3.cpp) and .h (http://www.geometrictools.com/LibMathematics/Distance/Wm5DistSegment3Rectangle3.h)

Do you know of a place where I could find similar scripts? I am no matematician.

btw is there some way I could get you to convert this to gml so that it compiles? :)
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on September 25, 2010, 09:02:08 am
I'm not sure about where to get a really good script for that. The typical strategy for working with rectangles is storing a center point and some lengthdir params.

I don't think the Wild Magic people were trying to act smart. Though it makes me wonder what compiler they were using, since it clearly wasn't VStudio or GCC. (GCC -does- offer an export template extension, but it's explicit).

Anyway, the sources you linked to only have a fraction of the code. They inherit the rest. It's like Rusky's dream system. So if you want to see everything that's going on in the code... well, have fun tracking down all the classes you inherit from.

A quick Google search will find thousands of capable geometric collision examples. Here's one. (http://www.gamedev.net/community/forums/topic.asp?topic_id=500238) But collisions are one place I don't even trust my own math skills to generate the most efficient test function, let alone some stranger's from GameDev.net. Or that of some group using Compiler from Hell.

I also don't understand why you needed it converted to GML; are you trying to get it to work in Game Maker as well? G++ compatible C++ can just be copied into WhiteSpace in ENIGMA and used like any other function. Including the code on that GameDev.net link I gave above. Right now, the syntax checker has problems with variable.function(), but I will have that working sometime this week.

When the fix is in the stable repo, I will let you know how to use his code.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Rusky on September 25, 2010, 10:35:04 am
That is the most amazing C++ in the world!

:troll:
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 25, 2010, 12:59:01 pm
The only script I really need is one that returns the distance of a segment from triangle, in 3d. If there is an intersection, I need it to return 0.

The other script, the one that returns the z of a x-y point inside the triangle is also necessary, but should be much easier to retrieve.

I would like it to work with GM too, but so far I have found nothing useful, be it C++ or GML.

If somebody can solve my problem I can buy him/her a Steam game. I'm tired of waiting, I'll have to learn C++ later this year at my university, but right now I want to finish this.

EDIT: maybe I got a chance. Here is a simple code (http://softsurfer.com/Archive/algorithm_0105/algorithm_0105.htm) that can account for ray/segment collisions with a triangle. If there is no intersection, then I suppose that the segment-triangle distance is the smallest distance between the segment the 3 sides of the triangle. On the same site, I also found some code (http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm) that can do that.

I think I can convert this script by myself. There are custom types defined in order to use custom operations, but there's hope.
But I still another script to calculate the distance between 2 segments, and I can't find any straightforward code.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 27, 2010, 03:52:22 pm
News. I converted a 3d C++ function (http://"http://softsurfer.com/Archive/algorithm_0106/algorithm_0106.htm") to find the distance between 2 segments into a GML script. Here's an example (http://"http://www.zshare.net/download/808607426589267c/"), this thing can recognized intersections too!

I'm now trying to convert another function (http://"http://softsurfer.com/Archive/algorithm_0105/algorithm_0105.htm") from the same site, but i got stuck because of a vectorial cross product.

If I have 2 vectors, u(u_x1,u_y1,u_z1,u_x2,u_y2,u_z2) and v(v_x1,v_y1,v_z1,v_x2,v_y2,v_z2), how do I calculate the vector w = u x v ?

w must perpendicular to both u and w, that's all I know
Title: Re: Chesee finder - pathfinding and collision engine
Post by: luiscubal on September 27, 2010, 04:49:13 pm
w = u x v is pretty easy. There's a formula for that.

| i j k |
| ux uy uz |
| vx vy vz |

=

(uy * vz - uz * vy, vx * uz - ux * vz, ux * vy - vx * uy)

At least if I remember properly

I have no idea why your vectors have 6 dimensions. Be aware that this formula only works for 3D vectors.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on September 27, 2010, 05:52:38 pm
Thank you. My vectors have 3 dimensions, I build them from the segments.

Your formula is correct, I found a similar one here (http://www.zshare.net/download/808641914270e4fe/)

However, I can't get the code to work. No errors, it just returns nonsense. I think I translated the code correctly...

example here (http://www.zshare.net/download/808644418340edef/)
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 07, 2010, 12:00:07 pm
I hired a C++ coder to make the functions I needed, we are testing it out now. Probably it's easier (and better) to make a .dll out of it instead of converting the code to GML.

Anybody wants to help?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on October 07, 2010, 08:02:04 pm
*shudder*
Title: Re: Chesee finder - pathfinding and collision engine
Post by: retep998 on October 08, 2010, 01:13:24 am
 :eng101: :eng99:
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 08, 2010, 06:18:21 am
Com'on, I'm doing this for the community and I'll release the code as open source. The dll could have a MIT license, if you don't like GPL.

Well, I now have a complete C++ CodeBlocks project, and I need to make a dll out of it, so I can use it with Game Maker too.

Anybody knows how to make a Game Maker dlls? Is that any different from making a dll for another program?

The GMC dll topic sucks. It's full of C++ tutorials, and i can't find any useful information.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 08, 2010, 07:17:51 am
Thank you. I already have a topic (http://gmc.yoyogames.com/index.php?showtopic=487745) on the GMC. Nobody answered.

Seems it's like writing a common dll, for that matter.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: IsmAvatar on October 08, 2010, 12:49:31 pm
... try knocking up Icuurd ..., if he's free he'll probably sort you out ;)

 :eng99:
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on October 08, 2010, 05:26:19 pm
Chances are, the programmer you hired doesn't specialize in geometry. I can write a set of shitty polygon collision functions for free.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 09, 2010, 04:54:47 am
I was thinking about hiring him again to do the dll part, but yeah, it took him too much time.

Here is the work he did (http://www.mediafire.com/?cgkk7t9gberf009), I'd like a judgement on efficiency.
There are:
1) a function to measure the distance from a 3d segment to a 3d planar convex, and return the closest points if there is no intersection
2) a function to return the z value of a x-y point of the convex

I could open a new job so you can participate. Here are my needs

- function 1) should return only one thing, a number representing
-- if there is an intersection, the distance from the first point of the segment to the intersection point
-- if there isn't, the distance from the first point of the segment and closest point of the convex polygon

- a function to measure the distance between 2 segments, which returns a number representing
-- if there is an intersection, the distance from the first point of the first segment to the intersection point
-- if there isn't, the distance from the first point of the first segment and the closest point of the second segment

- a function that, given a 3d point and a 3d planar convex, returns
-- if the point is above the convex or part of it, the distance from the convex
-- if the point is under the convex and not part of it, the distance from the convex as a negative value

- a function that, given a 3d point and a 3d planar convex, returns the x-y direction to take to get away from the convex as fast as possible

- take all the above functions and make a Game Maker compatible dll out of it (it has to return doubles)

- a GML function that, given the first point of a segment and a distance, returns the point of the segment with that distance from the first point

It's a lot of things, and I don't have much money nor a lot of time, but I hope we can make a deal.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 09, 2010, 08:24:55 am
New project opened. Max bid is 25$, if you want to participate, I'll give you the link.

I wonder if I could implement some sort of 3d triangulation too...
Title: Re: Chesee finder - pathfinding and collision engine
Post by: serprex on October 09, 2010, 11:19:32 pm
segment_triangle.cpp: http://en.wikipedia.org/wiki/Fast_inverse_square_root
Code: [Select]
inline void normalize(float* x)
{
float len = 1.0f / sqrtf(dot_product(x, x));
x[0] *= len;
x[1] *= len;
x[2] *= len;
}
He's using inline, so that should deal with aliasing

What's the data set? If you don't have too many values, consider using doubles. If you're alright having 25% useless data thrashing your cache, consider adjusting vectors to be float[4] so to allow for tree vectorization and other such power of two goodness

get_z:
Code: [Select]
if( fabsf(normal[2]) < FUZZY_ZERO )
return 0.0f; // that means that the triangle is parallel to the Z axis (we cannot retrieve a Z value from X and Y)
// Now, the plane equation is A1*x + B1*y + C1*z + D1 = 0
// solving for "z" yields:
// z = -(A1*x + B1*y + D1) / C1
return (normal[0]*x + normal[1]*y - dot_product(normal, va)) / -normal[2];
This is a little epsilon trigger happy. Better would be to check if it is exactly 0, otherwise let the processor give you the nearly zero value (Unless you're using zero as a signal value?). Another case of overly eager number fudging is in line_segment, where if( det > FUZZY_ZERO ) is better stated as a check on whether a01 is near 1

If you're going to use FUZZY_ZERO, consider using -ffast-math
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 10, 2010, 05:20:42 am
Hey, thanks for the feedback!

I'll notify him. He's now working on adding the other functions and making a dll as well.

He said he already worked on dll making, so he'll make a dll that works with other languages, but i have to test the Game Maker side.

Is a Game Maker dll really that different from any other dll, except for the "doubles only" thing?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: serprex on October 10, 2010, 08:10:30 am
http://gmc.yoyogames.com/index.php?showtopic=90437 39dll is open source, and it shows that making a DLL isn't that hard
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on October 10, 2010, 09:52:25 am
How much are you paying this guy, exactly?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 10, 2010, 03:54:51 pm
25$ to do the initial work and another 20$ to complete it and make a dll.

45$=33€ as I live In Europe I get that kind of discount...Is it too much in your opinion?

I found this topic (http://gmc.yoyogames.com/index.php?showtopic=449508) with 3d collisions, but it's not open source.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on October 10, 2010, 06:22:41 pm
Actually, I'm surprised you hired someone for that cheap without any sort of contract. Where did you dig hum up?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on October 11, 2010, 06:01:00 am
I HAVE a contract, actually, a pretty nice one :D
Quote
1) I require complete and fully-functional working program(s) in executable form as well as complete source code of all work done (so that I may modify it in the future).
2) Deliverables must be in ready-to-run condition as follows (depending on the nature of the deliverables):
2a) If there are any server-side deliverables (intended to only exist in one place in the Employer's environment) then they must be installed by the Worker in ready-to-run condition (unless specified elsewhere by the Employer).
2b) All other software (including but not limited to any desktop software or software the employer intends to distribute) must include a software installation package that will install the software in ready-to-run condition on the platform(s) specified in this project (unless specified elsewhere by the Employer).
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Employer will receive exclusive and complete copyrights to all work purchased.
3b) No part of the deliverable may contain any copyright restricted 3rd party components (including GPL, GNU, Copyleft, etc.) unless all copyright ramifications are explained AND AGREED TO by the employer on the site per the worker's Worker Legal Agreement.

I googled "rent a coder" and found a site (http://www.vworker.com) that does exactly that.  It's like the ebay of outsourcing.

@serprex
I've got an answer to your doubts
Quote
"consider adjusting vectors to be float[4]" - I don't think that's reasonable for our case. Because automatic SIMD optimizations are no good usually, if you do need them, then you should probably consider writing a different version of the function that properly takes advantage of them.
"This is a little epsilon trigger happy. Better would be to check if it is exactly 0, otherwise let the processor give you the nearly zero value (Unless you're using zero as a signal value?)." - that was just to prevent a division by zero or returning an invalid value, but may be there shouldn't be any checks in the first place, let the function assume the point exists.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on October 11, 2010, 07:31:34 am
Not to mention IEEE has no problem with division by zero.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on November 02, 2010, 06:11:02 am
After a lot of delays, work on the dll is almost done. I'll post a beta here very soon, I hope someone will help me testing it out.

With this kind of collision system, my AI engine will treat units as spheres, which is fast, but not as precise as someone may need.

If someone fells like bbox collisions are needed, I may consider adding them to the dll and then to the AI.

BTW Josh, do you have this kind of collisions ready somewhere in your codebase? I remember you mentioning meshes collisions.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on November 02, 2010, 09:17:38 am
I have something that checks bboxes in ENIGMA, yes. Non-rotated. It's just called collision_bbox_rext(); it's like a less accurate place_free.

Also, r9k's been working on triangle/polygon collisions. Those'll be done sometime in the not-so-distant future.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on November 02, 2010, 12:39:56 pm
I mean 3d bboxes and I'll probably need them rotated if I'm gonna use them.

If I'll ever decide to add this kind of collision detection to the dll, is there any way you (or r9k) could find it useful?
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on November 02, 2010, 12:47:35 pm
r9k's triangles are rotated. As far as 3D detection goes, I don't intend to use bboxes for 3D; I'll be skipping right to polygon meshes.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on November 02, 2010, 02:59:23 pm
Really? I thought every 3D game used bboxes. ???
Title: Re: Chesee finder - pathfinding and collision engine
Post by: Josh @ Dreamland on November 02, 2010, 06:02:04 pm
Some things use bboxes, sure; it would be horrible to have collision tests done on every face of every landform and every character. But to treat each object as a simple box isn't always a great idea. Often a simplified mesh is used for collisions instead of just a box. The meshes are, of course, composed of triangles.

A good game, though, will use more than just meshes and boxes, anyway. Since most games are not designed to use the kind of general-purpose collision functions Game Maker offers (namely, place_free(): the number one most whored function in GM), each "object" will be treated uniquely by the controller (possibly the player). I intend to offer a number of functions for resolving primitive and mesh distances. More variety = more efficiency.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on November 03, 2010, 04:25:01 am
Ok, I don't need any place_free() right now, I'm just asking if you could recycle some of the code I need to write and vice-versa.
Title: Re: Chesee finder - pathfinding and collision engine
Post by: The 11th plague of Egypt on November 09, 2010, 04:34:36 pm
If anybody wants to start early testing, I attached the dll C::B C++ code to this post. Licence is GPLv3.
If you'd prefer a more permissive licence, let me know. Any feedback is appreciated, just keep in mind some minor fixes are still needed.

Now the coder I rented plans on debugging it using Visual Studio because he said it's easier to make a debugging project in it.
Quote
I was meaning to create another project for testing (inside the same solution), but I couldn't find a way to do it in CodeBlocks.

Here is a brief description of the content. There should be 2 versions of the same function, one for use in C++ code and a dumber one that's GM compatible.

1) A function that, given a 3d segment and 3d planar convex

_cpp version
- if there is an intersection, returns
-- the coordinates of the intersecting points
-- distance=0
- if there isn't, returns
-- the coordinates of the closest points
-- the distance between the closest points

_gm version
- if there is an intersection, returns
-- the distance from the first point of the segment to the intersection point
- if there isn't, returns
-- the distance from the first point of the segment to the point of the segment that is closest to the convex polygon, as a negative value

2) a function that, given 2 segments

_cpp version
- if there is an intersection, returns
-- the coordinates of the intersecting points
-- distance=0

- if there isn't, returns
-- the coordinates of the closest points
-- the distance between the closest points

_gm version
- if there is an intersection, returns
-- the distance from the first point of the segment to the intersection point
- if there isn't, returns
-- the distance from the first point of the first segment to closest point of the second segment, as a negative value

3) a function that, given 2 points returns
- the distance between them

4) a function that, given a 3d point and a 3d planar convex, returns
- if the point is above the convex or part of it, the distance from the convex
- if the point is under the convex or not part of it, the distance from the convex as a negative value

5) a function that, given a 3d point and a 3d planar convex, returns

_gm version
- the x-y direction (360 degrees) to take to get away from the convex as fast as possible if you are on the point

_cpp version
- a vector pointing the direction to get away from the convex as fast as possible if you are on the point

6) a function that, given a 3d triangle and a 3d axis-aligned rectangular prism, returns
- 1, if the triangle is inside the prism or touches it or contains it
- 0, if the triangle is completely outside the prism

7) a function that, given a 3d convex and the x-y coordinates of one of its points, returns
- the the z value of that point