English 中文(简体)
Bezier Curve总长度相同
原标题:Bezier Curve always the same length

I m以超文本5的形式从事游戏。

I want is draw an S-shaped cubic bezier curve between two points, but I m looking for a way to calculate the coordinates of the control points so that the curve itself is always the same length no matter how close those points are, until it reaches the point where the curve becomes a straight line.

问题回答

This is solvable numerically. I assume you have a cubic bezier with 4 control points. at each step you have the first (P0) and last (P3) points, and you want to calculate P1 and P2 such that the total length is constant.

加上这一限制,就会取消一定程度的自由,这样我们就有1人离开(从4起起就确定了终点(-2),而持续时间是另一个――1)。 因此,你需要就此作出决定。

啤酒曲线是在0到1年之间界定的聚合物,你需要把元素(2d?)的根基结合起来。 对于一立方米苯,这意味着六分之六的rt,而该wo子不知道如何解决。 但是,如果你知道所有其他控制点(或知道依赖某些其他限制),那么你就可以为这一限制制定预估的数值。

是否确实有必要使曲线成为灵丹妙药? 减去两个总长度不变的圆环。 你们将永远获得S-shape。

安装两个循环弧:

“Fitting

<>D是终点之间的滑坡距离。 让我们永远保持下去。 www.un.org/Depts/DGACM/index_french.htm

b = sqrt(D*sin(C/4)/4 - (D^2)/16)

如果是正确的,那么如果某人有某种不同的话,我就没有听说过的话。

http://www.un.org。 在处理正确公式和检查时,你也应考虑我获得的消极解决办法。

b = -sqrt(D*sin(C/4)/4 - (D^2)/16)

Here s a working example in SVG that s close to correct:
http://phrogz.net/svg/constant-length-bezier.xhtml

“entergraph

I experimentally determined that when the endpoints are on top of one another the handles should be
desiredLength × cos(30°)
away from the handles; and (of course) when the end points are at their greatest distance the handles should be on top of one another. Plotting all ideal points looks sort of like an ellipse:

“Graph

The blue line is the actual ideal equation, while the red line above is an ellipse approximating the ideal. Using the equation for the ellipse (as my example above does) allows the line to get about 9% too long in the middle.

Here相关文本:

// M is the MoveTo command in SVG (the first point on the path)
// C is the CurveTo command in SVG:
//   C.x is the end point of the path
//   C.x1 is the first control point
//   C.x2 is the second control point
function makeFixedLengthSCurve(path,length){
  var dx   = C.x - M.x, dy = C.y - M.y;
  var len  = Math.sqrt(dx*dx+dy*dy);
  var angle = Math.atan2(dy,dx);
  if (len >= length){
    C.x  = M.x + 100 * Math.cos(angle);
    C.y  = M.y + 100 * Math.sin(angle);
    C.x1 = M.x; C.y1 = M.y;
    C.x2 = C.x; C.y2 = C.y;
  }else{
    // Ellipse of major axis length and minor axis length*cos(30°)
    var a = length, b = length*Math.cos(30*Math.PI/180);
    var handleDistance = Math.sqrt( b*b * ( 1 - len*len / (a*a) ) ); 
    C.x1 = M.x + handleDistance * Math.sin(angle);
    C.y1 = M.y - handleDistance * Math.cos(angle);
    C.x2 = C.x - handleDistance * Math.sin(angle);
    C.y2 = C.y + handleDistance * Math.cos(angle);
  }
}




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!