File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -12,8 +12,6 @@ var FromPoints = require('../geom/rectangle/FromPoints');
1212var Rectangle = require ( '../geom/rectangle/Rectangle' ) ;
1313var Vector2 = require ( '../math/Vector2' ) ;
1414
15- var tmpVec2 = new Vector2 ( ) ;
16-
1715/**
1816 * @classdesc
1917 * A LineCurve is a "curve" comprising exactly two points (a line segment).
@@ -182,16 +180,21 @@ var LineCurve = new Class({
182180 *
183181 * @method Phaser.Curves.Line#getTangent
184182 * @since 3.0.0
185- *
183+ *
186184 * @generic {Phaser.Math.Vector2} O - [out,$return]
187185 *
186+ * @param {number } [t] - The relative position on the line, [0..1].
187+ * @param {Phaser.Math.Vector2 } [out] - A vector to store the result in.
188+ *
188189 * @return {Phaser.Math.Vector2 } The tangent vector.
189190 */
190- getTangent : function ( )
191+ getTangent : function ( t , out )
191192 {
192- var tangent = tmpVec2 . copy ( this . p1 ) . subtract ( this . p0 ) ;
193+ if ( out === undefined ) { out = new Vector2 ( ) ; }
194+
195+ out . copy ( this . p1 ) . subtract ( this . p0 ) . normalize ( ) ;
193196
194- return tangent . normalize ( ) ;
197+ return out ;
195198 } ,
196199
197200 /**
You can’t perform that action at this time.
0 commit comments