Comments and answers for "How to get Yaw? or How to get Angle between two vectors over 180?"
http://answers.unity.com/questions/1558320/how-to-get-yaw-or-how-to-get-angle-between-two-vec.html
The latest comments and answers for the question "How to get Yaw? or How to get Angle between two vectors over 180?"Comment by hannacho700 on hannacho700's comment
http://answers.unity.com/comments/1558656/view.html
If the object goes from -180 to 180, or from 180 to -180, the round variable is incremented or decremented, assuming that object turns around. And when you calculate the value, you can use round * 360 + yaw to get a value in the range greater than -180 to 180 , no matter how many turns the object is.Tue, 02 Oct 2018 00:54:43 GMThannacho700Comment by JVene on JVene's answer
http://answers.unity.com/comments/1558357/view.html
What do you mean by "get more big size of range". -180 to 180 is a full circle. There is no more to a rotation except spinning around and arriving at an angle inside that range. It could be interpreted as 0 to 360, which is basically the same thing.Mon, 01 Oct 2018 06:30:44 GMTJVeneComment by hannacho700 on hannacho700's answer
http://answers.unity.com/comments/1558338/view.html
I think I solve my problem. So I share my idea.
public float GetYaw()
{
var down = -transform.up;
down.y = 0;
Yaw = Vector3.Angle(-Vector3.right, down) * Mathf.Sign(transform.up.z);
if (Yaw - preYaw < -300) round++;
else if (Yaw - preYaw > 300) round--;
roundYaw = round * 360 + Yaw;
preYaw = Yaw;
return roundYaw;
}Mon, 01 Oct 2018 04:49:29 GMThannacho700Answer by hannacho700
http://answers.unity.com/answers/1558326/view.html
I omited some explanation. In my case, transform.up points his backside. So down means forward.
then I used "down.y =0" to bring vectors to xz plane.
So I can already get yaw based on left(-Vector3.right) in xz plane.
but It's range is -180~180.
so I want to get more big size of range.Mon, 01 Oct 2018 02:47:24 GMThannacho700Answer by JVene
http://answers.unity.com/answers/1558322/view.html
Let's be clear about one point in your question. There is no information that comes from vectors which can tell you how many times a rotation has been performed. If an object rotated 765 degrees clockwise in the xz plane, the only information you'll get back from the resulting information in a Transform will be that the object rotated 45 degrees clockwise, because that is all the information that remains.
----------
Vector3.Angle returns the angle between two vectors, without regard to any axis. If you define yaw as a rotation in the xz plane, there is no relevance to down or up. I would infer that a relationship to the world 'negative right' direction and the transform's 'down' direction is more that of a pitch than a yaw, but Vector3.Angle is going to return the angle between 'negative right' and wherever 'down' is pointing, which won't be relative to an axis. Imagine pointing your left hand straight out left (that's what negative right means, no?), then point your right hand ahead of you, but down from straight out 45 degrees. Now, in yaw (the xz plane), your arms are 90 degrees apart, but the angle between your hands will be somewhere less than 90 but greater than 45 degrees, in a plane at an angle not aligned with a reference to a yaw.
----------
You can get the rotation of an object (in the range of -180 to 180 degrees) using Mathf.Atan2, providing the coordinates you get from transform.forward ( x and z, ignoring y ). The return value is in radians which you can convert by multiplying the return by Mathf.Rad2Deg. Note, however, that the standard orientation may require adjustment to your expectations, because in math zero degrees (or zero radians) is on the X axis (to the right), and positive rotation is counterclockwise. Once you adjust that for your expectation, you'll get the angle in the xz plane the object is facing.Mon, 01 Oct 2018 02:01:59 GMTJVene