common: fix arg name

For Bezier curves, we typically use 't' as a parameter
within the 0-1 range, while 'at' is used for the parameter
scaled by the curve's length. In one of the functions,
an incorrect name was used, which could be confusing.
No logical changes.
This commit is contained in:
Mira Grudzinska 2024-08-08 12:23:35 +02:00 committed by Hermet Park
parent 4b73a074c4
commit eca0011846
2 changed files with 14 additions and 14 deletions

View file

@ -273,27 +273,27 @@ float Bezier::lengthApprox() const
} }
void Bezier::split(float at, Bezier& left) void Bezier::split(float t, Bezier& left)
{ {
left.start = start; left.start = start;
left.ctrl1.x = start.x + at * (ctrl1.x - start.x); left.ctrl1.x = start.x + t * (ctrl1.x - start.x);
left.ctrl1.y = start.y + at * (ctrl1.y - start.y); left.ctrl1.y = start.y + t * (ctrl1.y - start.y);
left.ctrl2.x = ctrl1.x + at * (ctrl2.x - ctrl1.x); //temporary holding spot left.ctrl2.x = ctrl1.x + t * (ctrl2.x - ctrl1.x); //temporary holding spot
left.ctrl2.y = ctrl1.y + at * (ctrl2.y - ctrl1.y); //temporary holding spot left.ctrl2.y = ctrl1.y + t * (ctrl2.y - ctrl1.y); //temporary holding spot
ctrl2.x = ctrl2.x + at * (end.x - ctrl2.x); ctrl2.x = ctrl2.x + t * (end.x - ctrl2.x);
ctrl2.y = ctrl2.y + at * (end.y - ctrl2.y); ctrl2.y = ctrl2.y + t * (end.y - ctrl2.y);
ctrl1.x = left.ctrl2.x + at * (ctrl2.x - left.ctrl2.x); ctrl1.x = left.ctrl2.x + t * (ctrl2.x - left.ctrl2.x);
ctrl1.y = left.ctrl2.y + at * (ctrl2.y - left.ctrl2.y); ctrl1.y = left.ctrl2.y + t * (ctrl2.y - left.ctrl2.y);
left.ctrl2.x = left.ctrl1.x + at * (left.ctrl2.x - left.ctrl1.x); left.ctrl2.x = left.ctrl1.x + t * (left.ctrl2.x - left.ctrl1.x);
left.ctrl2.y = left.ctrl1.y + at * (left.ctrl2.y - left.ctrl1.y); left.ctrl2.y = left.ctrl1.y + t * (left.ctrl2.y - left.ctrl1.y);
left.end.x = start.x = left.ctrl2.x + at * (ctrl1.x - left.ctrl2.x); left.end.x = start.x = left.ctrl2.x + t * (ctrl1.x - left.ctrl2.x);
left.end.y = start.y = left.ctrl2.y + at * (ctrl1.y - left.ctrl2.y); left.end.y = start.y = left.ctrl2.y + t * (ctrl1.y - left.ctrl2.y);
} }

View file

@ -264,7 +264,7 @@ struct Bezier
Point ctrl2; Point ctrl2;
Point end; Point end;
void split(float at, Bezier& left); void split(float t, Bezier& left);
void split(Bezier& left, Bezier& right) const; void split(Bezier& left, Bezier& right) const;
void split(float at, Bezier& left, Bezier& right) const; void split(float at, Bezier& left, Bezier& right) const;
float length() const; float length() const;