• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How do you make a point face a vector?

Let's say I have a vector at a location (4,3,5) in space and I have an object at (0,0,0). How many degrees x and y would I need to rotate the object to make it face the vector?
 
It depends.

To elaborate: A point is non-dimensional and can't "face" any particular direction. So, you need to tell us the shape of the object at 0,0,0. A vector has direction and magnitude. We would need to know the direction your direction is in (orientation) and the magnitude. We also need to know what you mean by "face". Do you want the object to face the origin of the vector, the termination of the vector, the midpoint?
 
Last edited:
Use x and y to get one angle using trigonometry. Use x and z to get the other angle. That's all you need.
 
Use x and y to get one angle using trigonometry. Use x and z to get the other angle. That's all you need.

I rotate Y along atan2(X, Z) and then X by atan2(Z, Y). It looks fine if I do one or the other, but completely wrong if I do both. Is there some way to combine the rotations into one?
 
I want the thing at (0,0,0) to face the point. The point is just there.

That's a different question than asked in the OP. It now sounds like you are asking for the angles relative to the x,y, and z axes in a Cartesian coordinate system of a line originating at (0,0,0) and ending at (4,3,5). In that case, Arcadio's post.
 
If the object is already facing "up" - towards, say, (0,0,5) then you would rotate it tan(-1)(3/4) on the z axis (to face the 4,3,5 point on the x/y plane) and 90-tan(-1)(5/((3^2)(4^2))^0.5) on a different axis to point it "down" towards the point.

I think. I probably have something inverted or backwards there.
 
That was my first thought. http://forums.anandtech.com/showpost.php?p=37961645&postcount=9

Is it doable with a single rotation?

Not in a 3-dimensional space. Arcadio's comment about altitude and azimuth is on the money.

In most 3D modelling programs, the rotation on two axes would be a single transform operation (enter both numbers).

Try swapping around the X/Y/Z values in your math, or rotating by the complement of the angle instead, just to see if you can luck your way into it.
 
Not in a 3-dimensional space. Arcadio's comment about altitude and azimuth is on the money.

In most 3D modelling programs, the rotation on two axes would be a single transform operation (enter both numbers).

Try swapping around the X/Y/Z values in your math, or rotating by the complement of the angle instead, just to see if you can luck your way into it.

Instead of rotating along blue and then red in two steps, what formula would I need to just rotate along green in one step?


wD9mapS.png
 
The same way you tear off a band-aid...

you've got to make the point realize that there really is no denying the vector, and that sooner or later it must be dealt with; obviously the sooner, the better.

Hope this helps your point do what it needs to do, there's probably going to need to be some talking and conversation afterwards to reflect on how things went. But everybody will feel better once it's done.
 
Bruh, if you know of a textbook that contains this information then show me the PDF.

This is an extremely common question. Googling it would be the easiest way to get the answer. I've done it a bunch of times. Well, making a vector face a point is a common question anyway. Points don't face anything, so you wouldn't be able to do that no matter who you asked.
 
Instead of rotating along blue and then red in two steps, what formula would I need to just rotate along green in one step?


wD9mapS.png

you would use the pythagorean theorem to figure out the length of the yellow line segment (0,0,0),(4,3,5), and then use trig functions to determine the green angle compared to the grey line segment (which looks like it's (0,0,0),(0,3,0) or something. Dunno because the axes aren't labelled.)

But the plane defined by the yellow and grey bars intersects the x/y plane at an angle that you'd also have to determine. So you'd still need two angles.

Angles are two-dimensional in nature - you need two of them to describe three-dimensional movement.
 
where is the object "facing"? the object isn't just a point - it's something at 0,0,0 that's pointing a certain direction.

in which case you are looking for the euler angles between two vectors. that will tell you the rotations about X, Y, Z axes to get from one vector to another. i have a book (not on hand) that describes how to get these.

if you're looking for a single angle, then using the dot product of two vectors will work. A dot B = |A||B|cos(theta) will give you the angle between the two vectors, but it doesn't tell you the rotations require to align said vectors.

edit: also, the position of the vectors do not matter (vector 1 starts at 0,0,0 while vector 2 starts at 4,3,5). what matters is the direction and length of those vectors. the distance between the starting points is a translation, not a rotation.
 
Last edited:
helps if you use the correct terminology.

assuming this is for some sort of 3d application:
all objects are stand-ins for transformation matrix, so in order to point something you need to know/define the aim vector and an up vector. (typically either the x-axis or sometimes the z-axis)

in a Cartesian coordinate system all rotational transforms will be standard vector rotates in a predefined order(x 1st, y 2nd, z 3rd) or any arbtrary sequence(zyx,yxz,xzy,etc). so as everyone has indicated standard vector math or pythagorean with trig will give you your rotations.

However what the OP seems to be referring to is a Euler transform. euler coordinates are used to avoid gimbal lock in IK solutions by calculating rotations outside the normal rotation predefined order in a simultaneous calculation. main problem is that the OP is confusing a polar system rotation with a cartesian system. Euler transforms are way beyond my college maths or 3d animation schooling, so i wont even bother pretending to explain.
 
you would use the pythagorean theorem to figure out the length of the yellow line segment (0,0,0),(4,3,5), and then use trig functions to determine the green angle compared to the grey line segment (which looks like it's (0,0,0),(0,3,0) or something. Dunno because the axes aren't labelled.)

But the plane defined by the yellow and grey bars intersects the x/y plane at an angle that you'd also have to determine. So you'd still need two angles.

Angles are two-dimensional in nature - you need two of them to describe three-dimensional movement.

I'm pretty sure green is just the arccosine of the dot product. The length of yellow is irrelevant. That's just the vector.
 
helps if you use the correct terminology.

assuming this is for some sort of 3d application:
all objects are stand-ins for transformation matrix, so in order to point something you need to know/define the aim vector and an up vector. (typically either the x-axis or sometimes the z-axis)

in a Cartesian coordinate system all rotational transforms will be standard vector rotates in a predefined order(x 1st, y 2nd, z 3rd) or any arbtrary sequence(zyx,yxz,xzy,etc). so as everyone has indicated standard vector math or pythagorean with trig will give you your rotations.

However what the OP seems to be referring to is a Euler transform. euler coordinates are used to avoid gimbal lock in IK solutions by calculating rotations outside the normal rotation predefined order in a simultaneous calculation. main problem is that the OP is confusing a polar system rotation with a cartesian system. Euler transforms are way beyond my college maths or 3d animation schooling, so i wont even bother pretending to explain.

I am using a transformation matrix. Might it be easier to change the matrix directly?
 
Back
Top