How Can I Fix the Error in My 3D Motion Simulation?

  • Context: Undergrad 
  • Thread starter Thread starter Zav
  • Start date Start date
  • Tags Tags
    3d Motion Simulation
Click For Summary

Discussion Overview

The discussion revolves around a user's issue with a 3D motion simulation of an object, specifically regarding the calculations of velocity and position that lead to unintended spiral motion instead of circular motion. The scope includes technical explanations and proposed solutions related to physics and programming in simulations.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • The user describes their simulation setup, including initial conditions and the calculations performed at each step, noting that the object is expected to move in a circular path but instead exhibits spiral motion.
  • One participant emphasizes the need for the force to always point towards the center of the circular motion, indicating that the force must maintain a specific relationship with the initial velocity for true circular motion.
  • Another participant suggests separating the forces into components in the x and z directions, proposing a method to calculate these forces and update velocities accordingly, referencing centrifugal and centripetal forces.
  • A further suggestion involves using object-oriented programming (OOP) principles, specifically recommending the creation of a vector class to simplify vector operations in the simulation code.

Areas of Agreement / Disagreement

Participants present multiple approaches and suggestions for resolving the user's issue, indicating that there is no consensus on a single solution. Different methods for handling forces and velocities are proposed, reflecting varying perspectives on how to achieve the desired circular motion.

Contextual Notes

There are assumptions regarding the nature of forces and the relationship between velocity and circular motion that remain unexamined. The discussion does not resolve the mathematical steps necessary to achieve the intended motion.

Zav
Messages
1
Reaction score
0
hi,
i try to build a simulation of an object in 3d space.
the object is point object with properties like this:

p : current position of an object.
v : current velocity of an object.
f : current force applied on an object.
m : object's mass (1 kg)
dt : time elapsed since previous step

start condition:
v = (0, 0, 10)
p = (0, 0, 0)
dt = 0;

at every simulation step (about 0.1 sec) the following calculations are made:
dt = GetTimeSinceLastStep()
f = CalculateForce()
v = v + (f / m) * dt
p = p + v * dt

the function CalculateForce calculates the current force at every step.
let's assume that this function always return force in zx plane, perpendicular to the current velocity toward (0, 0, 0).

in such case, object suppose to perform circular motion with constant speed about the origin in zx plane. but here is my problem [(f/m) * dt] vector (that added to current velocity) will always have some length. so after addition it to v (according to Pythagoras law) the new v vector will be longer than the previous one.

so in my simulation the object always increase it's speed and instead of cirlular motion a have a spiral one.

where is an error ??

thanx in advance :)
the new
 
Physics news on Phys.org
Force is a vector. For circular motion, you need to have the force always pointing towards the center of the circle of motion, the centripetal force. This force has to have a specific relation to your initial velocity for you to actually have the object move in a circle. So you should expect to get a force of constant magnitude.
 
If you are working in a two dimensional plane, you should work with two forces, one in z direction and one in x direction. Your program should more or less look like this

f_x = CalculateForceX()
f_z = CalculateForceZ()
v_x = v_x + (f_x / m) * dt
v_z = v_z + (f_z / m) * dt
p_x = p_x + v_x* dt
p_z = p_z + v_z* dt

the relations for the force would be something equivalent to f_x = -F*cos(phi) and f_z = -F*sin(phi). Phi is the angle between the x-axis and the current place of your mass in counterclockwise direction. F is the centrifugal force, directed to the center, this should counter the centripetal force, this is m*V^2/r if I remember correctly, with V it's total speed and r the distance to the center.
 
Last edited:
If you're using an OOP, I suggest making a vector class. If you're using C++ specifically, you can overload operators, so that instead of writing

v_x = v_x + (f_x / m) * dt
v_y = v_y + (f_y / m) * dt
v_z = v_z + (f_z / m) * dt

you just write

v = v + f/m * dt;
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 41 ·
2
Replies
41
Views
4K
  • · Replies 24 ·
Replies
24
Views
4K
  • · Replies 35 ·
2
Replies
35
Views
5K
  • · Replies 27 ·
Replies
27
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 43 ·
2
Replies
43
Views
4K