Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix errors in rotation function in OSMPDummySensor #95

Merged
merged 4 commits into from
Jun 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Minor clean-up
Signed-off-by: Thomas Sedlmayer <tsedlmayer@pmsfit.de>
thomassedlmayer committed Mar 21, 2023
commit 34aa161d07dc5642629c4b27f116acc8464414c9
18 changes: 6 additions & 12 deletions examples/OSMPDummySensor/OSMPDummySensor.cpp
Original file line number Diff line number Diff line change
@@ -235,17 +235,12 @@ fmi2Status COSMPDummySensor::doExitInitializationMode()

return fmi2OK;
}

void transposeRotationMatrix(double matrix_in[3][3], double matrix_trans[3][3]) {
for(int i=0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
matrix_trans[j][i] = matrix_in[i][j];
}
}
}

/**
* @brief Rotate point with following order of rotation:
* 1. roll (around x-axis) 2. pitch (around y-axis) 3. yaw (around z-axis);
*
* Positive rotation is counter clockwise (right-hand rule).
*/
void rotatePointXYZ(double x, double y, double z,
double yaw, double pitch, double roll,
double &rx, double &ry, double &rz)
@@ -258,7 +253,6 @@ void rotatePointXYZ(double x, double y, double z,
double sin_pitch = sin(pitch);
double sin_roll = sin(roll);

/* order of rotation: roll (x-axis), pitch (y-axis), yaw (z-axis) */
matrix[0][0] = cos_pitch*cos_yaw; matrix[0][1] = -cos_pitch*sin_yaw; matrix[0][2] = sin_pitch;
matrix[1][0] = sin_roll*sin_pitch*cos_yaw + cos_roll*sin_yaw; matrix[1][1] = -sin_roll*sin_pitch*sin_yaw + cos_roll*cos_yaw; matrix[1][2] = -sin_roll*cos_pitch;
matrix[2][0] = -cos_roll*sin_pitch*cos_yaw + sin_roll*sin_yaw; matrix[2][1] = cos_roll*sin_pitch*sin_yaw + sin_roll*cos_yaw; matrix[2][2] = cos_roll*cos_pitch;