Remove MeagerMatrix removed Vector3D Reimplemented Matrix using compatible licensed code Added chainability to Matrix methods
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/518f7173 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/518f7173 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/518f7173 Branch: refs/heads/master Commit: 518f71734bb20c81dbccfb217d58bfe047979f40 Parents: 91b7669 Author: Harbs <[email protected]> Authored: Sun Aug 14 22:34:36 2016 +0300 Committer: Harbs <[email protected]> Committed: Sun Aug 14 22:34:36 2016 +0300 ---------------------------------------------------------------------- .../projects/Core/src/main/flex/CoreClasses.as | 1 - .../org/apache/flex/core/ITransformModel.as | 6 +- .../apache/flex/core/TransformCompoundModel.as | 8 +- .../flex/org/apache/flex/core/TransformModel.as | 8 +- .../org/apache/flex/core/TransformMoveXModel.as | 4 +- .../org/apache/flex/core/TransformMoveYModel.as | 4 +- .../apache/flex/core/TransformRotateModel.as | 4 +- .../org/apache/flex/core/TransformScaleModel.as | 4 +- .../main/flex/org/apache/flex/geom/IMatrix.as | 37 -- .../main/flex/org/apache/flex/geom/Matrix.as | 432 ++++++++----------- .../flex/org/apache/flex/geom/MeagerMatrix.as | 106 ----- .../main/flex/org/apache/flex/geom/Vector3D.as | 208 --------- .../flex/org/apache/flex/svg/TransformBead.as | 6 +- 13 files changed, 195 insertions(+), 633 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/CoreClasses.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/CoreClasses.as b/frameworks/projects/Core/src/main/flex/CoreClasses.as index 3a69a31..3e86f1c 100644 --- a/frameworks/projects/Core/src/main/flex/CoreClasses.as +++ b/frameworks/projects/Core/src/main/flex/CoreClasses.as @@ -110,7 +110,6 @@ internal class CoreClasses import org.apache.flex.events.ValueEvent; ValueEvent; import org.apache.flex.events.utils.MouseUtils; MouseUtils; import org.apache.flex.geom.Matrix; Matrix; - import org.apache.flex.geom.MeagerMatrix; MeagerMatrix; import org.apache.flex.geom.Point; Point; import org.apache.flex.geom.Rectangle; Rectangle; import org.apache.flex.utils.BinaryData; BinaryData; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as index a88fcb6..56cb961 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ITransformModel.as @@ -19,7 +19,7 @@ package org.apache.flex.core { import org.apache.flex.events.IEventDispatcher; - import org.apache.flex.geom.IMatrix; + import org.apache.flex.geom.Matrix; /** * The ITransformModel interface describes the minimum set of properties @@ -40,8 +40,8 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function get matrix():IMatrix; - function set matrix(value:IMatrix):void; + function get matrix():Matrix; + function set matrix(value:Matrix):void; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformCompoundModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformCompoundModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformCompoundModel.as index ce2e6d2..9418fd1 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformCompoundModel.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformCompoundModel.as @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - import org.apache.flex.geom.IMatrix; + import org.apache.flex.geom.Matrix; [DefaultProperty("transformModels")] public class TransformCompoundModel extends TransformModel @@ -28,10 +28,10 @@ package org.apache.flex.core if (value && value.length > 0) { var length:int = value.length; - var product:IMatrix = (value[0] as ITransformModel).matrix.clone(); + var product:Matrix = (value[0] as ITransformModel).matrix.clone(); for (var i:int = 1; i < length; i++) { - var current:IMatrix = (value[i] as ITransformModel).matrix; + var current:Matrix = (value[i] as ITransformModel).matrix; concat(product, current); } matrix = product; @@ -41,7 +41,7 @@ package org.apache.flex.core } } - private function concat(product:IMatrix, factor:IMatrix):void + private function concat(product:Matrix, factor:Matrix):void { var result_a:Number = product.a * factor.a; var result_b:Number = 0.0; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as index e2c083b..063b682 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformModel.as @@ -20,21 +20,21 @@ package org.apache.flex.core { import org.apache.flex.events.Event; import org.apache.flex.events.EventDispatcher; - import org.apache.flex.geom.IMatrix; + import org.apache.flex.geom.Matrix; public class TransformModel extends EventDispatcher implements ITransformModel { public static const CHANGE:String = "transferModelChange"; - private var _matrix:IMatrix; + private var _matrix:Matrix; private var _strand:IStrand; public function TransformModel() { } - public function get matrix():IMatrix + public function get matrix():Matrix { return _matrix; } @@ -49,7 +49,7 @@ package org.apache.flex.core return _strand as ITransformHost; } - public function set matrix(value:IMatrix):void + public function set matrix(value:Matrix):void { _matrix = value; if (_strand) http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveXModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveXModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveXModel.as index 40dd15f..78f2747 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveXModel.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveXModel.as @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - import org.apache.flex.geom.MeagerMatrix; + import org.apache.flex.geom.Matrix; public class TransformMoveXModel extends TransformModel { @@ -36,7 +36,7 @@ package org.apache.flex.core public function set x(value:Number):void { _x = value; - matrix = new MeagerMatrix(1, 0, 0, 1, x, 0); + matrix = new Matrix(1, 0, 0, 1, x, 0); } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveYModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveYModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveYModel.as index 51b9ba5..4d9f657 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveYModel.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformMoveYModel.as @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - import org.apache.flex.geom.MeagerMatrix; + import org.apache.flex.geom.Matrix; public class TransformMoveYModel extends TransformModel { @@ -36,7 +36,7 @@ package org.apache.flex.core public function set y(value:Number):void { _y = value; - matrix = new MeagerMatrix(1, 0, 0, 1, 0, y); + matrix = new Matrix(1, 0, 0, 1, 0, y); } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformRotateModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformRotateModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformRotateModel.as index 62bc7f6..1b9d1a8 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformRotateModel.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformRotateModel.as @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - import org.apache.flex.geom.MeagerMatrix; + import org.apache.flex.geom.Matrix; public class TransformRotateModel extends TransformModel @@ -38,7 +38,7 @@ package org.apache.flex.core { _angle = value; var radians:Number = value * Math.PI/180; - matrix = new MeagerMatrix(Math.cos(radians), Math.sin(radians), -Math.sin(radians), Math.cos(radians)); + matrix = new Matrix(Math.cos(radians), Math.sin(radians), -Math.sin(radians), Math.cos(radians)); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformScaleModel.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformScaleModel.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformScaleModel.as index ccd24a8..c8c29a8 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformScaleModel.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/TransformScaleModel.as @@ -18,7 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - import org.apache.flex.geom.MeagerMatrix; + import org.apache.flex.geom.Matrix; public class TransformScaleModel extends TransformModel { @@ -35,7 +35,7 @@ package org.apache.flex.core public function set scale(value:Number):void { _scale = value; - matrix = new MeagerMatrix(scale, 0, 0, scale, 0, 0); + matrix = new Matrix(scale, 0, 0, scale, 0, 0); } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/IMatrix.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/IMatrix.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/IMatrix.as deleted file mode 100644 index abc6348..0000000 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/IMatrix.as +++ /dev/null @@ -1,37 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.geom -{ - public interface IMatrix - { - function get a():Number; - function set a(value:Number):void; - function get b():Number; - function set b(value:Number):void; - function get c():Number; - function set c(value:Number):void; - function get d():Number; - function set d(value:Number):void; - function get tx():Number; - function set tx(value:Number):void; - function get ty():Number; - function set ty(value:Number):void; - function clone():IMatrix - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as index bf634e3..41ca075 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Matrix.as @@ -19,7 +19,7 @@ package org.apache.flex.geom { - public class Matrix implements IMatrix + public class Matrix { public function Matrix(a:Number = 1, b:Number = 0, c:Number = 0, d:Number = 1, tx:Number = 0, ty:Number = 0) { @@ -31,319 +31,233 @@ package org.apache.flex.geom this.ty = ty; } - private var _a:Number; - private var _b:Number; - private var _c:Number; - private var _d:Number; - private var _tx:Number; - private var _ty:Number; + public var a:Number; + public var b:Number; + public var c:Number; + public var d:Number; + public var tx:Number; + public var ty:Number; - public function get ty():Number + /** + * Returns a copy of the Matrix + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function clone():Matrix { - return _ty; - } - - public function set ty(value:Number):void - { - _ty = value; - } - - public function get tx():Number - { - return _tx; - } - - public function set tx(value:Number):void - { - _tx = value; - } - - public function get d():Number - { - return _d; - } - - public function set d(value:Number):void - { - _d = value; - } - - public function get c():Number - { - return _c; - } - - public function set c(value:Number):void - { - _c = value; - } - - public function get b():Number - { - return _b; - } - - public function set b(value:Number):void - { - _b = value; + return new Matrix(a, b, c, d, tx, ty); } - - public function get a():Number + + /** + * Adds the Matrix the current one + * Returns the matrix so the methods can be chained. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function concat(m:Matrix):Matrix { - return _a; + var newa:Number = a * m.a + b * m.c; + b = a * m.b + b * m.d; + a = newa; + + var newc:Number = c * m.a + d * m.c; + d = c * m.b + d * m.d; + c = newc; + + var newtx:Number = tx * m.a + ty * m.c + m.tx; + ty = tx * m.b + ty * m.d + m.ty; + tx = newtx; + return this; } - public function set a(value:Number):void + /** + * Calculates the Matrix determinant + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function determinant():Number { - _a = value; - } - - public function clone():IMatrix - { - return new Matrix(a, b, c, d, tx, ty); - } - - public function concat(m:Matrix):void - { - var result_a:Number = a * m.a; - var result_b:Number = 0.0; - var result_c:Number = 0.0; - var result_d:Number = d * m.d; - var result_tx:Number = tx * m.a + m.tx; - var result_ty:Number = ty * m.d + m.ty; - if (b != 0.0 || c != 0.0 || m.b != 0.0 || m.c != 0.0) - { - result_a = result_a + b * m.c; - result_d = result_d + c * m.b; - result_b = result_b + (a * m.b + b * m.d); - result_c = result_c + (c * m.a + d * m.c); - result_tx = result_tx + ty * m.c; - result_ty = result_ty + tx * m.b; - } - a = result_a; - b = result_b; - c = result_c; - d = result_d; - tx = result_tx; - ty = result_ty; + return a * d - b * c; } - public function invert():void + /** + * Inverts the Matrix. + * Returns the matrix so the methods can be chained. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function invert():Matrix { - var a0:* = NaN; - var a1:* = NaN; - var a2:* = NaN; - var a3:* = NaN; - var det:* = NaN; - var result_ty:* = NaN; - if (b == 0.0 && c == 0.0) + // if b and c are both 0, we can simplify this. + if (b == 0 && c == 0) { a = 1 / a; d = 1 / d; - b = c = 0.0; - tx = -a * tx; - ty = -d * ty; + tx *= -a; + ty *= -d; } else { - a0 = a; - a1 = b; - a2 = c; - a3 = d; - det = a0 * a3 - a1 * a2; - if (det == 0.0) + var det:Number = determinant(); + if (det == 0) { identity(); - return; + return this; } det = 1 / det; - a = a3 * det; - b = -a1 * det; - c = -a2 * det; - d = a0 * det; - result_ty = -(b * tx + d * ty); - tx = -(a * tx + c * ty); - ty = result_ty; + var newa:Number = d * det; + d = a * det; + a = newa; + b *= -det; + c *= -det; + + var newtx:Number = - a * tx - c * ty; + ty = - b * tx - d * ty; + tx = newtx; } + return this; } - public function identity():void + /** + * Resets the matrix to the default values. + * Returns the matrix so the methods can be chained. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function identity():Matrix { a = d = 1; - b = c = 0.0; - tx = ty = 0.0; + b = c = tx = ty = 0; + return this; } - public function createBox(scaleX:Number, scaleY:Number, rotation:Number = 0, tx:Number = 0, ty:Number = 0):void + /** + * Rotates the Matrix by the specified value. + * Returns the matrix so the methods can be chained. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function rotate(angle:Number):Matrix { - var u:Number = Math.cos(rotation); - var v:Number = Math.sin(rotation); - a = u * scaleX; - b = v * scaleY; - c = -v * scaleX; - d = u * scaleY; - tx = tx; - ty = ty; - } + var cos:Number = Math.cos(angle); + var sin:Number = Math.sin(angle); + + var newa:Number = a * cos - b * sin; + b = a * sin + b * cos; + a = newa; - public function createGradientBox(width:Number, height:Number, rotation:Number = 0, tx:Number = 0, ty:Number = 0):void - { - createBox(width / 1638.4, height / 1638.4, rotation, tx + width / 2, ty + height / 2); - } + var newc:Number = c * cos - d * sin; + d = c * sin + d * cos; + c = newc; - public function rotate(angle:Number):void - { - var u:Number = Math.cos(angle); - var v:Number = Math.sin(angle); - var result_a:Number = u * a - v * b; - var result_b:Number = v * a + u * b; - var result_c:Number = u * c - v * d; - var result_d:Number = v * c + u * d; - var result_tx:Number = u * tx - v * ty; - var result_ty:Number = v * tx + u * ty; - a = result_a; - b = result_b; - c = result_c; - d = result_d; - tx = result_tx; - ty = result_ty; + var newtx:Number = tx * cos - ty * sin; + ty = tx * sin + ty * cos; + tx = newtx; + return this; } - public function translate(dx:Number, dy:Number):void + /** + * Moves the Matrix by the specified amount + * Returns the matrix so the methods can be chained. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function translate(x:Number, y:Number):Matrix { - tx = tx + dx; - ty = ty + dy; + tx += x; + ty += y; + return this; } - public function scale(sx:Number, sy:Number):void + /** + * Scales the Matrix by the specified amount. + * Returns the matrix so the methods can be chained. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function scale(x:Number, y:Number):Matrix { - a = a * sx; - b = b * sy; - c = c * sx; - d = d * sy; - tx = tx * sx; - ty = ty * sy; + a *= x; + b *= y; + c *= x; + d *= y; + tx *= x; + ty *= y; + return this; } + /** + * Uses the Matrix to transform the point without the translation values. + * Returns a new Point. The original Point is unchanged. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ public function deltaTransformPoint(point:Point):Point { return new Point(a * point.x + c * point.y, d * point.y + b * point.x); } + /** + * Uses the Matrix to transform the point including the translation values. + * Returns a new Point. The original Point is unchanged. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ public function transformPoint(point:Point):Point { return new Point(a * point.x + c * point.y + tx, d * point.y + b * point.x + ty); } + /** + * Returns a string representation of the Matrix. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ public function toString():String { return "(a=" + a + ", b=" + b + ", c=" + c + ", d=" + d + ", tx=" + tx + ", ty=" + ty + ")"; } - public function copyFrom(sourceMatrix:Matrix):void - { - a = sourceMatrix.a; - b = sourceMatrix.b; - c = sourceMatrix.c; - d = sourceMatrix.d; - tx = sourceMatrix.tx; - ty = sourceMatrix.ty; - } - - public function setTo(aa:Number, ba:Number, ca:Number, da:Number, txa:Number, tya:Number):void - { - a = aa; - b = ba; - c = ca; - d = da; - tx = txa; - ty = tya; - } - - public function copyRowTo(row:uint, vector3D:Vector3D):void + /** + * Copies the values from another Matrix. + * Returns the matrix so the methods can be chained. + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion FlexJS 0.7 + */ + public function copyFrom(source:Matrix):Matrix { - switch (row) - { - case 0: - break; - case 1: - vector3D.x = b; - vector3D.y = d; - vector3D.z = ty; - break; - case 2: - case 3: - vector3D.x = 0; - vector3D.y = 0; - vector3D.z = 1; - break; - default: - vector3D.x = a; - vector3D.y = c; - vector3D.z = tx; - } - } - - public function copyColumnTo(column:uint, vector3D:Vector3D):void - { - switch (column) - { - case 0: - break; - case 1: - vector3D.x = c; - vector3D.y = d; - vector3D.z = 0; - break; - case 2: - case 3: - vector3D.x = tx; - vector3D.y = ty; - vector3D.z = 1; - break; - default: - vector3D.x = a; - vector3D.y = b; - vector3D.z = 0; - } - } - - public function copyRowFrom(row:uint, vector3D:Vector3D):void - { - switch (row) - { - case 0: - break; - case 1: - case 2: - b = vector3D.x; - d = vector3D.y; - ty = vector3D.z; - break; - default: - a = vector3D.x; - c = vector3D.y; - tx = vector3D.z; - } + a = source.a; + b = source.b; + c = source.c; + d = source.d; + tx = source.tx; + ty = source.ty; + return this; } - public function copyColumnFrom(column:uint, vector3D:Vector3D):void - { - switch (column) - { - case 0: - break; - case 1: - case 2: - b = vector3D.x; - d = vector3D.y; - ty = vector3D.z; - break; - default: - a = vector3D.x; - c = vector3D.y; - tx = vector3D.z; - } - } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/MeagerMatrix.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/MeagerMatrix.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/MeagerMatrix.as deleted file mode 100644 index 595b64d..0000000 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/MeagerMatrix.as +++ /dev/null @@ -1,106 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.geom -{ - - public class MeagerMatrix implements IMatrix - { - public function MeagerMatrix(a:Number = 1, b:Number = 0, c:Number = 0, d:Number = 1, tx:Number = 0, ty:Number = 0) - { - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - - } - private var _a:Number; - private var _b:Number; - private var _c:Number; - private var _d:Number; - private var _tx:Number; - private var _ty:Number; - - public function get ty():Number - { - return _ty; - } - - public function set ty(value:Number):void - { - _ty = value; - } - - public function get tx():Number - { - return _tx; - } - - public function set tx(value:Number):void - { - _tx = value; - } - - public function get d():Number - { - return _d; - } - - public function set d(value:Number):void - { - _d = value; - } - - public function get c():Number - { - return _c; - } - - public function set c(value:Number):void - { - _c = value; - } - - public function get b():Number - { - return _b; - } - - public function set b(value:Number):void - { - _b = value; - } - - public function get a():Number - { - return _a; - } - - public function set a(value:Number):void - { - _a = value; - } - - public function clone():IMatrix - { - return new MeagerMatrix(a, b, c, d, tx, ty); - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Vector3D.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Vector3D.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Vector3D.as deleted file mode 100644 index b661d97..0000000 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/geom/Vector3D.as +++ /dev/null @@ -1,208 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////// -// -// Licensed to the Apache Software Foundation (ASF) under one or more -// contributor license agreements. See the NOTICE file distributed with -// this work for additional information regarding copyright ownership. -// The ASF licenses this file to You under the Apache License, Version 2.0 -// (the "License"); you may not use this file except in compliance with -// the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//////////////////////////////////////////////////////////////////////////////// -package org.apache.flex.geom -{ - COMPILE::SWF - { - import flash.geom.Vector3D; - } - - COMPILE::SWF - public class Vector3D extends flash.geom.Vector3D - { - public function Vector3D(x:Number = 0.0, y:Number = 0.0, z:Number = 0.0, w:Number = 0.0) - { - super(x,y,z,w); - } - override public function clone():flash.geom.Vector3D - { - return new org.apache.flex.geom.Vector3D(this.x,this.y,this.z,this.w); - } - - } - - COMPILE::JS - public class Vector3D - { - public static const X_AXIS:Vector3D = new Vector3D(1,0,0); - public static const Y_AXIS:Vector3D = new Vector3D(0,1,0); - public static const Z_AXIS:Vector3D = new Vector3D(0,0,1); - public var x:Number; - public var y:Number; - public var z:Number; - public var w:Number; - public function Vector3D(x:Number = 0.0, y:Number = 0.0, z:Number = 0.0, w:Number = 0.0) - { - this.x = x; - this.y = y; - this.z = z; - this.w = w; - } - - public static function angleBetween(a:Vector3D, b:Vector3D) : Number - { - var dot:Number = a.x * b.x + a.y * b.y + a.z * b.z; - var al:Number = a.length; - var bl:Number = b.length; - dot = dot / (al * bl); - return Math.acos(dot); - } - - public static function distance(pt1:Vector3D, pt2:Vector3D) : Number - { - return pt1.subtract(pt2).length; - } - - public function clone():Vector3D - { - return new Vector3D(this.x,this.y,this.z,this.w); - } - - public function dotProduct(a:Vector3D):Number - { - return this.x * a.x + this.y * a.y + this.z * a.z; - } - - public function crossProduct(a:Vector3D) : Vector3D - { - return new Vector3D(this.y * a.z - this.z * a.y,this.z * a.x - this.x * a.z,this.x * a.y - this.y * a.x,1); - } - - public function get length() : Number - { - var r:Number = this.x * this.x + this.y * this.y + this.z * this.z; - if(r <= 0) - { - return 0; - } - return Math.sqrt(r); - } - - public function get lengthSquared() : Number - { - return this.x * this.x + this.y * this.y + this.z * this.z; - } - - public function normalize() : Number - { - var len:Number = this.length; - var lenInv:Number = len != 0?1 / len:0; - this.x = this.x * lenInv; - this.y = this.y * lenInv; - this.z = this.z * lenInv; - return len; - } - - public function scaleBy(s:Number) : void - { - this.x = this.x * s; - this.y = this.y * s; - this.z = this.z * s; - } - - public function incrementBy(a:Vector3D) : void - { - this.x = this.x + a.x; - this.y = this.y + a.y; - this.z = this.z + a.z; - } - - public function decrementBy(a:Vector3D) : void - { - this.x = this.x - a.x; - this.y = this.y - a.y; - this.z = this.z - a.z; - } - - public function add(a:Vector3D) : Vector3D - { - return new Vector3D(this.x + a.x,this.y + a.y,this.z + a.z); - } - - public function subtract(a:Vector3D) : Vector3D - { - return new Vector3D(this.x - a.x,this.y - a.y,this.z - a.z); - } - - public function negate() : void - { - this.x = -this.x; - this.y = -this.y; - this.z = -this.z; - } - - public function equals(toCompare:Vector3D, allFour:Boolean = false) : Boolean - { - return this.x == toCompare.x && this.y == toCompare.y && this.z == toCompare.z && (allFour?this.w == toCompare.w:true); - } - - public function nearEquals(toCompare:Vector3D, tolerance:Number, allFour:Boolean = false) : Boolean - { - var diff:Number = this.x - toCompare.x; - diff = diff < 0?0 - diff:diff; - var goodEnough:Boolean = diff < tolerance; - if(goodEnough) - { - diff = this.y - toCompare.y; - diff = diff < 0?0 - diff:diff; - goodEnough = diff < tolerance; - if(goodEnough) - { - diff = this.z - toCompare.z; - diff = diff < 0?0 - diff:diff; - goodEnough = diff < tolerance; - if(goodEnough && allFour) - { - diff = this.w = toCompare.w; - diff = diff < 0?0 - diff:diff; - goodEnough = diff < tolerance; - } - } - } - return goodEnough; - } - - public function project() : void - { - var tRecip:Number = 1 / this.w; - this.x = this.x * tRecip; - this.y = this.y * tRecip; - this.z = this.z * tRecip; - } - - public function toString() : String - { - return "Vector3D(" + this.x + ", " + this.y + ", " + this.z + ")"; - } - - public function copyFrom(sourceVector3D:Vector3D) : void - { - this.x = sourceVector3D.x; - this.y = sourceVector3D.y; - this.z = sourceVector3D.z; - } - - public function setTo(xa:Number, ya:Number, za:Number) : void - { - this.x = xa; - this.y = ya; - this.z = za; - } - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/518f7173/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as index e37f4df..19fe765 100644 --- a/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as +++ b/frameworks/projects/Graphics/src/main/flex/org/apache/flex/svg/TransformBead.as @@ -24,7 +24,7 @@ package org.apache.flex.svg import org.apache.flex.core.ITransformModel; import org.apache.flex.core.TransformModel; import org.apache.flex.events.Event; - import org.apache.flex.geom.IMatrix; + import org.apache.flex.geom.Matrix; COMPILE::SWF { import flash.display.Sprite; @@ -67,7 +67,7 @@ package org.apache.flex.svg public function transform():void { var element:Sprite = host.transformElement as Sprite; - var fjsm:org.apache.flex.geom.IMatrix = transformModel.matrix; + var fjsm:org.apache.flex.geom.Matrix = transformModel.matrix; var flashMatrix:flash.geom.Matrix = new flash.geom.Matrix(fjsm.a, fjsm.b, fjsm.c, fjsm.d, fjsm.tx, fjsm.ty); element.transform.matrix = flashMatrix; } @@ -79,7 +79,7 @@ package org.apache.flex.svg { var element:org.apache.flex.core.WrappedHTMLElement = host.transformElement; (element.parentNode as HTMLElement).setAttribute("overflow", "visible"); - var fjsm:org.apache.flex.geom.IMatrix = transformModel.matrix; + var fjsm:org.apache.flex.geom.Matrix = transformModel.matrix; var matrixArray:Array = [fjsm.a , fjsm.b, fjsm.c, fjsm.d, fjsm.tx, fjsm.ty]; var transformStr:String = "matrix(" + matrixArray.join(",") + ")"; element.setAttribute("transform", transformStr);
