Rotating on object so point on object faces a position

abrobot

New member
Joined
Nov 26, 2021
Messages
2
First, id like to say that this is my first question, so please forgive me if my question isn't perfect. I'm also not great at math, but I believe this is a trig problem.


Say for example you have a guy pointing.

1638026426530.png

You know his position and his rotation from the center of his body. You Also have the position of his hand. Now there is a position off in the distance somewhere, and you need to rotate this person so that hand is pointing directly at that position. Let's say for simplicity that you only need to rotate the person on one axis (right and left for example) to achieve this. How would you do so?

Any help with this would be very appreciated. This question is not for homework it's just for personal use. if this is the incorrect place to ask this question, I apologize and would appreciate it if you pointed me in the right direction. See what i did there. XD
 
I would start by defining all the parameters of this model:
  1. We can assume, without loss of generality, that the rotation axis of the body goes through the origin. Once the problem is solved it can be translated to an arbitrary location of the rotation axis.
  2. Next, we need some notation for the position of the hand: direction (unit) vector [imath]\bar v[/imath] with coordinates [imath]v_x,v_y,v_z[/imath] and the point of origin (elbow?) [imath]\bar p[/imath] with coordinates [imath]p_x,p_y,p_z[/imath].
  3. We also need notation for the target point [imath]\bar g[/imath] with components [imath]g_x,g_y,g_z[/imath]. Although the Z coordinates are not important at this point if we can only rotate the body around the Z axis.
  4. The location of the hand [imath]\bar p[/imath] together with its direction vector [imath]\bar v[/imath] defines a line in 3D, but we are interested in its project on XY plane only, i.e., the first two coordinates.
  5. Instead of rotating the shooter we can rotate the target to put it in the line of fire. Once we compute the angle [imath]\alpha[/imath] for such rotation we can apply the opposite rotation to the shooter to achieve the same goal, i.e. having the hand pointing at the target.
  6. How do we put the target on the line defined by the hand? Rotated target lies somewhere on the same circle as the original target. We can compute the intersection points of this circle with the "line of fire". Note that there will be two points of intersection: one for shooting straight forward and one for shooting backwards.
 
I would start by defining all the parameters of this model:
  1. We can assume, without loss of generality, that the rotation axis of the body goes through the origin. Once the problem is solved it can be translated to an arbitrary location of the rotation axis.
  2. Next, we need some notation for the position of the hand: direction (unit) vector [imath]\bar v[/imath] with coordinates [imath]v_x,v_y,v_z[/imath] and the point of origin (elbow?) [imath]\bar p[/imath] with coordinates [imath]p_x,p_y,p_z[/imath].
  3. We also need notation for the target point [imath]\bar g[/imath] with components [imath]g_x,g_y,g_z[/imath]. Although the Z coordinates are not important at this point if we can only rotate the body around the Z axis.
  4. The location of the hand [imath]\bar p[/imath] together with its direction vector [imath]\bar v[/imath] defines a line in 3D, but we are interested in its project on XY plane only, i.e., the first two coordinates.
  5. Instead of rotating the shooter we can rotate the target to put it in the line of fire. Once we compute the angle [imath]\alpha[/imath] for such rotation we can apply the opposite rotation to the shooter to achieve the same goal, i.e. having the hand pointing at the target.
  6. How do we put the target on the line defined by the hand? Rotated target lies somewhere on the same circle as the original target. We can compute the intersection points of this circle with the "line of fire". Note that there will be two points of intersection: one for shooting straight forward and one for shooting backwards.
Thank you for the reply; sadly I don't understand it very well. I'm not too familiar with trig, but I'm trying to read it slowly, so maybe I can put things together.
 
Here are more pointers (note that we do everything in the XY plane only):
Squared distance from the target to the origin is [imath]r_g^2 = g_x^2+g_y^2[/imath], so when the target is rotated all points [imath]x,y[/imath] where it can end up satisfy the equation for the circle : [imath]x^2+y^2 = r_g^2[/imath].
Now all the points on the straight line going through the hand can be described by a parametric equations [imath]x_t = p_x + t v_x, y_t = p_y +t v_y[/imath]. If you now plug in the expressions for [imath]x_t,y_t[/imath] into the equation for the circle you get a quadratic equation for [imath]t[/imath].
Once you find values for [imath]t[/imath] the corresponding [imath]x_t,y_t[/imath] are the positions where the target has to be rotated to be in the line of fire (and only one of them will be in front of the hand)
Does this make sense so far?
 
You know his position and his rotation from the center of his body. You Also have the position of his hand. Now there is a position off in the distance somewhere, and you need to rotate this person so that hand is pointing directly at that position. Let's say for simplicity that you only need to rotate the person on one axis (right and left for example) to achieve this. How would you do so?

If this is being done on a computer, you might consider use of the atan2 function, which accepts an X/Y coordinate pair (usually with Y first for some reason) and determines the angle to that point in the range of [imath]\left(-\pi, \pi\right][/imath]. It operates on the principle that X and Y coordinates are analogous to the adjacent and opposite legs of a right triangle and that the inverse tangent is useful for computing the angle. Find the angle to the point on the object, find the angle to the point of interest, and determine the angle of rotation by subtracting.
 
Top