7 : _pointA(point_a), _pointB(point_b), _pointC(point_c) {
11 _pointA(bez._pointA), _pointB(bez._pointB),
12 _pointC(bez._pointC) {
31 if(tx_ > 0. && tx_ < 1.0) {
33 x_.push_back(bez1.x());
34 y_.push_back(bez1.y());
37 if(ty_ > 0. && ty_ < 1.0) {
39 x_.push_back(bez2.x());
40 y_.push_back(bez2.y());
43 std::sort(x_.begin(), x_.end());
44 std::sort(y_.begin(), y_.end());
59 auto min_distance = std::numeric_limits<double>::max();
64 for (
auto val : tValues) {
66 auto raw_distance = coord.
distanceTo(point_on_path);
67 if(raw_distance < min_distance) {
69 min_distance = raw_distance;
77 auto min_distance = std::numeric_limits<double>::max();
83 for (
auto val : tValues) {
84 if(val > 0 && val < 1) {
86 auto raw_distance = coord.
distanceTo(point_on_path);
87 if(raw_distance < min_distance) {
89 min_distance = raw_distance;
110 auto a = Bx * Bx + By * By;
111 auto b = (3 * (Ax * Bx + Ay * By)) / a;
112 auto c = (2 * (Ax * Ax + Ay * Ay) + pos.x() * Bx + pos.y() * By) / a;
113 auto d = (pos.x() * Ax + pos.y() * Ay) / a;
134 if(min_distance < distance_to_A && min_distance < distance_to_C) {
138 if (distance_to_A < distance_to_C) {
146 if(points.size() == 1)
return points.front();
148 int size_ = points.size();
149 std::vector<Coordinate> new_vec;
150 for(
int i = 1; i < size_; i++) {
151 new_vec.push_back(points[i-1] * (1.0-t) + points[i] * t);
158 auto one_minus_t = 1 - t;
160 auto one_minus_t_square = one_minus_t * one_minus_t;
161 auto two_a_b = 2 * one_minus_t * t;
167 std::vector<Coordinate> ret;
168 for(
auto i = 0.; i < 1.; i+=precession) {
181 auto A = 4*(Ax*Ax + Ay*Ay);
182 auto B = 4*(Ax*Bx + Ay*By);
183 auto C = Bx*Bx + By*By;
185 auto Sabc = 2*std::sqrt(A+B+C);
186 auto A_2 = std::sqrt(A);
188 auto C_2 = 2*std::sqrt(C);
191 return ( A_32 * Sabc + A_2 * B * (Sabc - C_2) + (4 * C * A - B * B) * std::log((2* A_2 + BA + Sabc)/(BA + C_2))) / (4 * A_32);
195 auto z = std::make_shared<const Bezier>(
_pointA.
rotate(center, angle),
202 auto z = std::make_shared<const Bezier>(
_pointA.
scale(center, factor),
222 auto tanx = Ax * t + Bx;
223 auto tany = Ay * t + By;
233 auto tanx = Ay * t + By;
234 auto tany = -(Ax * t + Bx);
236 auto lNorm = std::sqrt(tanx * tanx + tany * tany);
247 auto z = std::make_shared<const Bezier>(
_pointA.
mirror(axis1, axis2),
257 auto D = (AB + BC)/2;
294 auto x12 = (x2-x1)*t+x1;
295 auto y12 = (y2-y1)*t+y1;
297 auto x23 = (x3-x2)*t+x2;
298 auto y23 = (y3-y2)*t+y2;
300 auto x123 = (x23-x12)*t+x12;
301 auto y123 = (y23-y12)*t+y12;
303 return std::make_shared<Bezier>(
Bezier({x1, y1}, {x12, y12}, {x123, y123}));
Coordinate mirror(const Coordinate &axis1, const Coordinate &axis2) const
mirror a coordinate
static std::vector< double > cubicSolver(const std::vector< double > &ce)
virtual std::vector< BB_CSPtr > splitHalf() const override
splitHalf Splits the bezier into two halves.
virtual const Coordinate tangent(double t) const override
tangent of the bezeir
double x() const
Returns x of Coordinate.
virtual const std::vector< Coordinate > getCP() const override
getCP Returns the control points of the bezier
virtual Coordinate DirectValueAt(double t) const override
DirectValueAt Coordinate of bezier at time t calculated numerically.
std::vector< double > nearestPointTValue(const Coordinate &coord) const override
Bezier::nearestPointTValue.
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 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.
virtual BB_CSPtr rotate(const geo::Coordinate ¢er, double angle) const override
rotate the bezier at specific center and some angle
const lc::geo::Coordinate returnCasesForNearestPoint(double min_distance, const lc::geo::Coordinate &coord, const Coordinate &ret) const override
Bezier::returnCasesForNearestPoint.
Coordinate rotate(const Coordinate &angleVector) const
rotate around (0.,0.) with a given angle vector
std::shared_ptr< const BezierBase > BB_CSPtr
virtual BB_CSPtr move(const geo::Coordinate &offset) const override
move the bezeir by some offset
virtual const Coordinate normal(double t) const override
normal of the bezier at time t
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
double distanceTo(const geo::Coordinate &c) const
virtual BB_CSPtr splitAtT(double t) const override
splitAtT Splits bezier at specific time.
virtual const std::vector< Coordinate > Curve(double precession) override
Curve Creates a bezier curve for drawing with some precession value.
virtual BB_CSPtr offset(const geo::Coordinate &offset) const override
offset offsets the bezier.
Bezier(const Coordinate &point_a, const Coordinate &point_b, const Coordinate &point_c)
virtual const Area boundingBox() const override
boundingBox of the bezier
virtual const double length() const override
length of the Bezier