From eca0011846a57dabb4a750a0482a01d501493a67 Mon Sep 17 00:00:00 2001 From: Mira Grudzinska Date: Thu, 8 Aug 2024 12:23:35 +0200 Subject: [PATCH] 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. --- src/common/tvgMath.cpp | 26 +++++++++++++------------- src/common/tvgMath.h | 2 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/common/tvgMath.cpp b/src/common/tvgMath.cpp index e435c300..eef1dabd 100644 --- a/src/common/tvgMath.cpp +++ b/src/common/tvgMath.cpp @@ -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.ctrl1.x = start.x + at * (ctrl1.x - start.x); - left.ctrl1.y = start.y + at * (ctrl1.y - start.y); + left.ctrl1.x = start.x + t * (ctrl1.x - start.x); + 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.y = ctrl1.y + at * (ctrl2.y - ctrl1.y); //temporary holding spot + left.ctrl2.x = ctrl1.x + t * (ctrl2.x - ctrl1.x); //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.y = ctrl2.y + at * (end.y - ctrl2.y); + ctrl2.x = ctrl2.x + t * (end.x - ctrl2.x); + ctrl2.y = ctrl2.y + t * (end.y - ctrl2.y); - ctrl1.x = left.ctrl2.x + at * (ctrl2.x - left.ctrl2.x); - ctrl1.y = left.ctrl2.y + at * (ctrl2.y - left.ctrl2.y); + ctrl1.x = left.ctrl2.x + t * (ctrl2.x - left.ctrl2.x); + 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.y = left.ctrl1.y + at * (left.ctrl2.y - left.ctrl1.y); + left.ctrl2.x = left.ctrl1.x + t * (left.ctrl2.x - left.ctrl1.x); + 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.y = start.y = left.ctrl2.y + at * (ctrl1.y - left.ctrl2.y); + left.end.x = start.x = left.ctrl2.x + t * (ctrl1.x - left.ctrl2.x); + left.end.y = start.y = left.ctrl2.y + t * (ctrl1.y - left.ctrl2.y); } diff --git a/src/common/tvgMath.h b/src/common/tvgMath.h index fa8ef706..65cdaac2 100644 --- a/src/common/tvgMath.h +++ b/src/common/tvgMath.h @@ -264,7 +264,7 @@ struct Bezier Point ctrl2; Point end; - void split(float at, Bezier& left); + void split(float t, Bezier& left); void split(Bezier& left, Bezier& right) const; void split(float at, Bezier& left, Bezier& right) const; float length() const;