Browse Source

Renamed Bezier functions.

Mr.doob 8 years ago
parent
commit
8e8589c881

+ 18 - 19
src/extras/core/Bezier.js

@@ -5,77 +5,76 @@
  * http://en.wikipedia.org/wiki/Bézier_curve
  * http://en.wikipedia.org/wiki/Bézier_curve
  */
  */
 
 
-// Quad Bezier Functions
-
-function b2p0( t, p ) {
+function QuadraticBezierP0( t, p ) {
 
 
 	var k = 1 - t;
 	var k = 1 - t;
 	return k * k * p;
 	return k * k * p;
 
 
 }
 }
 
 
-function b2p1( t, p ) {
+function QuadraticBezierP1( t, p ) {
 
 
 	return 2 * ( 1 - t ) * t * p;
 	return 2 * ( 1 - t ) * t * p;
 
 
 }
 }
 
 
-function b2p2( t, p ) {
+function QuadraticBezierP2( t, p ) {
 
 
 	return t * t * p;
 	return t * t * p;
 
 
 }
 }
 
 
-function b2( t, p0, p1, p2 ) {
+function QuadraticBezier( t, p0, p1, p2 ) {
 
 
-	return b2p0( t, p0 ) + b2p1( t, p1 ) + b2p2( t, p2 );
+	return QuadraticBezierP0( t, p0 ) + QuadraticBezierP1( t, p1 ) +
+		QuadraticBezierP2( t, p2 );
 
 
 }
 }
 
 
-// Cubic Bezier Functions
+//
 
 
-function b3p0( t, p ) {
+function CubicBezierP0( t, p ) {
 
 
 	var k = 1 - t;
 	var k = 1 - t;
 	return k * k * k * p;
 	return k * k * k * p;
 
 
 }
 }
 
 
-function b3p1( t, p ) {
+function CubicBezierP1( t, p ) {
 
 
 	var k = 1 - t;
 	var k = 1 - t;
 	return 3 * k * k * t * p;
 	return 3 * k * k * t * p;
 
 
 }
 }
 
 
-function b3p2( t, p ) {
+function CubicBezierP2( t, p ) {
 
 
-	var k = 1 - t;
-	return 3 * k * t * t * p;
+	return 3 * ( 1 - t ) * t * t * p;
 
 
 }
 }
 
 
-function b3p3( t, p ) {
+function CubicBezierP3( t, p ) {
 
 
 	return t * t * t * p;
 	return t * t * t * p;
 
 
 }
 }
 
 
-function b3( t, p0, p1, p2, p3 ) {
+function CubicBezier( t, p0, p1, p2, p3 ) {
 
 
-	return b3p0( t, p0 ) + b3p1( t, p1 ) + b3p2( t, p2 ) + b3p3( t, p3 );
+	return CubicBezierP0( t, p0 ) + CubicBezierP1( t, p1 ) + CubicBezierP2( t, p2 ) +
+		CubicBezierP3( t, p3 );
 
 
 }
 }
 
 
 //
 //
 
 
-function tangentQuadraticBezier( t, p0, p1, p2 ) {
+function TangentQuadraticBezier( t, p0, p1, p2 ) {
 
 
 	return 2 * ( 1 - t ) * ( p1 - p0 ) + 2 * t * ( p2 - p1 );
 	return 2 * ( 1 - t ) * ( p1 - p0 ) + 2 * t * ( p2 - p1 );
 
 
 }
 }
 
 
