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:
966 bytes
|
Line | |
---|
1 | /**************************************************************
|
---|
2 | * Quadratic Bezier curve
|
---|
3 | **************************************************************/
|
---|
4 |
|
---|
5 |
|
---|
6 | THREE.QuadraticBezierCurve = function ( v0, v1, v2 ) {
|
---|
7 |
|
---|
8 | this.v0 = v0;
|
---|
9 | this.v1 = v1;
|
---|
10 | this.v2 = v2;
|
---|
11 |
|
---|
12 | };
|
---|
13 |
|
---|
14 | THREE.QuadraticBezierCurve.prototype = Object.create( THREE.Curve.prototype );
|
---|
15 |
|
---|
16 |
|
---|
17 | THREE.QuadraticBezierCurve.prototype.getPoint = function ( t ) {
|
---|
18 |
|
---|
19 | var tx, ty;
|
---|
20 |
|
---|
21 | tx = THREE.Shape.Utils.b2( t, this.v0.x, this.v1.x, this.v2.x );
|
---|
22 | ty = THREE.Shape.Utils.b2( t, this.v0.y, this.v1.y, this.v2.y );
|
---|
23 |
|
---|
24 | return new THREE.Vector2( tx, ty );
|
---|
25 |
|
---|
26 | };
|
---|
27 |
|
---|
28 |
|
---|
29 | THREE.QuadraticBezierCurve.prototype.getTangent = function( t ) {
|
---|
30 |
|
---|
31 | var tx, ty;
|
---|
32 |
|
---|
33 | tx = THREE.Curve.Utils.tangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x );
|
---|
34 | ty = THREE.Curve.Utils.tangentQuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y );
|
---|
35 |
|
---|
36 | // returns unit vector
|
---|
37 |
|
---|
38 | var tangent = new THREE.Vector2( tx, ty );
|
---|
39 | tangent.normalize();
|
---|
40 |
|
---|
41 | return tangent;
|
---|
42 |
|
---|
43 | }; |
---|
Note:
See
TracBrowser
for help on using the repository browser.