opengl – GLM conversion from Euler angles to Quaternion and back does not apply

I am trying to convert the orientation of an OpenVR controller that I saved as glm::vec3 of Euler angles in a glm::fquat and back, but I get wildly different results and the behavior in the game is just wrong (difficult to explain, but the object's orientation behaves normally for a small angular range and then rotates in strange axes),

This is my conversion code:

// get `orientation` from OpenVR controller sensor data

const glm::vec3 eulerAnglesInDegrees{orientation(PITCH), orientation(YAW), orientation(ROLL)};
debugPrint(eulerAnglesInDegrees);

const glm::fquat quaternion{glm::radians(eulerAnglesInDegrees)};
const glm::vec3 result{glm::degrees(glm::eulerAngles(quaternion))};
debugPrint(result);

// `result` should represent the same orientation as `eulerAnglesInDegrees`

I would expect eulerAnglesInDegrees and result to be either the same or equivalent representations of the same orientation, but apparently that is not the case. Here are some example values ​​that I have printed out:

39.3851 5.17816 3.29104 
39.3851 5.17816 3.29104 

32.7636 144.849 44.3845 
-147.236 35.1512 -135.616 

39.3851 5.17816 3.29104 
39.3851 5.17816 3.29104 

32.0103 137.415 45.1592 
-147.99 42.5846 -134.841 

As you can see above, the conversion is correct for some orientation areas, but completely different for others.

What am I doing wrong?

I've looked at existing questions and tried a few things, including trying out every possible rotation order listed here, conjugating the quaternion, and other random things like flipping pitch / yaw / roll. Nothing gave me the expected result.

How can I convert Euler angles to quaternions and back that represent the original orientation? glm?


Some more examples of discrepancies:

original:      4; 175;   26; 
computed:   -175;   4; -153; 
difference:  179; 171;  179; 

original:     -6; 173;   32; 
computed:    173;   6; -147; 
difference: -179; 167;  179; 

original:      9; 268;  -46; 
computed:   -170; -88;  133; 
difference:  179; 356; -179; 

original:    -27; -73;  266; 
computed:    -27; -73;  -93; 
difference:    0;   0;  359; 

original:    -33; 111;  205; 
computed:    146;  68;   25; 
difference: -179;  43;  180; 

I tried to find a pattern to fix the finale computed Results, but it doesn't appear that there is one that is easy to identify.


GIF + video of behavior:

video excerpt


Visual representation of my intuition / my current understanding:

Visual diagram

  • The picture above shows a ball and I am in the middle. If I aim the weapon at the green half of the bullet, the alignment is correct. If I aim the gun at the red half of the bullet, that's wrong – it seems like each axis is inverted, but I'm not 100% sure that it is.

c ++ – GLM conversion of Euler angles to Quaternion and back does not apply

I am trying to convert the orientation of an OpenVR controller that I saved as glm::vec3 of Euler angles in a glm::fquat and back, but I get wildly different results and the behavior in the game is just wrong (difficult to explain, but the object's orientation behaves normally for a small angular range and then rotates in strange axes),

This is my conversion code:

const glm::vec3 eulerAnglesInDegrees{orientation(PITCH), orientation(YAW), orientation(ROLL)};
debugPrint(eulerAnglesInDegrees);

const glm::fquat quaternion{glm::radians(eulerAnglesInDegrees)};
debugPrint(result);

I would expect eulerAnglesInDegrees and result to be either the same or equivalent representations of the same orientation, but apparently that is not the case. Here are some example values ​​that I have printed out:

39.3851 5.17816 3.29104 
39.3851 5.17816 3.29104 

32.7636 144.849 44.3845 
-147.236 35.1512 -135.616 

39.3851 5.17816 3.29104 
39.3851 5.17816 3.29104 

32.0103 137.415 45.1592 
-147.99 42.5846 -134.841 

As you can see above, the conversion is correct for some orientation areas, but completely different for others.

What am I doing wrong?

I've looked at existing questions and tried a few things, including trying out every possible rotation order listed here, conjugating the quaternion, and other random things like flipping pitch / yaw / roll. Nothing gave me the expected result.

How can I convert Euler angles to quaternions and back that represent the original orientation? glm?

c ++ – conversion from the element pointer to the entire structure / class

Consider the following code:

#include 


struct bar {
  double a = 1.0;
  int b = 2;
  float c = 3.0;
};

void callbackFunction(int* i) {

  auto myStruct = reinterpret_cast(i) - offsetof(bar, b);

  std::cout << myStruct->a << std::endl;
  std::cout << myStruct->b << std::endl;
  std::cout << myStruct->c << std::endl;

  //do stuff
}

int main() {

  bar foo;

  callbackFunction(&foo.b);

  return 0;
}

I need to define a callback function and would like to use some additional information in this function. I have defined my own structure and passed a member's address to the function. In function, I want to "get" the whole structure through casting, but the pointers don't seem to match and I get wrong results. I think I'm doing something wrong when casting, but I'm not sure what?

wp remote post – conversion of the code wp_remote_post

I'm trying to convert this PHP code to WordPress format wp_remote_post ().
Thoughts, ideas, that's NOT my strong point, lol.

setUrl('https://xxxx.yyyyy.zzzzz');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
  'follow_redirects' => TRUE
));
$request->setHeader(array(
  'x-api-key' => 'ppppppppppppppp',
  'Content-Type' => 'application/json'
));
$request->setBody('{n    "object_type": "Leaderboard",n    "action": "list",n    "pagination": {n       "limit": 5,n       "order": falsen    },n    "data": {n        "username": "me@mysite.me"n    }n}');
try {
  $response = $request->send();
  if ($response->getStatus() == 200) {
    echo $response->getBody();
  }
  else {
    echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
    $response->getReasonPhrase();
  }
}
catch(HTTP_Request2_Exception $e) {
  echo 'Error: ' . $e->getMessage();
}

Conversion from Maxima (Mathematica) to Python

Did you know which script (program) converts the code from? maxima (mathematical formula processing software) python? does maxima have the ability to convert Fortran?
Since the formula processing software is a simple input for fractions, I use it a lot, but when I try to convert those fractions to manually python With slashes, it is withered (for me).

The Google Finance feature returns the date, not the currency conversion

I am trying to calculate the USD: AUD conversion from M3 and display the result of the current exchange rate in the next cell, but only the date is resolved

I am trying to convert cell M3 to cell N3 in AUD

=M2*GOOGLEFINANCE("CURRENCY:USDAUD") 

This formula worked in the cell above and converted the "live" rate, but if I change it for other cells, it will return a random date like 01/27/1900.

I have another part of the table that converts the currency on a specific date. However, this must be up-to-date and updated with the live prices with every check.

can someone help?