# Need to know euler angles of Vector3 direction relative to other Vector3 direction

 0 I tried this but it dont work as I expected(the results in euler had to be the same)... ``````Quaternion relative_rot = Quaternion.Inverse(transform.rotation) * Quaternion.LookRotation(Vector3.up); Vector3 relative_rot_euler = relative_rot.eulerAngles; Debug.Log("x,y,z : x1,y1,z1 " +transform.rotation.eulerAngles.x+", " +transform.rotation.eulerAngles.y+", " +transform.rotation.eulerAngles.z+" : " +relative_rot_euler.x+", " +relative_rot_euler.y+", " +relative_rot_euler.z ); `````` The primary idea is to measure deviation of direction in euler angles from one vector3 to another. more ▼ asked Dec 10 '10 at 02:38 AM Den 27 ● 2 ● 2 ● 2 SisterKy 2.5k ● 33 ● 42 ● 60 add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

 0 The problem may be that you're using Vector3.up as the (first) argument to LookRotation(), which is likely to produce an invalid result. The second (optional) argument to LookRotation() is the reference vector, which defaults to Vector3.up. If the input vector and the reference vector are parallel or nearly parallel (as is the case in the above code), the results are likely to be invalid. I'm a little skeptical regarding the usefulness of expressing a relative rotation in Euler-angle form, but I'll just assume you have a good reason for wanting to do that. more ▼ answered Dec 10 '10 at 04:19 AM Jesse Anders 7.3k ● 7 ● 17 ● 48 Thanks for the answer, but the problem is not resolved... I use euler angles to add torque to rigidbody for selective axes. This torque have to be dependent on relative angles between two vector directions(in my case oject`s down and another world vector).. And as a test I used other arguments to LookRotation() - Vector3.forward for example.. And angles for 1 or 2 axes were quite the same as transform.rotation.eulerAngles, but not for all 3 axes. Dec 10 '10 at 12:49 PM Den To be honest, I kind of doubt the approach you're taking here is viable. (That said, I don't know enough about the problem you're trying to solve to suggest an alternative.) Dec 10 '10 at 10:15 PM Jesse Anders I want to stabilize GO rotation using physics (AddTorque) on x and z axes only with respect to, for example, a normal to terrain or some other vector.. Thats what I`m trying to do =) Now I can stabilize to normal to x-z plane using directl transform.rotation.eulerAngles, but can`t do it for random vector. Will try to experiment more.. Dec 10 '10 at 11:53 PM Den It sounds like what you'd want to do here is apply a torque (with appropriate magnitude) that's parallel to the cross product of the game object's local up vector and the vector you want to align with. (Reaching a target orientation using applied torque only can be kind of tricky though - you might be able to find some threads on the topic in the forums.) Dec 11 '10 at 02:19 AM Jesse Anders Yes, I use PID controller, but I need a feedback of angle (sub of target and current). Tried to add auler angles of two rotations but still could not achieve proper angles.. ((( Dec 11 '10 at 12:13 PM Den add new comment (comments are locked) 10|3000 characters needed characters left ▼ Viewable by all users

By Email:

Topics:

x300
x296
x205
x143
x85

asked: Dec 10 '10 at 02:38 AM

Seen: 2902 times

Last Updated: Dec 10 '10 at 02:38 AM