robot shortest path in 3d

hello everyone, i have an assignment is to write a C++ program that will calculate the potential distribution in a 10×10×10 environment containing obstacles. It will then find the shortest collision-free path for a flying robot from any given starting location to the target location.

My program should read the (starting location) , (the target location) , and (the obstacle locations) from a text file.

It will then calculate the potential distribution, use it to generate the path, and store the path in another text file.

***it is challenging assignment and i'm not sure how can i read 3d Arrays from file and how to write a function using Gauss-Seidel Method in 3d.

hope someone knows, thank you all.
Last edited on
Is it a console program that mimics something like 3d?
how can i read 3d Arrays from file 

Pretty well the same way as you would read anything else from file. It simply depends on what information is in the file and how it is set out in that file.

Gauss-Seidel Method in 3d.

Gauss-Seidel is just an iterative method for solving a set of coupled equations (making each variable - e.g. element of an array - the subject of its equation and repeatedly cycling through the set of equations). Depends what equations you want to solve.

 the potential distribution

"Potential" what? Potential energy? Electrostatic potential? Most "potential" equations are of the form (with partial derivatives):
d^2 phi / dx^2 + d^2 phi / dy^2 + d^2 phi / dz^2 = S
There are standard discretisations for those second derivatives. What matters is the source term S and the boundary conditions.

One thing is for sure - you need to decide what equations you intend to solve (and probably how you are going to discretise them) before you start any coding.
how can i read 3d Arrays from file

magic!

1
2
3
4
5
6
7
8
9
10
11
12

int array_3D[x][y][z];
std::string line;

for(auto iter_X=0; iter_X<x;++iter_X)
 for(auto iter_Y=0; iter_Y<y;++iter_Y)
   for(auto iter_Z=0; iter_Z<z;++iter_Z)
{
    (std::getline(file, line, ' '));
    array_3d[iter_X][iter_Y][iter_Z]= std::stoi(line);
}
Last edited on
Topic archived. No new replies allowed.