|
KiCad PCB EDA Suite
|
#include "3d_math.h"#include <glm/gtc/matrix_transform.hpp>#include <glm/gtc/quaternion.hpp>#include <cmath>Go to the source code of this file.
Functions | |
| glm::mat4 | CalcModelMatrix (const SFVEC3F &aOffset, const SFVEC3F &aRotation, const SFVEC3F &aScale) |
| Build the model-to-footprint transform used by rendering and picking. | |
| SFVEC3F | CalcModelRotation (const glm::mat3 &aRotation) |
| Recover the FP_3DMODEL angles that CalcModelMatrix() would turn into aRotation. | |
| SFVEC3F | InterpolateModelRotation (const SFVEC3F &aStart, const SFVEC3F &aEnd, float aT) |
| Interpolate between two model orientations along the shortest arc. | |
| glm::mat4 CalcModelMatrix | ( | const SFVEC3F & | aOffset, |
| const SFVEC3F & | aRotation, | ||
| const SFVEC3F & | aScale ) |
Build the model-to-footprint transform used by rendering and picking.
Offsets are in millimetres, in the footprint's Y-up frame. Scale is applied in the model's original axes, before rotation and translation.
| aOffset | |
| aRotation | raw FP_3DMODEL::m_Rotation in degrees (the negation of the UI angles), applied about X, then Y, then Z before translation. |
| aScale |
Definition at line 34 of file 3d_math.cpp.
Referenced by PANEL_PREVIEW_3D_MODEL::alignmentModelMatrix(), RENDER_3D_OPENGL::get3dModelsFromFootprint(), getModelHeight(), InterpolateModelRotation(), RENDER_3D_RAYTRACE_BASE::load3DModels(), ODB::ModelHeightAboveBoard(), and EDA_3D_CANVAS::PickModel().
| SFVEC3F CalcModelRotation | ( | const glm::mat3 & | aRotation | ) |
Recover the FP_3DMODEL angles that CalcModelMatrix() would turn into aRotation.
| aRotation | an orthonormal rotation matrix. |
Definition at line 47 of file 3d_math.cpp.
References std::abs().
Referenced by InterpolateModelRotation().
Interpolate between two model orientations along the shortest arc.
Both angle triplets are raw FP_3DMODEL::m_Rotation degrees. Interpolating the angles directly would tumble through gimbal lock, so the ends are converted to quaternions and the result is decomposed back.
| aStart | |
| aEnd | |
| aT | the interpolation parameter, clamped to [0, 1]. |
Definition at line 73 of file 3d_math.cpp.
References CalcModelMatrix(), CalcModelRotation(), and end.
Referenced by PANEL_PREVIEW_3D_MODEL::tickAlignmentAnimation().