Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
336 views
in Technique[技术] by (71.8m points)

physics - Modelling circular motion / tangential acceleration

The following pseudo code works for modelling linear acceleration (applying calculateNextStep and doNextStep for each time tick):

class myObject{

    vector positionVector
    vector velocityVector
    vector accelerationVector
    vector forceVector

    function calculateNextStep(){
        resetForceVector()
        calculateNetForces()
    }

    function doNextStep(){
        accelerationVector = forceVector.getCopy()
        accelerationVector.divideBy(mass)
        velocityVector.add(accelerationVector)
        positionVector.add(velocityVector)
    }
}

My understanding is that for circular motion we need to apply a force orthogonal to the velocity of the object. The size of that force will determine the radius of the circle:

    function calculateNextStep() {
        resetForceVector()
        orthogonalForce = velocityVector.getCopy.getOrthogonalVector()
        orthogonalForce.setLength(sizeOfForce)
    }

When I apply this approach the object doesn't travel in a circular path. Instead it spirals outwards, increasing in velocity.

I assume this is because the tangential force only applies instantaneously ie. as soon as the object moves the tangential force should change accordingly but I don't know how to account for this in my model.

I assume this has been tackled before but can't find anything. Is there a correction term I should be applying? Something to do with limits / integrals?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You are right with your assumption. The problem lies with the tangential force.

But there are two problems with the way you calculate your tangential force:

  1. What you mentioned, that the force should apply instantaneously.
  2. The way you calculate your force, the center of rotation changes throughout the simulation.

Both of those can be fixed by decreasing the timestep and increasing the number of iterations, but those are hardware bound, so you will eventually hit the bottom there.

A better way to fix those problems is by using a different model:

Using a conservative force(examples of that are gravity, electrostatic forces, Forces from a rope that connects your object and the center, …) allows the system to correct itself if it starts spiraling(If your object leaves the desired radius, conservative forces will make sure it comes back).

Here an example implementation for gravity:

orthogonalVector = centerPoint - positionVector;
float value = orthogonalVector.value();
float scalar = gravityConstant*centerMass/pow(value, 3);
accelerationVector = scalar*orthogonalVector;

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...