Questions tagged [quaternions]

1

votes
0

answer
5

Views

How can i use a local orientation from an IMU to manipulate global orientation of an object in Unity?

I have an IMU (inertial measurement unit), i recieve it's orientation in Quaternion expressed in it's own local coordinate system (LT in picture). I want to convert this orientation to one expressed in a global coordinate system. I have found a way to do this, by using the gravity vector from the IM...
pvand
1

votes
0

answer
276

Views

How to get pitch correctly with GLM?

I am trying to limit rotation of the camera around X axis by 90 degrees. My camera uses glm::quaternion to store orientation in space. For changing camera pitch angle I use the code: m_orientation *= glm::quat(vector3(glm::radians(angle), 0.0, 0.0)); And later I extract pitch angle I use: float pitc...
Nikolai Paukov
1

votes
0

answer
39

Views

Controlling rotation path in Unity3D

On my top down 2.5D shooter game, I am usingQuaternion.LookRotation() and Quaternion.Lerp() to change the rotation of my player towards a click. The player rotates just fine, but I need more control over the rotation path. The issue here is that the LookRotation() always returns the shortest path...
Fabio S.
1

votes
0

answer
38

Views

How do I rotate a 3D object relative to its orientation using quaternions?

As a learning experience, I'm trying to build a simple 3D game without any libraries. I've managed to figure out rendering (for the most part), and I've gotten 4D matrix transforms to work well enough. I'm having trouble rotating my player object relative to its own orientation; I want to build an a...
Peter N Wood
3

votes
0

answer
16

Views

Quaternion division

Quaternion multiplication is well-defined, and is known to me as 'Hamilton product': // hamilton product vec4 qmul(in vec4 q1, in vec4 q2) { return vec4( q1.w * q2.xyz + q2.w * q1.xyz - cross(q1.xyz, q2.xyz), q1.w*q2.w - dot(q1.xyz, q2.xyz) ); } However, for implementing qtanh() quaternionic functio...
xakepp35
1

votes
1

answer
993

Views

Unity3D angle between vectors/directions on specific axis

I have two directions and i am trying to calculate the angle on a specific axis. The object from which the directions are derived is not a static object so i'm struggling to get my head round the maths to work out what i need to do. FYI, I have the start and end points that i have used to calculate...
user7856951
1

votes
1

answer
770

Views

Madgwick AHRS algorithm Android implementation

I'm trying to implement Madgwick sensor fusion algorithm from here, to calculate orientation of my phone. It works relatively fine when I am moving, but it if the phone is steady on the table it starts to accumulate errors very quickly. I tried to play with sensor update rate and filter gain, but i...
Jopo Podpleský
1

votes
0

answer
43

Views

c# quaternion reference system

I'm working on an Android app which extracts a Quaternion relative to a rotation, then sends its axis/angle representation to C# in order to operate a 3D rotation of a vector. I need this to be done outside Android (in my C# application), but for testing I'm doing it on both Android and C# to be sur...
magicleon94
1

votes
0

answer
118

Views

Shape interpolation with quaternios using Eigen in C++/OpenGL

I am trying to implement shape interpolation between two triangles using quaternions as discussed in the 2000 paper As-rigid-as-possible shape interpolation by Alexa, Cohen-Or, and Levin. Let's say Triangle 1 has points A, B, C, and Triangle 2 has points M, N, O. The two corresponding matrices (T1 a...
Toj19
1

votes
0

answer
99

Views

OpenGL Applying A Global Rotation to Local Euler Angles

I am working on an Android application using OpenGL. In a database, I store the rotation of objects using local Euler rotation, x, y, then z, but in the editor, I would like to apply a global rotation by the x, y or z global axis. I took two approaches, outlined below. I've simplified these methods...
DiDoubleTwice
1

votes
1

answer
69

Views

Unity Rotate Player while in free fall Not Working

I have a player that launches off a ramp. Everything works fine until that point. When the player is off the ramp they are looking a little upwards so what I am trying to do is smoothly change the player (X, Y, Z) rotation; from the current one to a new one. I always need y = -180 I always need z...
shane
1

votes
0

answer
57

Views

How to increase fbx size while applying Quaternion in ThreeJs

