rotational-matrices

GLM: rotation matrix initialisation

喜夏-厌秋 提交于 2020-01-07 09:26:17
问题 The basic aim of my code is just to rotate a few points around the z-axis. However, after trying to initialise a rotation matrix using glm::rotate(m4, a, v3) and trying to check its components, a quick printf outputs some 1 800 000 000.0000000... for each element. I believe this is not the correct functionality.~ Note: I am not asking about the maths behind spatial transformations. They are clear to me. Code in essence: int main(int argc, char **argv){ InitGL(); // openGL, GLFW..

GLM: rotation matrix initialisation

左心房为你撑大大i 提交于 2020-01-07 09:26:07
问题 The basic aim of my code is just to rotate a few points around the z-axis. However, after trying to initialise a rotation matrix using glm::rotate(m4, a, v3) and trying to check its components, a quick printf outputs some 1 800 000 000.0000000... for each element. I believe this is not the correct functionality.~ Note: I am not asking about the maths behind spatial transformations. They are clear to me. Code in essence: int main(int argc, char **argv){ InitGL(); // openGL, GLFW..

Android Convert device coordinate system to “user” coordinate system

痴心易碎 提交于 2020-01-03 12:26:29
问题 My question is similar to Changing sensor coordinate system in android I want to be able to compare a user's movements with each other regardless of device orientation. So that when the users holds out the phone in portrait orientation and bends his arm, acceleration readings are the same as when he holds out his phone in landscape and then bends his arm in the same direction. This is what I call the "user" coordinate system. It is different from the world coordinate system since it should

Why are quaternions used for rotations?

若如初见. 提交于 2019-12-29 02:17:33
问题 I'm a physicist, and have been learning some programming, and have come across a lot of people using quaternions for rotations instead of writing things in matrix/vector form. In physics, there are very good reasons we don't use quaternions (despite the bizarre story that's occasionally told about Hamilton/Gibbs/etc). Physics requires that our descriptions have good analytic behavior (this has a precisely defined meaning, but in some rather technical ways that go far beyond what's taught in

Calculating a rotation matrix using rotate in Matlab

流过昼夜 提交于 2019-12-25 06:37:20
问题 I'm using Matlab 2013a on Windows 7 Pro 64 bit. In 2010 (using a different version of Matlab), I wrote the following code to calculate a 3x3 rotation matrix C=rotate (omega, i, w); R=C*Ro; where omega, i, and w are rotation angles in radians. On my current system, giving the example input of omega = i = w = 0, C will be a 3x3 identity matrix. If I copy the code into another directory that I wrote in the past few months, the same code will result in the following error. Error using rotate Too

Applying a rotation matrix on a point with an origin fails

五迷三道 提交于 2019-12-24 21:38:35
问题 From this answer; https://stackoverflow.com/a/34060479/1493455 I have made some code that should rotate a point around an origin point. The origin is at 0,0,0. Instead of my rotations being yaw pitch roll , I have xrot yrot and zrot which are degrees (0-360). A rotation around the X axis results in the object pitching back and forth, a rotation around the Z axis results in it rotating as if it was the yaw of the object. I think I messed up somewhere in translating the values, but I can't seem

Imprecision with rotation matrix to align a vector to an axis

限于喜欢 提交于 2019-12-24 10:57:49
问题 I've been banging my head against the wall with this for several hours and I can't seem to figure out what I'm doing wrong. I'm trying to generate a rotation matrix which will align a vector with a particular axis (I'll ultimately be transforming more data, so having the rotation matrix is important). I feel like my method is right, and if I test it on a variety of vectors, it works pretty well , but the transformed vectors are always a little off . Here's a full code sample I'm using to test

Rotation and direction of a vector in 3D space - Inverse Order

徘徊边缘 提交于 2019-12-24 10:47:42
问题 I have two vectors in 3D-space, S (Start) and T (Target), and I want to find the Rotation Matrix (RM) that allows such transformation. I know that by computing the cross product S × T I get the rotation axis. The angle between S and T is given by tan⁻¹(||S × T||, S·T) , where S·T is the dot product between S and T. This gives me the rotation vector rotvec = [S x T; angle] (the cross product is normalized). Then by using function vrrotvec2mat (in MATLAB) or transforms3d.axangles.axangle2mat

How do I rotate a 3D matrix by 90 degrees counterclockwise?

感情迁移 提交于 2019-12-23 22:10:11
问题 I'm trying to rotate a matrix counterclockwise by 90 degrees in Java. I found answers on how to do this with a 2D matrix, but my matrix is 3D. Here's how I found out on how to do a 2D rotation: static int[][] rotateCW(int[][] mat) { final int M = mat.length; final int N = mat[0].length; int[][] ret = new int[N][M]; for (int r = 0; r < M; r++) { for (int c = 0; c < N; c++) { ret[c][M-1-r] = mat[r][c]; } } return ret; } How would I go about rotating a 3D matrix then? 回答1: By multiplying your

QGraphicsSvgItem positioning after rotation

ぐ巨炮叔叔 提交于 2019-12-23 04:45:25
问题 I encountered a strange issue/feature when I try to rotate a QGraphicsSvgItem object and set a position. Check the following example: I have one .svg for the sake of simplicity that is a blue rectangle. I create two QGraphicsSvgItem using the file and I rotate on of them with 90 degree. I set both of them to the same position, however the rotated one positioned 'wrongly'(maybe that is the correct behaviour). It looks like that the x,y coordinate(top-left corner) is now the top-right corner,