# yade-users team mailing list archive

## Re: [Question #698572]: Is it possible to constrain the motion of a body along a circle

```Question #698572 on Yade changed:

Karol Brzezinski proposed the following answer:
Hi,

I  came up with a simple idea, that could work. It doesn't require any
optimization tools, so theoretically should be faster. Unfortunately, I
my implementation was quite slow and  still required regularization such
ass your eccentricAxisEngine(). Maybe it was due to the numerical issues
and maybe just erroneous code. Thus, I will not share the code because I
don't want to suggest wrong solutions (unless you want the code), but I
will share the idea behind this.

I limited the problem to the 2D space.
1) The rotation center is in  point (0,0,0) and the center of mass travels along circle of radius (R). So the angular acceleration (omega") is related with linear acceleration in tangential direction (a") by kinematics: a" = R*omega". By knowing mass and inertia of the body this relations can be expressed in terms of unbalanced force (f_u) and unbalanced torque (t_u).
2) First I read unbalanced force from the forceContainer. I add the "force equivalent of gravity", and than I leave only component in the direction tangential to the circle (for the current position).  Based on this and eq. from point (1), I can compute the desired (target) torque.
3) The force in point (2) is almost the target force, I need to add the component "balancing eccentric force", based on the actual velocity and given radius.
4) Knowing my target torque and target force I modify existing unbalanced forces by adding corrections.

Eventually I got confused by inertia convention in clumps. I am
suspecting a bug, but maybe I should start another topic for that.
Please note that your very first solution works like a charm if you stay
in one plane (e.g. y-z).

It can be visualized by modifying fragment of your code:
######################
# ---------------------------------------------------------------------------------- bodies
sph1 = sphere((0, 2, 0), .5)
sph2 = sphere(center=(0, 0, 0), radius=.5)

sph1_id = O.bodies.append(sph1)
sph2_id = O.bodies.append(sph2)

g = Vector3([0,0,-10])
stiffnes = 1e7

# ---------------------------------------------------------------- clump
clump_id = O.bodies.clump([sph1_id, sph2_id])

####### additional sphere to collide with
sph3 = sphere((0, -2.25, 3), .5)
sph3_id = O.bodies.append(sph3)
#######################

Good luck!
Karol

--