bezier

how to calculate control points on a bezier curve?

断了今生、忘了曾经 提交于 2019-12-06 09:56:47
I do have a bezier curve, and at a certain point, I want a second bezier curve "branching off" the first curve in a smooth manner. Together with calculating the intersection point (with a percentage following the Bezier curve), I need also the control point (the tangent and weight). The intersection point is calculated with the following piece of javascript: getBezier = function getBez(percent,p1,cp1,cp2,p2) { function b1(t) { return t*t*t } function b2(t) { return 3*t*t*(1-t) } function b3(t) { return 3*t*(1-t)*(1-t) } function b4(t) { return (1-t)*(1-t)*(1-t) } var pos = {x:0,y:0}; pos.x =

Detect&find intersection ray vs. cubic bezier triangle

狂风中的少年 提交于 2019-12-06 07:55:21
问题 While writing a model editor, besides enabling raytracing I can think about couple of operations where I'd like to find an very good approximation about the intersection point between a ray and a triangular bezier patch. How to do this? I know couple of ways but likely there's better ones. Exact use-cases: I might want to use one bezier triangle patch as a reference surface for drawing detailed shapes with mouse. I might too want to pinpoint a splitting-point from such patch. If there's C

How to generate a “thick” bezier curve?

人走茶凉 提交于 2019-12-06 07:38:02
问题 I'm looking for a way to generate a polygon programatically by "thickening" a Bezier curve. Something like this: My initial idea was to find the normals in the line, and generate the polygon from them: But the problem is that the normals can cross each other in steep curves, like this: Are there any formulas or algorithms that generate a polygon from a bezier curve? I couldn't find any information on the internet, but perhaps I'm searching using the wrong words... 回答1: If you want a constant

Jigsaw Puzzle pices using Bezier Curve

天大地大妈咪最大 提交于 2019-12-06 06:51:35
I was trying to make some jigsaw pieces like this - What I have tried till now with lineTo - outside: function (ctx, s, cx, cy) { ctx.lineTo(cx, cy) ctx.lineTo(cx+s*.3, cy) ctx.lineTo(cx+s*.5, cy+s*-.2) ctx.lineTo(cx+s*.7, cy) ctx.lineTo(cx+s, cy) }, inside: function (ctx, s, cx, cy) { ctx.lineTo(cx, cy) ctx.lineTo(cx+s*.3, cy) ctx.lineTo(cx+s*.5, cy+s*+.2) ctx.lineTo(cx+s*.7, cy) ctx.lineTo(cx+s, cy) }, Fiddle Link Efficient Jigsaw design is simple and it works like this: The linked code already shows how to efficiently assemble one of your jigsaw pieces by reusing a single side design. The

Calculate the arclength, curve length of a cubic bezier curve. Why is not working?

…衆ロ難τιáo~ 提交于 2019-12-06 06:20:31
问题 I'm calculating the arclength (length of a cubic bezier curve) with this algorithm function getArcLength(path) { var STEPS = 1000; // > precision var t = 1 / STEPS; var aX=0; var aY=0; var bX=0, bY=0; var dX=0, dY=0; var dS = 0; var sumArc = 0; var j = 0; for (var i=0; i<STEPS; j = j + t) { aX = bezierPoint(j, path[0], path[2], path[4], path[6]); aY = bezierPoint(j, path[1], path[3], path[5], path[7]); dX = aX - bX; dY = aY - bY; // deltaS. Pitagora dS = Math.sqrt((dX * dX) + (dY * dY));

Cubic bezier curve segment

五迷三道 提交于 2019-12-06 04:59:12
问题 If I have the 4 points describing a Bezier curve P1, P2, P3, P4 (where P1 and P4 are the end points of the curve and P2 and P3 are the control points of the curve), how could I find the points that describes only a segment of this bezier curve? I found this answer which is exactly what I am looking for but the answer seems wrong. If I set t0=0 and t1=1 in the equations which should represent the entire bezier curve, the resulting points are not valid. They are not equal to the original points

Calculate the horizon of a curved face?

被刻印的时光 ゝ 提交于 2019-12-06 03:31:00
I need to find the 2 points of the visual horizon , of a curved face. I have: XYZ of the 4 corner points XYZ of the 2 curved edge bezier points And I need to calculate either: XY of the horizon points XYZ of the horizon points First off you have to convert your 3D beziers to 2D. If I remember right it's sufficient to project the curves just like you project 3D points for rendering. Afterwards you have to find the extrema of the curves. A small HowTo: Convert your bezier-curve from bezier representation to a polyonomial of the form x(t) = a*t^3 + b*t^2 + c*t + d y(t) = e*t^3 + f*t^2 + g*t + g

How can I create a simple 2D NURBS using XAML?

坚强是说给别人听的谎言 提交于 2019-12-06 00:28:55
I need to create a spline with two endpoints and 'n' control points. As far as I am aware, a Bezier curve allows for only one control point, and a Bezier spline allows for two control points. However, I need to be able to add as many control points as I see fit, not limited to one or two. Here is an example of what I want to achieve, with 4 control points: (Source: Wikipedia article on NURBS ) So far I've only been able to combine a series of BezierSegments together like this: http://img297.imageshack.us/img297/3706/bezierpath.png <Polyline Stroke="Green" Stretch="Uniform" Points="0,0 1,2 2,1

Create random shape/contour using matplotlib

孤街醉人 提交于 2019-12-05 22:52:55
问题 I am trying to generate an image of a random contour using python but I couldn't find an easy way to do it. Here is an example sort of what I want: Initially I tought of doing it using matplotlib and gaussian functions, but I could not even get close to the image I showed. Is there a simple way to do it? I appreciate any help 回答1: matplotlib Path A simple way to achieve random and quite smoothed shapes is using matplotlib.path module. Using a cubic Bézier curve, most of the lines will be

Bezier curve algorithm in objective-c

邮差的信 提交于 2019-12-05 21:35:53
Can someone smarter than me take a look at this. I'm trying to implement a Bezier curve algorithm I found here in objective-c. The output is way wrong. I think I converted the code correctly so either the original was wrong or was not ment to be used like this... If I use the built in NSBezierPath the curve looks great but I can't use the built in NSBezierPath . NSBezierPath example NSBezierPath *bezierPath = [[NSBezierPath alloc] init]; [bezierPath setLineWidth:1.0f]; [bezierPath moveToPoint:NSMakePoint(x1, y1)]; [bezierPath curveToPoint:NSMakePoint(x4, y4) controlPoint1:NSMakePoint(x2, y2)