Measuring - Gizmo measure - Fixed measurements for circles for scaled volumes
This commit is contained in:
parent
03f2f1478a
commit
a331c9d018
2 changed files with 10 additions and 6 deletions
src
|
@ -93,7 +93,7 @@ protected:
|
|||
std::vector<double> m_coefficient;
|
||||
};
|
||||
|
||||
Polynomial1 operator * (const Polynomial1& p0, const Polynomial1& p1)
|
||||
inline Polynomial1 operator * (const Polynomial1& p0, const Polynomial1& p1)
|
||||
{
|
||||
const uint32_t p0Degree = p0.GetDegree();
|
||||
const uint32_t p1Degree = p1.GetDegree();
|
||||
|
@ -107,7 +107,7 @@ Polynomial1 operator * (const Polynomial1& p0, const Polynomial1& p1)
|
|||
return result;
|
||||
}
|
||||
|
||||
Polynomial1 operator + (const Polynomial1& p0, const Polynomial1& p1)
|
||||
inline Polynomial1 operator + (const Polynomial1& p0, const Polynomial1& p1)
|
||||
{
|
||||
const uint32_t p0Degree = p0.GetDegree();
|
||||
const uint32_t p1Degree = p1.GetDegree();
|
||||
|
@ -136,7 +136,7 @@ Polynomial1 operator + (const Polynomial1& p0, const Polynomial1& p1)
|
|||
}
|
||||
}
|
||||
|
||||
Polynomial1 operator - (const Polynomial1& p0, const Polynomial1& p1)
|
||||
inline Polynomial1 operator - (const Polynomial1& p0, const Polynomial1& p1)
|
||||
{
|
||||
const uint32_t p0Degree = p0.GetDegree();
|
||||
const uint32_t p1Degree = p1.GetDegree();
|
||||
|
@ -165,7 +165,7 @@ Polynomial1 operator - (const Polynomial1& p0, const Polynomial1& p1)
|
|||
}
|
||||
}
|
||||
|
||||
Polynomial1 operator * (double scalar, const Polynomial1& p)
|
||||
inline Polynomial1 operator * (double scalar, const Polynomial1& p)
|
||||
{
|
||||
const uint32_t degree = p.GetDegree();
|
||||
Polynomial1 result(degree);
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
// the maximum absolute component occurs at index i, then the orthogonal
|
||||
// vector U has u[i] = v[i+1], u[i+1] = -v[i], and all other components
|
||||
// zero. The index addition i+1 is computed modulo N.
|
||||
Vec3d get_orthogonal(const Vec3d& v, bool unitLength)
|
||||
inline Vec3d get_orthogonal(const Vec3d& v, bool unitLength)
|
||||
{
|
||||
double cmax = std::fabs(v[0]);
|
||||
int32_t imax = 0;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
#include "libslic3r/Model.hpp"
|
||||
#include "libslic3r/PresetBundle.hpp"
|
||||
#include "libslic3r/MeasureUtils.hpp"
|
||||
|
||||
#include <imgui/imgui_internal.h>
|
||||
|
||||
|
@ -1486,8 +1487,11 @@ void GLGizmoMeasure::on_render_input_window(float x, float y, float bottom_limit
|
|||
case Measure::SurfaceFeatureType::Circle:
|
||||
{
|
||||
auto [center, radius, normal] = m_curr_feature->get_circle();
|
||||
// generic point on circle, used to recalculate radius after transformation
|
||||
const Vec3d on_circle = m_volume_matrix * (center + radius * Measure::get_orthogonal(normal, true));
|
||||
center = m_volume_matrix * center;
|
||||
normal = m_volume_matrix.matrix().block(0, 0, 3, 3).inverse().transpose() * normal;
|
||||
normal = (m_volume_matrix.matrix().block(0, 0, 3, 3).inverse().transpose() * normal).normalized();
|
||||
radius = (on_circle - center).norm();
|
||||
if (use_inches) {
|
||||
center = ObjectManipulation::mm_to_in * center;
|
||||
radius = ObjectManipulation::mm_to_in * radius;
|
||||
|
|
Loading…
Reference in a new issue