Calculate new(x,y) for a line

103 Views Asked by At
  1. Suppose if tanks has to rotate its main gun by $30^\circ$ to hit the target, what will be its new $(x,y)$ coordinate or a formula to calculate it as shown in image?

  2. If bullet is fired from the main gun in that direction how to move bullet $((x_1,y_1)(x_2,y_2))$ straight to target or what the formula for bullet to travel from main gun to the target?

Just for assumption we can consider line as bullet in image

Image

What I have tried:

  1. $x=r\cos\theta$ and $y=r\sin\theta$ to calculate new $(x,y)$ but this is possible only if my circle is at origin.

  2. If I get my new $(x,y)$ I will be able to calculate my slope for that line i.e $m=\frac{y2-y1}{x2-x1}$ and then add my slope m each time to move my bullet forward in that direction to hit the target.

2

There are 2 best solutions below

0
On

It may have already occurred to the poster that one could translate the origin via the equation (x-h)^2+(y-k)^2=r^2 such that the new origin is the values of (h,k).

0
On

First off, I'm typing this on my phone making it difficult to respond.

You could also use the 2 dimensional rotation matrix

cosx -sinx sinx cosx (I see this is being changed from my phone to visual, this is a 2x2 matrix) Where x is in radians, you can convert to radians via r/d=2pi/360=pi/180 where r is radians and d is degrees.

Once the value is in this matrix, we will be using matrix multiplication in the order of Rp, where R is the rotation matrix and p is the column vector deriving the new point (x,y).

Assuming you have converted 30° to radians we get pi/6.

We then have, (root3/2) -(1/2) (1/2) (root3/2)

x*=[(root3)/2]x-(1/2)y y*=(1/2)x+[(root3)/2]y

The point (x*,y*) is the new rotated point through 30°.