# spiral physics help

This topic is 405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello Everyone,

Wondering if anyone has some ideas for me. This is also for 2D. Given a circle C(pos,r) I would like to drop a particle of arbitrary mass in, and watch it spiral towards the center.

I suspect I can use the Logarithmic Spiral to solve this problem, for example from here http://mathworld.wolfram.com/LogarithmicSpiral.html

However, it's position based. What I need is a directional force proportional to the distance from the center. So as the particle gets closer and closer to the center, the force increases.

Any sources or ideas would be much appraciated.

Mike

##### Share on other sites
I am not sure I understand what the problem is with it being "position based". Do you mean that you need to come up with a field of accelerations --not velocities-- that will produce spirals?

##### Share on other sites

Any attractive force will cause the particle to fall in a spiral, ending in contact instead of an orbit at some distance if there is attrition. Attrition makes the particle lose energy, until it has no potential energy and it reaches the attractor.

With a constant force towards the spiral center plus a constant force opposite the current velocity vector you cannot go wrong.

##### Share on other sites

I am not sure I understand what the problem is with it being "position based". Do you mean that you need to come up with a field of accelerations --not velocities-- that will produce spirals?

Hi Alvaro,

Yes, I am looking for F=ma => a=F/m. I know the mass, but I don't know how to calculate the Force vector which of course needs a normalized direction and a magnitude for a spiral.

Thanks,

Mike

##### Share on other sites
Well, you could try with something like (-x/(x^2+y^2), -y/(x^2+y^2)), but you also need to add linear drag to your equations of movement, or you will just get periodic orbits.

It you are dropping particles with some angular momentum, they will spiral. If you want the field to add the angular momentum, you can add something proportional to (y, -x). I would try that, that divided by distance to the origin, and that divided by distance to the origin squared, all of them multiplied by various constants. But I don't know what effect you are looking for exactly, so you'll have to play around with it yourself.

##### Share on other sites

Just for the record, potential energy is turned into kinetic energy. Energy isn't lost, just converted.

Edit: It seems that you want F related to gravitation and do numerical integration. Or do you want to do it parametrically?

Edited by sjhalayka

##### Share on other sites

Can someone please look into allowing me to upload files? I have some code that draws an orbit path.

##### Share on other sites

When replying hit the button "Use Full Editor".  It has an option at the bottom for uploading files.

Edited by frob

##### Share on other sites

I have some code that draws an orbit path.

What are you trying to upload? If it’s just “some code”, then why not submit it via pastebin.com?

##### Share on other sites

Because it's six files altogether.

Edit: I uploaded the files to GitHub.

https://github.com/sjhalayka/Orbit

Edited by sjhalayka

##### Share on other sites

In main.cpp, replace idle_func with the following code. This implements drag:

void idle_func(void)
{
custom_math::vector_3 grav_dir = sun_pos - mercury_pos;
custom_math::vector_3 drag_dir = -mercury_vel;

float distance = grav_dir.length();

grav_dir.normalize();
custom_math::vector_3 accel = grav_dir*(G*sun_mass/pow(distance, 2.0));

drag_dir.normalize();
accel = accel + drag_dir*(G*sun_mass/pow(distance, 2.1));

float dt = 10000;

mercury_vel = mercury_vel + accel*dt;
mercury_pos = mercury_pos + mercury_vel*dt;

positions.push_back(mercury_pos);

glutPostRedisplay();
}

Edited by sjhalayka