I'm trying to load an object using fbx loader and apply quaternion to rotate in an orbit. Rotation is working but object looks far away on the screen. Here is the code that i'm trying. fbxLoader.load('models/fbx/yarn_with_mtl.fbx', function (yarn) { yarn.traverse(function(child) { if (child inst...
Kiran Bs
1

votes
0

answer
179

Views

Calculating orientation from 6-axis IMU without Magnetometer

Is it possible to perform quaternion/Euler angle calculations from only accelerometer and gyroscope readings? I’d like to be able to detect orientation for a small pcb that I have which I designed and built with InvenSense ICM-20689 (SPI version of the popular MPU-6050/6000) but without a magneto...
Kevin King
1

votes
0

answer
46

Views

Unity3D manipulate object orientation with respect to original orientation

I encountered another issue with hand-object interaction using a Leap Motion device. In particular, I use the LM to perform orientation manipulations on virtual objects. I want to use the difference between the current and last orientation of the hand to manipulate the object: Quaternion relativeOr...
R.Devel
1

votes
0

answer
28

Views

Converting CoreMotion Portrait Angles to Landscape Right and Landscape Left in Objective-C iOS

I am trying to get CoreMotion to behave correctly when the user's device is in Landscape Mode. The below code is working for Portrait mode but I can't figure out how to convert it to Landscape Left and Landscape Right. If you are familiar with Quaternions and CoreMotion, any help would be hugely app...
Ian Annase
1

votes
0

answer
149

Views

Unity: Applying MoveRotation to an object with an offset

In a Unity VR app I'm building, I'm trying to rotate an object that is currently 'being held'. The technique I'm using is to find the desired rotation and feed it into the target objects Rigidbody via Rigidbody.MoveRotation. This works well when I use a test quaternion exposed in the inspector, but...
1

votes
0

answer
145

Views

Using Input.Gyro to get the amount of “tilt” from an origin rotation

In my scenario, I have a table (plane) that a ball will roll around on using nothing but physics giving the illusion that the mobile device is the table using Input.gyro.attitude. Taking it one step further, I would like this relative to the device origin at the time Start() is called, so if it is...
Karl
1

votes
1

answer
49

Views

Align rotation of plane to rotation of other object

Right now I am working on knife fighting and I've stumbled upon a small problem. I am creating a decal on a surface being hit by the knife and I want to rotate said decal to match the rotation of the knife during the hit. To do that I am using this code: 'transform' is referring to knife's transform...
Fiffe
1

votes
1

answer
147

Views

Does the quaternion that Eigen extracts from an Affine3d 3x3 rotation matrix is normalized?

here https://docs.ros.org/kinetic/api/eigen_conversions/html/eigen__msg_8cpp_source.html#l00093 I quite do not understand the syntax of this line : Eigen::Quaterniond q = (Eigen::Quaterniond)e.linear(); But anyway, assuming e is of type Eigen::Affine3d (3x3 rotation matrix), where can I figure out h...
tehdodk
1

votes
0

answer
35

Views

iOS CoreMotion Attitude Relative to iPhone Coordinate System

I have researched this topic extensively, here on stack and all over the internet, and I can't seem to come across a solution. A lot of people on stack have asked similar questions, and people have provided responses but I don't think anyone has provided a good solution yet. Problem: When using Cor...
Chris S
1

votes
0

answer
38

Views

3D Rigging: Belt twist or Frame Interpolation beyond 180 degrees. Euler, Matrix, Quaternions?

3D TD here, defining a 'Bezier curve' and orientation along it with Control Objects' transforms. I'm having issues to interpolate the 'Up Vector' between the Control Objects, in a way that would allow me to have a differential of more than 180 degrees between control, so I'm limited in how much I c...
probineroutlook
1

votes
0

answer
40

Views

Controlling a virtual character's joints rotation with OpenNI + Kinect

I'm starting a project where I need to control a virtual character. The character is being rendered in multiple 3D engines, such as Three.JS and iOS SceneKit. I'm getting the Quaternions of every joint of the skeleton with OpenNI, and it looks kind of like this: The code that saves and pass the quat...
Carlos C
1

votes
1

answer
115

Views

Combine more than 3 rotations (Quaternions)

I have a 3D point and the x,y,z rotations (qInitial) for that point. I want to rotate that point more (by some degrees that could be 0 up to 360) around y axis (qYextra). How can I calculate the final Euler rotation (qResult.eulerAngles) that is a combination of these 4 rotations (x-y-z-y)? I have t...
tsynn
1

votes
0

answer
42

Views

Convert left-handed Y-up (e.g. Unity) coordinates&rotations to right-handed Z-up (3DS Max)

We develop an application that uses models exported as an fbx from max in unity (seems to work), changes them and then communicates the changes back to 3DSMax for a clean render. We rotate the model pivot in max in such a way in max that it is shown correctly in Unity after the export. What we got s...
Exatex
1

votes
1

answer
29

Views

Rotation - Yaw Roll Pitch

I am trying to rotate a object based on the sensor values (pitch roll yaw). I have the following script snippet of code to rotate the object. if ((0
Rishi
1

votes
1

answer
389

Views

How can i get a quaternion through my 1 axis gyroscope?

My problem is, i have a 1 axis gyroscope and a 3 axis acellerometer in my device. I managed to get the quaternion through the accelerometer but i cant figure out how to do it with the gyroscope. I want to be able to, through my gyroscope ( angular rate information) get a quaternion out of it.
Mathis Vic
1

votes
1

answer
160

Views

Compare Quaternion to axis

I have the orientation of an object stored as a unit quaternion, and I want to see what angle the object's local x axis makes with the global y axis. What's the easiest way to do that? Thanks!
Ben Jones
1

votes
1

answer
796

Views

How do you set an objects Orientation to another objects in Ogre3D?

I tried do do this: Ogre::Vector3 src = bone1->_getDerivedOrientation() * Ogre::Vector3::UNIT_X; Ogre::Quaternion quatt = src.getRotationTo(bone2->_getDerivedOrientation() * Ogre::Vector3::UNIT_X); bone1->rotate(quatt); src = bone1->_getDerivedOrientation() * Ogre::Vector3::UNIT_Y; quatt = src.getR...
Pete L
1

votes
1

answer
20

Views

How can I mirror (and rotate) an object through a line as were it a portal?

I want to create a 2D portal effect. Thus, the object exiting the exit portal should correspond in location/rotation with the object going through the entry portal. This until half of the original object is through the portal. I have made a sprite cube that should be mirrored over a line (the portal...
Emphy
1

votes
1

answer
1.6k

Views

Using Quaternion to represent gyroscope angle in C#

I'm using the WiiM+ gyro to calculate rotation. I integrate the rates of turn along the yaw, pitch and roll axes and store it in a vector called angleSum So for each reading, angleSum(reading) represents the y, p and r rotations from the initial orientation. I then use quaternions (which I'm total...
Imelza
1

votes
1

answer
1.3k

Views

SLERP & skeletal animation interpolation help!

I had skeletal animation in my program working fine, but I was interpolating between the 4x4 matrices stored for each bone between frames in a linear way, i.e. bMatrix bMathbMathInterpolate(bMatrix const * const p_a,bMatrix const * const p_b, float p_delta) { bMatrix l_mat; for(unsigned char i = 0;i...
Bevan
1

votes
1

answer
446

Views

quaternions for Opengl ES

I am working with Opengl es to create a stickman and this might seem like a stupid question but when using quaternions to represent rotation what should I do if want the rotation to be around another point than the origin and should I use a unit quaternion or not. my guess is I can rotate and then t...
Steve
1

votes
1

answer
420

Views

Rotation with Quaternion not quite right

Following on from my previous question, I have now managed to rotate my object with quaternions but there is still a small problem and I dont know how to solve it. With the code below my object rotates round the x and y axis. But it always jumps back to the initial position when I switch between x-...
buddy
1

votes
1

answer
4.5k

Views

How to get projected angle from quaternion on a certain axis?

I am using quaternions in my game to calculate some basic angles. Now I am trying to get the angle of a quaternion, given a certain axis. So, given a quaternion and a new axis. Can I get the projected angle back? To me, it seems like a solid way to calculate the signed angle between two vectors. The...
Marnix
1

votes
2

answer
3.2k

Views

Orbit camera around sphere while looking at the center (using quaternions)

I have looked at a ton of quaternion examples on several sites including this one, but found none that answer this, so here goes... I want to orbit my camera around a large sphere, and have the camera always point at the center of the sphere. To make things easy, the sphere is located at {0,0,0} in...
jessejuicer
1

votes
1

answer
345

Views

XNA / C# - Making the Z component of a Quaternion a fixed angle value? Or is there another way?

I've spent about maybe 3 hours trying to get this to work... In my developing 3D game, I already have a camera and a world matrix space. What I want to do is to make it so when you turn the camera left or right, the camera also tilts/banks left or right. However, all the methods I have tried (Slerp,...
Jared
1

votes
1

answer
1.6k

Views

java 3D rotation with quaternions

I have this method for rotating points in 3D using quaternions, but it seems not to work properly: public static ArrayList rotation3D(ArrayList points, double angle, int xi, int yi, int zi) { ArrayList newPoints = new ArrayList(); for (int i=0;i
MRM
1

votes
2

answer
2.2k

Views

How to obtain axis-angle from rotation matrix?

I need to obtain some data from an openGL rotation matrix. I need to obtain the equivalent euler angles (already did it), the equivalent quaternion (did it, but just copying it from the Internet) and the equivalent axis-angle. I dont know if a rotation matrix can be expresed as a single rotation of...
Alex
1

votes
1

answer
825

Views

quaternion inverts vector

I'm using glm::quaternions to rotate a vector around a certain axis. But the vector inverts the axis everytime it is called. Here is my code to rotate my object around the side axis: void PlayerController::rotateForward(float angle) { angle = (angle*M_PI) / 180.0f; fquat rot = fquat(angle, playerObj...
minime
1

votes
1

answer
717

Views

How to calculate the quaternion that represents a triangle's 3D rotation?

Or to look at it another way, let's say we have 2 same size triangles located and orientated at different parts of 3D space. How do you calculate the quaternion that describes the rotation such that applying the quaternion to triangle A would have it sit at triangle B? It is difficult to see how fin...
ste3e

View additional questions