Curly braces: Difference between revisions
From JSXGraph Wiki
A WASSERMANN (talk | contribs) (Created page with "<jsxgraph width="600" height="600"> var brd = JXG.JSXGraph.initBoard('jxgbox',{boundingbox:[-4,4,4,-4],keepaspectratio:true,axis:true}); var A = brd.create('point', [-3,3]); var ...") |
A WASSERMANN (talk | contribs) No edit summary |
||
Line 4: | Line 4: | ||
var B = brd.create('point', [3,-2]); | var B = brd.create('point', [3,-2]); | ||
var line = brd.create('segment', [A,B]); | var line = brd.create('segment', [A,B]); | ||
var crl = brd.create('curve', [[0],[0]], {strokeWidth:1, strokeColor:'black'}); | |||
crl.bezierDegree = 3; | |||
crl.updateDataArray = function() { | |||
var d = [B.X() - A.X(), B.Y() - A.Y()], | |||
dl = Math.sqrt(d[0]*d[0]+d[1]*d[1]), | |||
mid = [(A.X()+B.X())*0.5, (A.Y()+B.Y())*0.5]; | |||
this.dataX = [ A.X(), A.X()+d[1]/dl, mid[0], mid[0]+d[1]/dl, mid[0], B.X()+d[1]/dl, B.X()]; | |||
this.dataY = [ A.Y(), A.Y()-d[0]/dl, mid[1], mid[1]-d[0]/dl, mid[1], B.Y()-d[0]/dl, B.Y()]; | |||
}; | |||
brd.update(); | |||
</jsxgraph> | </jsxgraph> | ||