简体   繁体   中英

use any curve to connect two certain points with certain link length using javascript of its library such as d3

I want to connect two point using a curve, we know the coordinates of start point, the coordinates of end point, curve length. Since the length is greater than the direct straight line of the two points, a curve should be used. Any method using the d3 library would be better. I found something similar to my question here . But the question is not actually solved since calculating the length is far too complex. Thanks.

Here is one way of using circle arc, I analytically try it but it seems not good enough since we need some numerical method such as Newton's method to obtain theta, the function has the form

sin theta / theta = 2l / s

where l is the length of the curve and s is the length of the straight line (segment).

The answer is very simple: the curve that satisfies the condition is an arc. Given points, and desired curve length, finding such arc is a matter of high school math. Since you didn't bother attaching a jsfiddle or similar prototype showing some effort from your side, I won't bother too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM