quaternions

Component of a quaternion rotation around an axis

自作多情 提交于 2019-11-26 18:31:58
I'm having trouble finding any good information on this topic. Basically I want to find the component of a quaternion rotation, that is around a given axis (not necessarily X, Y or Z - any arbitrary unit vector). Sort of like projecting a quaternion onto a vector. So if I was to ask for the rotation around some axis parallel to the quaternion's axis, I'd get the same quaternion back out. If I was to ask for the rotation around an axis orthogonal to the quaternion's axis, I'd get out an identity quaternion. And in-between... well, that's what I'd like to know how to work out :) sebf I spent the

Rotating a Group of Vectors

岁酱吖の 提交于 2019-11-26 10:57:30
I am trying to rotate a group of vectors I sampled to the normal of a triangle If this was correct, the randomly sampled hemisphere would line up with the triangle. Currently I generate it on the Z-axis and am attempting to rotate all the samples to the normal of the triangle. but it seems to be "just off" glm::quat getQuat(glm::vec3 v1, glm::vec3 v2) { glm::quat myQuat; float dot = glm::dot(v1, v2); if (dot != 1) { glm::vec3 aa = glm::normalize(glm::cross(v1, v2)); float w = sqrt(glm::length(v1)*glm::length(v1) * glm::length(v2)*glm::length(v2)) + dot; myQuat.x = aa.x; myQuat.y = aa.y; myQuat

Finding quaternion representing the rotation from one vector to another

人走茶凉 提交于 2019-11-26 09:57:33
I have two vectors u and v. Is there a way of finding a quaternion representing the rotation from u to v? Polaris878 Quaternion q; vector a = crossproduct(v1, v2); q.xyz = a; q.w = sqrt((v1.Length ^ 2) * (v2.Length ^ 2)) + dotproduct(v1, v2); Don't forget to normalize q. Richard is right about there not being a unique rotation, but the above should give the "shortest arc," which is probably what you need. Half-Way Vector Solution I came up with the solution that I believe Imbrondir was trying to present (albeit with a minor mistake, which was probably why sinisterchipmunk had trouble verifying

Using Quaternions for OpenGL Rotations [duplicate]

只愿长相守 提交于 2019-11-26 08:19:30
问题 This question already has answers here : Quaternion rotation without Euler angles (3 answers) Closed 10 months ago . So I\'m writing a program where objects move around spacesim-style, in order to learn how to move things smoothly through 3D space. After messing around with Euler angles a bit, it seems they aren\'t really appropriate for free-form 3D movement in arbitrary directions, so I decided to move on to what seems to be best for the job - quaternions. I intend for the object to rotate

Rotate GameObject over time

这一生的挚爱 提交于 2019-11-26 03:27:02
问题 I a new here and i try to start working with Unity Engine. Could somebody explain me, how works Quaternion.Slerp? Because I want to rotate some object in different angles 90, 180 and 270. My code you can see below. Unfortunately when I add 180 degrees, object make crazy things and than put rotation to (0, 180, 180) for this game object. I would like to get (180,0,0) public float speed = 0.1F; private float rotation_x; void Update() { if (Input.GetButtonDown(\"Fire1\")) { rotation_x =

Rotating a Group of Vectors

对着背影说爱祢 提交于 2019-11-26 02:15:02
问题 I am trying to rotate a group of vectors I sampled to the normal of a triangle If this was correct, the randomly sampled hemisphere would line up with the triangle. Currently I generate it on the Z-axis and am attempting to rotate all the samples to the normal of the triangle. but it seems to be \"just off\" glm::quat getQuat(glm::vec3 v1, glm::vec3 v2) { glm::quat myQuat; float dot = glm::dot(v1, v2); if (dot != 1) { glm::vec3 aa = glm::normalize(glm::cross(v1, v2)); float w = sqrt(glm:

Finding quaternion representing the rotation from one vector to another

筅森魡賤 提交于 2019-11-26 01:56:32
问题 I have two vectors u and v. Is there a way of finding a quaternion representing the rotation from u to v? 回答1: Quaternion q; vector a = crossproduct(v1, v2); q.xyz = a; q.w = sqrt((v1.Length ^ 2) * (v2.Length ^ 2)) + dotproduct(v1, v2); Don't forget to normalize q. Richard is right about there not being a unique rotation, but the above should give the "shortest arc," which is probably what you need. 回答2: Half-Way Vector Solution I came up with the solution that I believe Imbrondir was trying