# Path - quadraticTo or cubicTo is not tangent

Hello,
I try to draw the line which has lot of curves (more than 3 control points, even more than 10) and want it to be continuous.
But when I try to `cubicTo` (or `quadraticTo`) it always draw line from last position of Path, but it’s not tangent to previous curve. Could anyone help me how to fix it?

Maybe that’s question concerns more to interpolating topic than to Juce at all. But please, help me?

The Path::cubicTo( float controlPoint1X, float controlPoint1Y, float controlPoint2X, float controlPoint2Y, float endPointX, float endPointY) has three arguments, but actually needs rather four components:

• the start point, which is given by the path (previous call)
• the first ControlPoint, that defines the tangent at the start point
• the second ControlPoint, that defines the tangent at the end point
• the end point

If you put the start point as the first argument, it will not define any tangent, since the tangent would have no direction. If you add e.g. this into an empty application, it draws with horizontal start and horizontal end:

``````Path p;
p.startNewSubPath ( 100, 100);
p.cubicTo (200, 100, 100, 200, 200, 200);
g.strokePath (p, PathStrokeType (1.0));
``````

HTH

Hello, great thanks for help.
But of course I understand what you described. But my question is:
What should be `controlPoint1`(first argument) to be sure that line will be tangent to previous path line?
As I told it probably interpolation/math topic instead Juce topic, but I ask you for a help.
I suppose I need in some way to define angle in first control point, and that angle should be corresponding in some way to the previous line(curve). But I have no idea how to do that?

The first vector should be the opposite of the previous one. I chose horizontal, but if you have your arriving curve computed by any means, just use the opposite vector for the next one.

There is not enough information to have only one solution.

• the length of the vector -> I chose it to hit the orthogonal where I meet the next point
• other option, always use three points and compute the tangent to be orthogonal to the middle angle of the two segments

It really depends on what you want to achieve. But basically, have the previous vector and the following vector in line, to have continuity in the curve

OK, maybe I should say on the beginning what I want to achieve. So my main aim is to make frequency analyser and want to get graph similar to graph in Voxengo SPAN plugin

I have already my peaks, but when I connect them by simple `lineTo` it doesn’t look good. I am not sure what to use, but I was trying with `cubicTo` and `quadraticTo` and I have impression it’s not good idea. Maybe you could give some hint what would be the best in that case? Remember my graph is changing dynamically according to sound that is coming in.