Answers for "how to combine 2 quaternion components?"
http://answers.unity.com/questions/119763/how-to-combine-2-quaternion-components.html
The latest answers for the question "how to combine 2 quaternion components?"Answer by Xav_m
http://answers.unity.com/answers/119786/view.html
Thanks!
I think I missunderstood quaternions.
I have a function that lines a prefab with an irregular terrain. Works ok as long as terrain is flat, when slopes occur some geometry gets into terrain mesh, so I get some cuts. I need to align the prefab to the last positioned one, to form a continous skidmark, so I thought on getting the normal of the terrain and aligning X,Z to terrain and Y to lookat previous prefab.
So back to question, how do I get a component from a quaternion?
I tried:
Debug.Log ("rotx: "+rotationQ[ 0 ]);
and get different result from
inspector value: 331.4471
debug log: -0.2466001
Thanks again.Sat, 21 May 2011 16:37:06 GMTXav_mAnswer by Peter G
http://answers.unity.com/answers/119765/view.html
I highly doubt that you want to do that.
1. Quaternions have 4 components so I don't know what you are even trying to do.
2. Each value does not necessarily store rotation around a single axis so editing a specific value might give you strange results.
Maybe you want Euler Angles:
var angleA : Vector3 = new Vector3 ( x , y , z );
var angleB : Vector3 = new Vector3 ( x , y, z );
var angleC : Vector3 = new Vector3 ( angleA.x , angleB.y , angleA.z);
transform.eulerAngles = angleC;
or if you want to use Quaternions use the "*" operator to multiply them together:
var rotationAngle : float = 90;
var quatA = Quaternion.AngleAxis(rotationAngle , Vector3.forward);
var quatB = Quaternion.AngleAxis(rotationAngle , Vector3.up);
var quatC = quatA * quatB;
//this will be rotate 90 degrees around the z axis and 90 degrees around the y axis.
transform.rotation = quatC;Sat, 21 May 2011 15:12:59 GMTPeter G