Browse Source

Removed unused getTangent from QuadraticBezierCurve and CubicBezierCurve.

Mr.doob 8 years ago
parent
commit
b6a473d8b7

+ 1 - 17
src/extras/core/Interpolations.js

@@ -78,20 +78,4 @@ function CubicBezier( t, p0, p1, p2, p3 ) {
 
 }
 
-//
-
-function TangentQuadraticBezier( t, p0, p1, p2 ) {
-
-	return 2 * ( 1 - t ) * ( p1 - p0 ) + 2 * t * ( p2 - p1 );
-
-}
-
-function TangentCubicBezier( t, p0, p1, p2, p3 ) {
-
-	var k = 1 - t;
-	return - 3 * p0 * k * k + 3 * p1 * k * k - 6 * t * p1 * k +
-		6 * t * p2 * k - 3 * t * t * p2 + 3 * t * t * p3;
-
-}
-
-export { CatmullRom, QuadraticBezier, CubicBezier, TangentQuadraticBezier, TangentCubicBezier };
+export { CatmullRom, QuadraticBezier, CubicBezier };

+ 16 - 26
src/extras/curves/CubicBezierCurve.js

@@ -1,44 +1,34 @@
 import { Curve } from '../core/Curve';
-import { CubicBezier, TangentCubicBezier } from '../core/Interpolations';
+import { CubicBezier } from '../core/Interpolations';
 import { Vector2 } from '../../math/Vector2';
 
 /**************************************************************
  *	Cubic Bezier curve
  **************************************************************/
 
-function CubicBezierCurve( v0, v1, v2, v3 ) {
+var CubicBezierCurve = Curve.create(
 
-	this.v0 = v0;
-	this.v1 = v1;
-	this.v2 = v2;
-	this.v3 = v3;
+	function ( v0, v1, v2, v3 ) {
 
-}
+		this.v0 = v0;
+		this.v1 = v1;
+		this.v2 = v2;
+		this.v3 = v3;
 
-CubicBezierCurve.prototype = Object.create( Curve.prototype );
-CubicBezierCurve.prototype.constructor = CubicBezierCurve;
+	},
 
-CubicBezierCurve.prototype.getPoint = function ( t ) {
+	function ( t ) {
 
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
+		var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
 
-	return new Vector2(
-		CubicBezier( t, v0.x, v1.x, v2.x, v3.x ),
-		CubicBezier( t, v0.y, v1.y, v2.y, v3.y )
-	);
+		return new Vector2(
+			CubicBezier( t, v0.x, v1.x, v2.x, v3.x ),
+			CubicBezier( t, v0.y, v1.y, v2.y, v3.y )
+		);
 
-};
+	}
 
-CubicBezierCurve.prototype.getTangent = function ( t ) {
-
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2, v3 = this.v3;
-
-	return new Vector2(
-		TangentCubicBezier( t, v0.x, v1.x, v2.x, v3.x ),
-		TangentCubicBezier( t, v0.y, v1.y, v2.y, v3.y )
-	).normalize();
-
-};
+);
 
 
 export { CubicBezierCurve };

+ 15 - 27
src/extras/curves/QuadraticBezierCurve.js

@@ -1,45 +1,33 @@
 import { Curve } from '../core/Curve';
-import { QuadraticBezier, TangentQuadraticBezier } from '../core/Interpolations';
+import { QuadraticBezier } from '../core/Interpolations';
 import { Vector2 } from '../../math/Vector2';
 
 /**************************************************************
  *	Quadratic Bezier curve
  **************************************************************/
 
+var QuadraticBezierCurve = Curve.create(
 
-function QuadraticBezierCurve( v0, v1, v2 ) {
+	function ( v0, v1, v2 ) {
 
-	this.v0 = v0;
-	this.v1 = v1;
-	this.v2 = v2;
+		this.v0 = v0;
+		this.v1 = v1;
+		this.v2 = v2;
 
-}
+	},
 
-QuadraticBezierCurve.prototype = Object.create( Curve.prototype );
-QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;
+	function ( t ) {
 
-QuadraticBezierCurve.prototype.getPoint = function ( t ) {
+		var v0 = this.v0, v1 = this.v1, v2 = this.v2;
 
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2;
+		return new Vector2(
+			QuadraticBezier( t, v0.x, v1.x, v2.x ),
+			QuadraticBezier( t, v0.y, v1.y, v2.y )
+		);
 
-	return new Vector2(
-		QuadraticBezier( t, v0.x, v1.x, v2.x ),
-		QuadraticBezier( t, v0.y, v1.y, v2.y )
-	);
+	}
 
-};
-
-
-QuadraticBezierCurve.prototype.getTangent = function ( t ) {
-
-	var v0 = this.v0, v1 = this.v1, v2 = this.v2;
-
-	return new Vector2(
-		TangentQuadraticBezier( t, v0.x, v1.x, v2.x ),
-		TangentQuadraticBezier( t, v0.y, v1.y, v2.y )
-	).normalize();
-
-};
+);
 
 
 export { QuadraticBezierCurve };