diff --git a/GeoLib/AnalyticalGeometry.cpp b/GeoLib/AnalyticalGeometry.cpp index d9ac7a6dc07710c1e49d98d999c00cbd24e6c7b2..024e15ba8229b11560ce5bda2268f0a49e7021c0 100644 --- a/GeoLib/AnalyticalGeometry.cpp +++ b/GeoLib/AnalyticalGeometry.cpp @@ -152,10 +152,10 @@ bool lineSegmentIntersect(GeoLib::LineSegment const& s0, return false; } - auto const a = s0.getBeginPoint().asEigenVector3d(); - auto const b = s0.getEndPoint().asEigenVector3d(); - auto const c = s1.getBeginPoint().asEigenVector3d(); - auto const d = s1.getEndPoint().asEigenVector3d(); + auto const& a = s0.getBeginPoint().asEigenVector3d(); + auto const& b = s0.getEndPoint().asEigenVector3d(); + auto const& c = s1.getBeginPoint().asEigenVector3d(); + auto const& d = s1.getEndPoint().asEigenVector3d(); Eigen::Vector3d const v = b - a; Eigen::Vector3d const w = d - c; @@ -369,16 +369,10 @@ std::unique_ptr<GeoLib::Point> triangleLineIntersection( MathLib::Point3d const& c, MathLib::Point3d const& p, MathLib::Point3d const& q) { - auto const va = a.asEigenVector3d(); - auto const vb = b.asEigenVector3d(); - auto const vc = c.asEigenVector3d(); - auto const vp = p.asEigenVector3d(); - auto const vq = q.asEigenVector3d(); - - Eigen::Vector3d const pq = vq - vp; - Eigen::Vector3d const pa = va - vp; - Eigen::Vector3d const pb = vb - vp; - Eigen::Vector3d const pc = vc - vp; + Eigen::Vector3d const pq = q.asEigenVector3d() - p.asEigenVector3d(); + Eigen::Vector3d const pa = a.asEigenVector3d() - p.asEigenVector3d(); + Eigen::Vector3d const pb = b.asEigenVector3d() - p.asEigenVector3d(); + Eigen::Vector3d const pc = c.asEigenVector3d() - p.asEigenVector3d(); double u = pq.cross(pc).dot(pb); if (u < 0) diff --git a/GeoLib/MinimalBoundingSphere.cpp b/GeoLib/MinimalBoundingSphere.cpp index 9f55e3628e89810f0fa0fdada27f06f104bac580..3195f3c24235f1493276df010ed8e2a00cdc3e2c 100644 --- a/GeoLib/MinimalBoundingSphere.cpp +++ b/GeoLib/MinimalBoundingSphere.cpp @@ -34,13 +34,11 @@ MinimalBoundingSphere::MinimalBoundingSphere(MathLib::Point3d const& p, MathLib::Point3d const& q) : _radius(std::numeric_limits<double>::epsilon()), _center(p) { - auto const& vp = p.asEigenVector3d(); - auto const& vq = q.asEigenVector3d(); - Eigen::Vector3d const a = vq - vp; + Eigen::Vector3d const a = q.asEigenVector3d() - p.asEigenVector3d(); Eigen::Vector3d o = a / 2; _radius = o.norm() + std::numeric_limits<double>::epsilon(); - o += vp; + o += p.asEigenVector3d(); _center = MathLib::Point3d{{o[0], o[1], o[2]}}; } @@ -49,10 +47,8 @@ MinimalBoundingSphere::MinimalBoundingSphere(MathLib::Point3d const& p, MathLib::Point3d const& r) { auto const& vp = p.asEigenVector3d(); - auto const& vq = q.asEigenVector3d(); - auto const& vr = r.asEigenVector3d(); - Eigen::Vector3d const a = vr - vp; - Eigen::Vector3d const b = vq - vp; + Eigen::Vector3d const a = r.asEigenVector3d() - vp; + Eigen::Vector3d const b = q.asEigenVector3d() - vp; Eigen::Vector3d const axb = a.cross(b); if (axb.squaredNorm() > 0) @@ -85,11 +81,9 @@ MinimalBoundingSphere::MinimalBoundingSphere(MathLib::Point3d const& p, MathLib::Point3d const& r, MathLib::Point3d const& s) { - auto const& vp = p.asEigenVector3d(); - - Eigen::Vector3d const va = q.asEigenVector3d() - vp; - Eigen::Vector3d const vb = r.asEigenVector3d() - vp; - Eigen::Vector3d const vc = s.asEigenVector3d() - vp; + Eigen::Vector3d const va = q.asEigenVector3d() - p.asEigenVector3d(); + Eigen::Vector3d const vb = r.asEigenVector3d() - p.asEigenVector3d(); + Eigen::Vector3d const vc = s.asEigenVector3d() - p.asEigenVector3d(); if (!MathLib::isCoplanar(p, q, r, s)) { @@ -100,7 +94,7 @@ MinimalBoundingSphere::MinimalBoundingSphere(MathLib::Point3d const& p, denom; _radius = o.norm() + std::numeric_limits<double>::epsilon(); - o += vp; + o += p.asEigenVector3d(); _center = MathLib::Point3d({o[0], o[1], o[2]}); } else