Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I draw a curve through tree points in Android?

I need to connect three points by a smooth curve. I've looked at the same questions already answered on StackOverflow but they all suggest using Path.quadTo(). I do not understand why this is considered a correct answer as Bezier curve is only approaching middle (control) point but not going through it. In my case I have to go exactly through it. So how can I achieve that?

like image 843
Andrey Novikov Avatar asked Jan 17 '11 10:01

Andrey Novikov


People also ask

How to create curves from points in Rhino?

1) You can create curves from points using either the Interpolate Curve component or the Curve component. 2) This question is not at all clear. Maybe you could draw something in Rhino to illustrate. 3) Again this is not clear. The obvious answer would be that the 'beam' will stop at the end of the curve but you might be asking something else.

How do computers draw curves?

While we can draw curves with ease freehand, computers are a bit handicapped in that they require some constraints to draw the curve we desire, since the number of curves that can be drawn from one point to an other is infinite. That’s where the control points come in to picture. They determine the curvature of the desired curve.

How to draw a curved feature line in AutoCAD?

1. Draw 3D Polyline through points. 2. Convert said 3D Polyline to a Feature Line. 3. Use "Smooth" Command to make the Feature Line look like the curve it is.

How to draw a line graph from a Bezier path?

Drawing regular line graphs are pretty straight forward. You just keep doing-addLineToPath (point:) to a Bézier path while iterating through the given points. For this problem I would need a curve instead of a line. I know the UIBezierPath class has these two methods :-


1 Answers

True, what you need is Catmull Rom splines which are guaranted to go through each point. However, I don't know any function in the Android API to draw them. You could also "trick" the quadTo function and pass it a virtual middle point that you compute according to the current point and the next one.

like image 141
Vincent Mimoun-Prat Avatar answered Oct 02 '22 15:10

Vincent Mimoun-Prat