How to move the scaled point and keep the shape of the curve?

326 views Asked by At

For a curve, I wanna move the start and end point to new position, and then how to keep the shape of the curve ?

image with points

From the points which circulated on the yellow curve, move them to red curve position which circulated on the red curve, how to keep the shape of the curve on the red curve ?

2

There are 2 answers

1
Andrey  Smorodov On

When you define spline curve you need to define also tangents angles at endpoints, when you move you points to center, you are chenging the slopes of side lines, so if tangent angles are fixed wrt lines, they will make curve change. If you will see carefully corner angles are same on both images. To keep your curves shape you need to change these angles according side lines slope chenges.

6
fang On

So, let me summarize what you want to do here: given a Bezier curve or a B-spline curve and two new locations for the start point and end point, find a new Bezier/B-spline curve that more or less keeps the same shape as original curve.

One way to achieve this is to find a transformation that would transform the start/end points to their new locations, then you can apply the same transformation to all the other control points for the curve. Basically, this is the same as finding the transformation between a line defined by the curve's start point P and end point Q and another line defined by the new point locations P* and Q*. From P and P*, we can find a translation vector. From line PQ and line PQ, we can find a rotation angle. From length |PO| and length |PQ| we can find a scale factor. So, combining the translation vector, rotation angle and the scale factor, we will be able to find the transformation matrix. Apply the transformation matrix onto all the other control points, then you should be able to get the new curve that more or less maintain the same shape as original curve.

If what you really wan to do is to offset the curves, then this is a totally different story. Offset curves are achieved by a far-more complex algorithm (which I will not elaborate here) and we will specify offset distance (could be positive or negative to imply outwards/inwards offset) instead of new locations for the start/end points.