-function tangentCubicBezier( t, p0, p1, p2, p3 ) {
+function TangentCubicBezier( t, p0, p1, p2, p3 ) {
 
 
 	return - 3 * p0 * ( 1 - t ) * ( 1 - t ) +
 	return - 3 * p0 * ( 1 - t ) * ( 1 - t ) +
 		3 * p1 * ( 1 - t ) * ( 1 - t ) - 6 * t * p1 * ( 1 - t ) +
 		3 * p1 * ( 1 - t ) * ( 1 - t ) - 6 * t * p1 * ( 1 - t ) +
@@ -84,4 +83,4 @@ function tangentCubicBezier( t, p0, p1, p2, p3 ) {
 
 
 }
 }
 
 
-export { b2, b3, tangentQuadraticBezier, tangentCubicBezier };
+export { QuadraticBezier, CubicBezier, TangentQuadraticBezier, TangentCubicBezier };

+ 5 - 5
src/extras/core/Font.js

@@ -1,4 +1,4 @@
-import { b2, b3 } from './Bezier';
+import { QuadraticBezier, CubicBezier } from './Bezier';
 import { ShapePath } from './ShapePath';
 import { ShapePath } from './ShapePath';
 
 
 /**
 /**
@@ -97,8 +97,8 @@ Object.assign( Font.prototype, {
 								for ( var i2 = 1; i2 <= divisions; i2 ++ ) {
 								for ( var i2 = 1; i2 <= divisions; i2 ++ ) {
 
 
 									var t = i2 / divisions;
 									var t = i2 / divisions;
-									b2( t, cpx0, cpx1, cpx );
-									b2( t, cpy0, cpy1, cpy );
+									QuadraticBezier( t, cpx0, cpx1, cpx );
+									QuadraticBezier( t, cpy0, cpy1, cpy );
 
 
 								}
 								}
 
 
@@ -127,8 +127,8 @@ Object.assign( Font.prototype, {
 								for ( var i2 = 1; i2 <= divisions; i2 ++ ) {
 								for ( var i2 = 1; i2 <= divisions; i2 ++ ) {
 
 
 									var t = i2 / divisions;
 									var t = i2 / divisions;
-									b3( t, cpx0, cpx1, cpx2, cpx );
-									b3( t, cpy0, cpy1, cpy2, cpy );
+									CubicBezier( t, cpx0, cpx1, cpx2, cpx );
+									CubicBezier( t, cpy0, cpy1, cpy2, cpy );
 
 
 								}
 								}
 
 

+ 5 - 5
src/extras/curves/CubicBezierCurve.js

@@ -1,4 +1,4 @@
-import { b3, tangentCubicBezier } from '../core/Bezier';
+import { CubicBezier, TangentCubicBezier } from '../core/Bezier';
 import { Curve } from '../core/Curve';
 import { Curve } from '../core/Curve';
 import { Vector2 } from '../../math/Vector2';
 import { Vector2 } from '../../math/Vector2';
 
 
@@ -21,8 +21,8 @@ CubicBezierCurve.prototype.constructor = CubicBezierCurve;
 CubicBezierCurve.prototype.getPoint = function ( t ) {
 CubicBezierCurve.prototype.getPoint = function ( t ) {
 
 
 	return new Vector2(
 	return new Vector2(
-		b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
-		b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
+		CubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
+		CubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
 	);
 	);
 
 
 };
 };
@@ -30,8 +30,8 @@ CubicBezierCurve.prototype.getPoint = function ( t ) {
 CubicBezierCurve.prototype.getTangent = function ( t ) {
 CubicBezierCurve.prototype.getTangent = function ( t ) {
 
 
 	return new Vector2(
 	return new Vector2(
-		tangentCubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
-		tangentCubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
+		TangentCubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
+		TangentCubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y )
 	).normalize();
 	).normalize();
 
 
 };
 };

+ 4 - 4
src/extras/curves/CubicBezierCurve3.js

@@ -1,4 +1,4 @@
-import { b3 } from '../core/Bezier';
+import { CubicBezier } from '../core/Bezier';
 import { Curve } from '../core/Curve';
 import { Curve } from '../core/Curve';
 import { Vector3 } from '../../math/Vector3';
 import { Vector3 } from '../../math/Vector3';
 
 
@@ -20,9 +20,9 @@ var CubicBezierCurve3 = Curve.create(
 	function ( t ) {
 	function ( t ) {
 
 
 		return new Vector3(
 		return new Vector3(
-			b3( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
-			b3( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y ),
-			b3( t, this.v0.z, this.v1.z, this.v2.z, this.v3.z )
+			CubicBezier( t, this.v0.x, this.v1.x, this.v2.x, this.v3.x ),
+			CubicBezier( t, this.v0.y, this.v1.y, this.v2.y, this.v3.y ),
+			CubicBezier( t, this.v0.z, this.v1.z, this.v2.z, this.v3.z )
 		);
 		);
 
 
 	}
 	}

+ 5 - 5
src/extras/curves/QuadraticBezierCurve.js

@@ -1,4 +1,4 @@
-import { b2, tangentQuadraticBezier } from '../core/Bezier';
+import { QuadraticBezier, TangentQuadraticBezier } from '../core/Bezier';
 import { Curve } from '../core/Curve';
 import { Curve } from '../core/Curve';
 import { Vector2 } from '../../math/Vector2';
 import { Vector2 } from '../../math/Vector2';
 
 
@@ -22,8 +22,8 @@ QuadraticBezierCurve.prototype.constructor = QuadraticBezierCurve;
 QuadraticBezierCurve.prototype.getPoint = function ( t ) {
 QuadraticBezierCurve.prototype.getPoint = function ( t ) {
 
 
 	return new Vector2(
 	return new Vector2(
-		b2( t, this.v0.x, this.v1.x, this.v2.x ),
-		b2( t, this.v0.y, this.v1.y, this.v2.y )
+		QuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x ),
+		QuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y )
 	);
 	);
 
 
 };
 };
@@ -32,8 +32,8 @@ QuadraticBezierCurve.prototype.getPoint = function ( t ) {
 QuadraticBezierCurve.prototype.getTangent = function ( t ) {
 QuadraticBezierCurve.prototype.getTangent = function ( t ) {
 
 
 	return new Vector2(
 	return new Vector2(
-		tangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x ),
-		tangentQuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y )
+		TangentQuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x ),
+		TangentQuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y )
 	).normalize();
 	).normalize();
 
 
 };
 };

+ 4 - 4
src/extras/curves/QuadraticBezierCurve3.js

@@ -1,4 +1,4 @@
-import { b2 } from '../core/Bezier';
+import { QuadraticBezier } from '../core/Bezier';
 import { Curve } from '../core/Curve';
 import { Curve } from '../core/Curve';
 import { Vector3 } from '../../math/Vector3';
 import { Vector3 } from '../../math/Vector3';
 
 
@@ -19,9 +19,9 @@ var QuadraticBezierCurve3 = Curve.create(
 	function ( t ) {
 	function ( t ) {
 
 
 		return new Vector3(
 		return new Vector3(
-			b2( t, this.v0.x, this.v1.x, this.v2.x ),
-			b2( t, this.v0.y, this.v1.y, this.v2.y ),
-			b2( t, this.v0.z, this.v1.z, this.v2.z )
+			QuadraticBezier( t, this.v0.x, this.v1.x, this.v2.x ),
+			QuadraticBezier( t, this.v0.y, this.v1.y, this.v2.y ),
+			QuadraticBezier( t, this.v0.z, this.v1.z, this.v2.z )
 		);
 		);
 
 
 	}
 	}