source: other-projects/playing-in-the-street/summer-2013/trunk/Playing-in-the-Street-WPF/Content/Web/mrdoob-three.js-4862f5f/src/extras/curves/CubicBezierCurve.js@ 28897

Last change on this file since 28897 was 28897, checked in by davidb, 10 years ago

GUI front-end to server base plus web page content

File size: 973 bytes
Line 
1/**************************************************************
2 * Cubic Bezier curve
3 **************************************************************/
4
5THREE.CubicBezierCurve = function ( v0, v1, v2, v3 ) {
6
7 this.v0 = v0;
8 this.v1 = v1;
9 this.v2 = v2;
10 this.v3 = v3;
11
12};
13
14THREE.CubicBezierCurve.prototype = Object.create( THREE.Curve.prototype );
15
16THREE.CubicBezierCurve.prototype.getPoint = function ( t ) {
17
18 var tx, ty;
19
20 tx = THREE.Shape.Utils.b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x );
21 ty = THREE.Shape.Utils.b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y );
22
23 return new THREE.Vector2( tx, ty );
24
25};
26
27THREE.CubicBezierCurve.prototype.getTangent = function( t ) {
28
29 var tx, ty;
30
31 tx = THREE.Curve.Utils.tangentCubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x );
32 ty = THREE.Curve.Utils.tangentCubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y );
33
34 var tangent = new THREE.Vector2( tx, ty );
35 tangent.normalize();
36
37 return tangent;
38
39};
Note: See TracBrowser for help on using the repository browser.