quaternions

unity Rotate between min and max distance

守給你的承諾、 提交于 2019-12-10 20:48:26
问题 I'm trying to make it possible to drag an object. This object can only rotate so much. (Similair to a door). Here is the code abit edited that rotates an object which works. I have 2 vectors for maxrotation and minrotation. This code will be called whenever the user is dragging the interactible object. (like update but only when dragged) if (GestureManager.Instance.IsNavigating && HandsManager.Instance.FocusedGameObject == gameObject) { //speed and navigiation of rotation float rotationFactor

Quaternion Cameras and projectile vectors

烈酒焚心 提交于 2019-12-10 19:39:43
问题 In our software we have a camera based on mouse movement, and a quarternion at its heart. We want to fire projectiles from this position, which we can do, however we want to use the camera to aim. The projectile takes a vector which it will add to its position each game frame. How do we acquire such a vector from a given camera/quaternion? 回答1: The quaternion doesn't represent a direction, it represents a rotation. You can define a vector that points in the direction that your camera is

Converting glm quaternion to rotation matrix and using it with opengl

拜拜、爱过 提交于 2019-12-10 16:46:12
问题 so i have the orientation of my object stored in a glm::fquat and i want to use it to rotate my model. how do i do that? i tried this: glPushMatrix(); glTranslatef(position.x, position.y, position.z); glMultMatrixf(glm::mat4_cast(orientation)); glCallList(modelID); glPopMatrix(); but i got this error: error: cannot convert 'glm::detail::tmat4x4<float>' to 'const GLfloat* {aka const float*}' for argument '1' to 'void glMultMatrixf(const GLfloat*)'| im obviously doing something wrong so whats

Can I interpolate rotation from two Quaternions created from Yaw/Pitch/roll?

空扰寡人 提交于 2019-12-10 12:49:14
问题 Quaternions are good for interpolate rotations between them. so far so good. If I have a networking game, will it suffice to transfer the rotation as vector3f or should I use a quaternion? To make the game smoother I may have to interpolate between the last sent rotation and the current one. But can I interpolate rotations between two Quaternions which were created from Yaw/Pitch/Roll? Quaternion a = Quaternion.FromYawPitchRoll(x1,y1,z1); Quaternion b = Quaternion.FromYawPitchRoll(x2,y2,z2);

Longitude / Latitude to quaternion

谁说胖子不能爱 提交于 2019-12-10 04:52:47
问题 I've got a longitude and latitude and want to convert this to a quaternion and wondering how I can do this? I want to use this, because I've got an app which projects the earth on a sphere and I want to rotate from one location to another one. Best! 回答1: There's a way to go about this without using matrices or vectors, similar to this numpy implementation. We can think of longitude/latitude as two quaternion rotations composed together. Let's work with a Z-up right-handed coordinate system.

How to rotate about the center of screen using quaternions in opengl?

拜拜、爱过 提交于 2019-12-09 12:58:19
问题 I am trying implement arcball/trackball rotation but I have a problem with the center of rotation. I want the center to be the center of my screen no matter what. Let me explain what I have done so far. I've created a quaterion (rotation axis: vector_start x vector_end, angle: vector_start * vector_end) From that quaternion I've created a rotation matrix in order to use it with glMultMatrixf(matrix) and get the desired rotation. The problem is that while my model seems to arcball rotate as it

iDevice attitude: stabilising quaternion

大憨熊 提交于 2019-12-08 12:54:55
问题 I'm trying to use iDevice's attitude self.motionManager.deviceMotion.attitude.quaternion the device is resting on the table, but the values are not the same. how to stabilise these values without causing bad rotation? I'm using the device attitude to rotate the camera node. (x = -0.0055437298906573507, y = -0.0078092851375721247, z = -0.041180405121897398, w = 0.999105828407855) (x = -0.0061666945840810842, y = -0.0067849414785486747, z = -0.041464744435584115, w = 0.99909789881469635) (x =

Add offset to DeviceOrientationControls in three.js

烂漫一生 提交于 2019-12-08 07:54:43
问题 I'm trying to add an offset to the camera after deviceControls.update(); command. I used DeviceOrientationControls as shown in this first example. The offset will be the result of a drag gesture, as presents in this example. When I multiply the 2 quaternions (I have tried a x b and b x a), the final result is not correct. Here is my operation : const m1 = new THREE.Matrix4(); m1.lookAt(new THREE.Vector3(), camera.target, THREE.Object3D.DefaultUp.clone()); const quater = new THREE.Quaternion()

Direction vector to a rotation (three.js)

末鹿安然 提交于 2019-12-08 05:47:38
问题 I'm attempting rotate an arrow on the surface of a planet to face the direction it is traveling. I can get the direction vector and the up vector from the surface normal. How would I go about turning this into a quaternion for my arrows rotation. I'm using three.js so any suggested methods they provided that I can use would be useful. Cheers. The information I have so far. var upVector = new THREE.Vector3(); upVector.subVectors( new THREE.Vector3(0,0,0), lastVec ); var dirVector = new THREE

Unity - Clamp Rotation between arbitrary angles

微笑、不失礼 提交于 2019-12-08 01:35:11
问题 I have a task where I have to clamp an angle between other two angle. The catch is that the limits can be >360 or <0 (ex. [-45,45] or [275,45]). Is there a clean way to do this taking into account all the special cases? (ex. range [-45,45] and input angle of 225 should be -45). Thanks in advance! P.S. I am using unity, so I have all the default Quaternion methods at hand. Current Code: Quaternion inputAngle = Quaternion.identity; if (Character.IsFacingRight) inputAngle = Quaternion