Discretize a parabola based on (approximate) step size. The approximate_step_size is measured parallel to the source_segment, not along the parabola.
142{
144
145
155
156 assert((as.cast<
int64_t>().dot(
ab.cast<
int64_t>()) /
int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
157 assert((ae.cast<
int64_t>().dot(
ab.cast<
int64_t>()) /
int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
158
161
162 assert((ap.cast<
int64_t>().dot(
ab.cast<
int64_t>()) /
int64_t(ab_size)) <= std::numeric_limits<coord_t>::max());
163
165 Line(a, b).distance_to_infinite_squared(
p, &pxx);
166 const Point ppxx = pxx -
p;
168 const PointMatrix rot = PointMatrix(
perp(ppxx));
169
170 if (d == 0)
171 {
172 discretized.emplace_back(s);
173 discretized.emplace_back(e);
174 return discretized;
175 }
176
177 const float marking_bound =
atan(transitioning_angle * 0.5);
180
181 assert(msx <= std::numeric_limits<coord_t>::max());
182 assert(double(msx) * double(msx) <= double(std::numeric_limits<int64_t>::max()));
183 assert(mex <= std::numeric_limits<coord_t>::max());
184 assert(double(msx) * double(msx) / double(2 * d) + double(d / 2) <= std::numeric_limits<coord_t>::max());
185
186 const coord_t marking_start_end_h = msx * msx / (2 *
d) + d / 2;
187 Point marking_start = rot.unapply(
Point(
coord_t(msx), marking_start_end_h)) + pxx;
189 const int dir = (sx > ex) ? -1 : 1;
190 if (dir < 0)
191 {
192 std::swap(marking_start, marking_end);
193 std::swap(msx, mex);
194 }
195
198
199 const Point apex = rot.unapply(
Point(0, d / 2)) + pxx;
201
202 assert(!(add_marking_start && add_marking_end) || add_apex);
203 if(add_marking_start && add_marking_end && !add_apex)
204 {
205 BOOST_LOG_TRIVIAL(warning) << "Failing to discretize parabola! Must add an apex or one of the endpoints.";
206 }
207
208 const coord_t step_count =
static_cast<coord_t>(
static_cast<float>(std::abs(ex - sx)) / approximate_step_size + 0.5);
209
210 discretized.emplace_back(s);
212 {
213 assert(double(sxex) * double(step) <= double(std::numeric_limits<int64_t>::max()));
215 assert(double(x) * double(x) <= double(std::numeric_limits<int64_t>::max()));
216 assert(double(x) * double(x) / double(2 * d) + double(d / 2) <= double(std::numeric_limits<int64_t>::max()));
218
220 {
221 discretized.emplace_back(marking_start);
222 add_marking_start = false;
223 }
225 {
226 discretized.emplace_back(apex);
227 add_apex = false;
228 }
230 {
231 discretized.emplace_back(marking_end);
232 add_marking_end = false;
233 }
234 assert(x <= std::numeric_limits<coord_t>::max() && x >= std::numeric_limits<coord_t>::lowest());
235 assert(y <= std::numeric_limits<coord_t>::max() && y >= std::numeric_limits<coord_t>::lowest());
236 const Point result = rot.unapply(
Point(x, y)) + pxx;
237 discretized.emplace_back(result);
238 }
239 if (add_apex)
240 {
241 discretized.emplace_back(apex);
242 }
243 if (add_marking_end)
244 {
245 discretized.emplace_back(marking_end);
246 }
247 discretized.emplace_back(e);
248 return discretized;
249}
EIGEN_DEVICE_FUNC const AtanReturnType atan() const
Definition ArrayCwiseUnaryOps.h:248
EIGEN_DEVICE_FUNC SegmentReturnType segment(Index start, Index n)
This is the const version of segment(Index,Index).
Definition BlockMethods.h:888
static Vec2i64 p(const vd_t::vertex_type *node)
Definition VoronoiUtils.cpp:14
int32_t coord_t
Definition libslic3r.h:39
const Scalar & y
Definition MathFunctions.h:552
Eigen::Matrix< typename Derived::Scalar, 2, 1, Eigen::DontAlign > perp(const Eigen::MatrixBase< Derived > &v)
Definition Point.hpp:104
T dot(const boost::geometry::model::d2::point_xy< T > &v1, const boost::geometry::model::d2::point_xy< T > &v2)
Definition ExtrusionSimulator.cpp:143
std::vector< Point, PointsAllocator< Point > > Points
Definition Point.hpp:58
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297
Coord step(const Coord &crd, Dir d)
Definition MarchingSquares.hpp:137
Kernel::Point_2 Point
Definition point_areas.cpp:20
__int64 int64_t
Definition unistd.h:76