Translate linear motion to polar coordinates

1.5k Views Asked by At

I'm a math noob, so even though I want to understand a general solution to my problem, I don't even know how to articulate it except as an example. So:

The setup: Suppose I want to draw a segment from (1,2) to (0,1) on the Cartesian plane. Suppose I get to do so by tracing a vector along said segment. That is, I have a stepper motor at (0,0) that rotates about the z axis, and a pen parallel to the z axis, tip facing the xy plane, attached to the tip of a rod that can extend linearly from the axle of the stepper motor. Effectively, I can represent arbitrary vectors from the polar origin (ignoring length limitations, lets assume I can manage sqrt(5).

My problem is thus: If I run the stepper motor at constant velocity, this represents constant angular velocity. This is not a problem, except I would need to know how to compensate for this by moving the pen tip (vector magnitude) such that the end result is a smooth -y-ward motion. I have no idea where to begin. I would even appreciate answers that point me toward being able to ask this question more succinctly.

2

There are 2 best solutions below

1
On BEST ANSWER

The transformation from Cartesian coordinates to polar coordinates is $$ x = r\cos\theta, \quad y=r\sin\theta. $$ Since the equation of the line on which your two points lie is $y=x+1$, its polar equation is $$ r\sin\theta=r\cos\theta+1, $$ which you can solve for $r$ to obtain $$ r = \frac1{\sin\theta - \cos\theta}. $$ That tells you what you want the radial position of the pen to be, given the current angle of the stepper motor.

If the constant angular velocity, which is $\frac{d\theta}{dt}$, is equal to $a$ (make sure you use radians per second, not degrees per second!), then the required velocity of your pen tip in the radial direction should then be $$ \frac{dr}{dt} = \frac{dr}{d\theta} \frac{d\theta}{dt} = \frac{\sin\theta+\cos\theta}{\sin2\theta-1} \cdot a. $$

1
On

Suppose you go from point $A=(x_A=1,y_A=2)$ to point $B=(x_B=0,y_B=1)$.

The movement of an arbitrary point $M=(x,y)=(r\cos \theta,r \sin \theta)$ along a segment $[AB]$ is described by $M=(1-\lambda)A+\lambda B$ with $\lambda\in[0,1]$.

$\begin{cases} x= r\cos \theta = (1-\lambda)x_A+\lambda x_B = 1-\lambda \\ y= r\sin \theta = (1-\lambda)y_A+\lambda y_B = 2-\lambda \end{cases}$

You get $r^2 = x^2+y^2 = (1-\lambda)^2+(2-\lambda)^2 = 5-6\lambda+2\lambda^2$

And $\displaystyle{\tau=\tan\theta=\frac yx=\frac{2-\lambda}{1-\lambda}}$

Since you want your motor to have constant angular velocity, it means $\theta=vt$ so we have to express $\lambda$ as a function of time, to get $r$ as a function of the time too.

$(1-\lambda)\tau=2-\lambda\iff(\tau-1)\lambda=\tau-2\iff\lambda=\frac{\tau-2}{\tau-1}$

Finally you get

$\begin{cases} \theta = vt \\ \tau = \tan\theta \\ \lambda=\frac{\tau-2}{\tau-1} \\ r = \sqrt{5-6\lambda+2\lambda^2} \end{cases}$

Note: to do this in general, keep the values $x_A,x_B,y_A,y_B$ as I showed at the beginning. You may also have to check the special case $x=0$ to avoid infinite values of $\tau$ and take an approximation instead.

$\begin{cases} \displaystyle{\lambda=\frac{y_A-x_A\tan(\theta)}{(x_B-x_A)\,\tan(\theta)-(y_B-y_A)}} \qquad \mathrm{or\ }\lambda=\frac{x_A}{x_A-x_B}\ \mathrm{when \ x=0}\\\\ \displaystyle{x= (1-\lambda)x_A+\lambda x_B} \\ \displaystyle{y= (1-\lambda)y_A+\lambda y_B} \\\\ \displaystyle{r=\sqrt{x^2+y^2}} \end{cases}$