7 : _pointA(point_a), _pointB(point_b), _pointC(point_c), _pointD(point_d) {
11 _pointA(bez._pointA), _pointB(bez._pointB),
12 _pointC(bez._pointC), _pointD(bez._pointD) {
21 auto a = v1 - (v2*2) + v3;
32 for(
const double tx_ : x_roots) {
33 if(tx_ > 0. && tx_ < 1.0) {
35 x_.push_back(bez1.x());
36 y_.push_back(bez1.y());
39 for(
const double ty_ : y_roots) {
40 if(ty_ > 0. && ty_ < 1.0) {
42 x_.push_back(bez2.x());
43 y_.push_back(bez2.y());
46 std::sort(x_.begin(), x_.end());
47 std::sort(y_.begin(), y_.end());
62 auto min_distance = std::numeric_limits<double>::max();
67 for (
auto val : tValues) {
69 auto raw_distance = coord.
distanceTo(point_on_path);
70 if(raw_distance < min_distance) {
72 min_distance = raw_distance;
80 auto min_distance = std::numeric_limits<double>::max();
86 for (
auto val : tValues) {
87 if(val > 0 && val < 1) {
89 auto raw_distance = coord.
distanceTo(point_on_path);
90 if(raw_distance < min_distance) {
92 min_distance = raw_distance;
119 std::vector<double> empty(0, 0.);
157 if(points.size() == 1)
return points.front();
159 int size_ = points.size();
160 std::vector<Coordinate> new_vec;
161 for(
int i = 1; i < size_; i++) {
162 new_vec.push_back(points[i-1] * (1.0-t) + points[i] * t);
170 auto t_cube = t_square*t;
171 auto one_minus_t = 1 - t;
172 auto one_minus_square = one_minus_t*one_minus_t;
173 auto one_minus_cube = one_minus_square * one_minus_t;
180 std::vector<Coordinate> ret;
181 for(
auto i = 0.; i < 1.0; i+=precession) {
192 auto z = std::make_shared<const lc::geo::CubicBezier>(
_pointA.
rotate(center, angle),
200 auto z = std::make_shared<const lc::geo::CubicBezier>(
_pointA.
scale(center, factor),
209 auto z = std::make_shared<const lc::geo::CubicBezier>(
_pointA +
offset,
228 auto z = std::make_shared<const lc::geo::CubicBezier>(
_pointA.
mirror(axis1, axis2),
267 auto x12 = (x2-x1)*t+x1;
268 auto y12 = (y2-y1)*t+y1;
270 auto x23 = (x3-x2)*t+x2;
271 auto y23 = (y3-y2)*t+y2;
273 auto x34 = (x4-x3)*t+x3;
274 auto y34 = (y4-y3)*t+y3;
276 auto x123 = (x23-x12)*t+x12;
277 auto y123 = (y23-y12)*t+y12;
279 auto x234 = (x34-x23)*t+x23;
280 auto y234 = (y34-y23)*t+y23;
282 auto x1234 = (x234-x123)*t+x123;
283 auto y1234 = (y234-y123)*t+y123;
285 return std::make_shared<CubicBezier>(
CubicBezier({x1, y1}, {x12, y12}, {x123, y123}, {x1234, y1234}));
Coordinate mirror(const Coordinate &axis1, const Coordinate &axis2) const
mirror a coordinate
virtual BB_CSPtr rotate(const geo::Coordinate ¢er, double angle) const override
rotate the bezier at specific center and some angle
static std::vector< double > quadraticSolver(const std::vector< double > &ce)
quadraticSolver, Quadratic equations solver
virtual BB_CSPtr splitAtT(double t) const override
splitAtT Splits bezier at specific time.
virtual const lc::geo::Coordinate returnCasesForNearestPoint(double min_distance, const lc::geo::Coordinate &coord, const Coordinate &ret) const override
Bezier::returnCasesForNearestPoint.
double x() const
Returns x of Coordinate.
virtual BB_CSPtr scale(const geo::Coordinate ¢er, const geo::Coordinate &factor) const override
scale the bezier at specific center by some factor
double y() const
Returns y of Coordinate.
Coordinate scale(const double &scale_factor) const
virtual const std::vector< Coordinate > Curve(double precession) override
Curve Creates a bezier curve for drawing with some precession value.
virtual BB_CSPtr mirror(const geo::Coordinate &axis1, const geo::Coordinate &axis2) const override
mirror a bezier around a line
virtual Coordinate nearestPointOnEntity(const Coordinate &coord) const override
nearestPointOnEntity of the bezier
virtual std::vector< double > nearestPointTValue(const Coordinate &coord) const override
Bezier::nearestPointTValue.
virtual const std::vector< Coordinate > getCP() const override
getCP Returns the control points of the bezier
Coordinate rotate(const Coordinate &angleVector) const
rotate around (0.,0.) with a given angle vector
virtual BB_CSPtr move(const geo::Coordinate &offset) const override
move the bezeir by some offset
virtual const Coordinate tangent(double t) const override
tangent of the bezeir
std::shared_ptr< const BezierBase > BB_CSPtr
virtual BB_CSPtr offset(const geo::Coordinate &offset) const override
offset offsets the bezier.
virtual Coordinate DirectValueAt(double t) const override
DirectValueAt Coordinate of bezier at time t calculated numerically.
virtual std::vector< BB_CSPtr > splitHalf() const override
splitHalf Splits the bezier into two halves.
virtual Coordinate nearestPointOnPath(const Coordinate &coord) const override
nearestPointOnPath of the bezier
virtual Coordinate CasteljauAt(std::vector< Coordinate > points, double t) const override
CasteljauAt Coordinate of bezier at time t.
double distanceTo(const geo::Coordinate &c) const
CubicBezier(const Coordinate &point_a, const Coordinate &point_b, const Coordinate &point_c, const Coordinate &point_d)
virtual const Coordinate normal(double t) const override
normal of the bezier at time t
virtual const double length() const override
length of the Bezier
virtual const Area boundingBox() const override
boundingBox of the bezier