How do we simulate 3D space?

  • Thread starter tolove
  • Start date
  • Tags
    3d Space
In summary, the conversation discussed the process of translating real-world positions into computer language, using an example of simulating a ball in a closed box. The need for accuracy and confidence in representing reality in computer programs was also mentioned, along with the idea of comparing results to the actual system being modeled. The use of a lattice of points to represent continuous space in numerical simulations was also brought up.
  • #1
tolove
164
1
How can we translate real-world positions into a computer language? An example would be to simulate a ball bouncing around in a closed box.

How can we say with confidence that the program will represent reality?

This is my current thinking on how to manage space. Any advise or critique would be greatly appreciated!

Code:
import numpy as np
import numpy.random as rand

def gen_space(xsize=10, ysize=10, zsize=10):
    '''
        Create and fill a 3D space with random values on the interval [0,1].

        When accessing points in this space, we can visualize like so:

        space[:][Y][Z]      # Returns (x) at y=Y, z=Z
        space[X][:][Z]      # Returns (y) at x=X, z=Z
        space[X][Y]         # Returns (z) at x=X, y=Y
        space[:][:][Z]      # Returns (x, y) at z=Z
        space[:][Y]         # Returns (x, z) at y=Y
        space[X]            # Returns (y, z) at x=X
        space[X][Y][Z]      # Returns value at the point (X, Y, Z)

        Returns: space, [xsize, ysize, zsize]
    '''

    # space = np.array([[[None] * zsize] * ysize] * xsize)  # Safe method
    space = np.empty([zsize, ysize, xsize])  # Fast method

    for x in range(xsize):
        for y in range(ysize):
            for z in range(zsize):
                space[x][y][z] = rand.random()

    return space, [xsize, ysize, zsize]

if __name__ == '__main__':
    space, sizes = gen_space()

Thank you very much for your time and thoughts!
 
Physics news on Phys.org
  • #2
The only way we can say a program represents reality is to take its results and compare it to the system its trying to model.

I did a course in Computational Physics where we modeled simple systems like oscillation springs and pendulums and depending on the choice of ODE solver you picked you either lose energy or add energy in your simulation and after a awhile you would notice why that ODE was a bad idea.

Even the best computer simulations only approximate the system they are trying to model and for some cases that is okay but we can never truly know whether it does or not without constant comparing of results.

This is one of the reasons why trial lawyers object to simulations of events because you can make a plausible looking movie that is not true to reality with bad physics and the jury would believe it...
 
  • #3
Storing a continuous space as a lattice of points is indeed the most common representation. In most all cases, this can be done in a controlled manner. Specifically, for a space of linear length ##L##, discretized using ##N## points on a lattice (stored in an array), there is a lattice spacing ##a = L/N##. Although technically we only recover continuous space in the limit ##a \rightarrow 0## (or ##N \rightarrow \infty##), many numerical results can be "converged" to a given accuracy. By "converged," we essentially mean that if we make ##a## smaller (say by a factor of two, by doubling ##N##), we find that the results do not change (to our desired level of accuracy). Many computational algorithms can be analyzed to understand how the error depends on ##a##, for example an algorithm which has an error scaling as ##a## is worse than one which scales as ##a^2##, because the latter would allow for a larger ##a## (and thus smaller ##N##, and therefore less memory and faster calculations).
 

1. How do we create a 3D model?

Creating a 3D model involves using specialized software, such as computer-aided design (CAD) or 3D modeling software, to digitally construct a three-dimensional object. This process typically involves creating a wireframe, applying textures and materials, and adding lighting and animation to bring the model to life.

2. What is the difference between 3D modeling and 3D rendering?

3D modeling is the process of creating a digital representation of a three-dimensional object, while 3D rendering is the process of converting that model into a two-dimensional image or animation. 3D rendering adds realistic lighting, shadows, and textures to the model to make it appear more lifelike.

3. How do we simulate movement in 3D space?

To simulate movement in 3D space, we use mathematical algorithms and equations to calculate the position, velocity, and acceleration of objects in the virtual environment. This is often done through computer graphics libraries and game engines that allow for real-time movement and interaction with the 3D space.

4. What is the importance of a coordinate system in 3D simulation?

A coordinate system is essential in 3D simulation as it allows us to accurately define the position, orientation, and movement of objects in the virtual space. This helps maintain consistency and realism in the simulation and allows for precise control over the objects' movements and interactions.

5. How do we account for depth perception in 3D simulation?

Depth perception in 3D simulation is achieved through techniques such as perspective projection, where objects appear smaller as they move further away from the viewer, and stereoscopy, where each eye receives a slightly different image to create the illusion of depth. These techniques mimic how our eyes perceive depth in the real world, making the simulation more immersive and realistic.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
4K
  • Precalculus Mathematics Homework Help
Replies
17
Views
877
  • Precalculus Mathematics Homework Help
Replies
8
Views
292
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
6
Views
788
  • Programming and Computer Science
Replies
8
Views
741
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
Replies
13
Views
2K
Back
Top