|
KiCad PCB EDA Suite
|
Defines math related functions. More...
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. | |
| SFVEC3F | SphericalToCartesian (float aInclination, float aAzimuth) |
| https://en.wikipedia.org/wiki/Spherical_coordinate_system | |
| SFVEC3F | UniformRandomHemisphereDirection () |
| SFVEC3F | CosWeightedRandomHemisphereDirection (const SFVEC3F &n) |
| bool | Refract (const SFVEC3F &aInVector, const SFVEC3F &aNormal, float aRin_over_Rout, SFVEC3F &aOutVector) |
| Based on: https://github.com/mmp/pbrt-v3/blob/master/src/core/reflection.h See also: http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_3_Refractions_and_Beers_Law.shtml. | |
| float | mapf (float x, float in_min, float in_max, float out_min, float out_max) |
| float | RGBtoGray (const SFVEC3F &aColor) |
| SFVEC3F | MaterialDiffuseToColorCAD (const SFVEC3F &aDiffuseColor) |
| float | QuadricEasingInOut (float t) |
| float | BezierBlend (float t) |
Defines math related functions.
Definition in file 3d_math.h.
|
inline |
Definition at line 210 of file 3d_math.h.
Referenced by TRACK_BALL::Interpolate().
| 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().
|
inline |
Definition at line 164 of file 3d_math.h.
Referenced by RENDER_3D_OPENGL::setupMaterials().
Definition at line 178 of file 3d_math.h.
References RGBtoGray().
Referenced by RENDER_3D_RAYTRACE_BASE::addModels(), MODEL_3D::Draw(), and MODEL_3D::MODEL_3D().
|
inline |
Definition at line 194 of file 3d_math.h.
Referenced by TRACK_BALL::Interpolate().
|
inline |
Based on: https://github.com/mmp/pbrt-v3/blob/master/src/core/reflection.h See also: http://www.flipcode.com/archives/Raytracing_Topics_Techniques-Part_3_Refractions_and_Beers_Law.shtml.
| aInVector | incoming vector. |
| aNormal | normal in the intersection point. |
| aRin_over_Rout | incoming refraction index / out refraction index. |
| aOutVector | the refracted vector. |
Definition at line 143 of file 3d_math.h.
Referenced by RENDER_3D_RAYTRACE_BASE::shadeHit().
|
inline |
Definition at line 171 of file 3d_math.h.
Referenced by RENDER_3D_RAYTRACE_BASE::getModelMaterial(), and MaterialDiffuseToColorCAD().
|
inline |
https://en.wikipedia.org/wiki/Spherical_coordinate_system
| aInclination | θ ∈ [0, π] |
| aAzimuth | φ ∈ [0, 2π] |
Definition at line 74 of file 3d_math.h.
Referenced by init_lights(), and RENDER_3D_RAYTRACE_BASE::Reload().
|
inline |
Definition at line 86 of file 3d_math.h.
References Fast_RandFloat().
Referenced by RENDER_3D_RAYTRACE_BASE::shadeHit().