import 'mocha' ; import * as assert from 'assert' ; import PerspectiveTransform from './../../../core/common/PerspectiveTransform' ; author Sean Owen
  describe ( "PerspectiveTransformTestCase" , ( ) => { const EPSILON = 1.0E-4 ; it ( "testSquareToQuadrilateral" , ( ) => { const pt = PerspectiveTransform . squareToQuadrilateral ( 2.0 , 3.0 , 10.0 , 4.0 , 16.0 , 15.0 , 4.0 , 9.0 ) ; assertPointEquals ( 2.0 , 3.0 , 0.0 , 0.0 , pt ) ; assertPointEquals ( 10.0 , 4.0 , 1.0 , 0.0 , pt ) ; assertPointEquals ( 4.0 , 9.0 , 0.0 , 1.0 , pt ) ; assertPointEquals ( 16.0 , 15.0 , 1.0 , 1.0 , pt ) ; assertPointEquals ( 6.535211 , 6.8873234 , 0.5 , 0.5 , pt ) ; assertPointEquals ( 48.0 , 42.42857 , 1.5 , 1.5 , pt ) ; } ) ; it ( "testQuadrilateralToQuadrilateral" , ( ) => { const pt = PerspectiveTransform . quadrilateralToQuadrilateral ( 2.0 , 3.0 , 10.0 , 4.0 , 16.0 , 15.0 , 4.0 , 9.0 , 103.0 , 110.0 , 300.0 , 120.0 , 290.0 , 270.0 , 150.0 , 280.0 ) ; assertPointEquals ( 103.0 , 110.0 , 2.0 , 3.0 , pt ) ; assertPointEquals ( 300.0 , 120.0 , 10.0 , 4.0 , pt ) ; assertPointEquals ( 290.0 , 270.0 , 16.0 , 15.0 , pt ) ; assertPointEquals ( 150.0 , 280.0 , 4.0 , 9.0 , pt ) ; assertPointEquals ( 7.1516876 , - 64.60185 , 0.5 , 0.5 , pt ) ; assertPointEquals ( 328.09116 , 334.16385 , 50.0 , 50.0 , pt ) ; } ) ; function assertPointEquals ( expectedX , expectedY , sourceX , sourceY , pt ) { const points = Float32Array . from ( [ sourceX , sourceY ] ) ; pt . transformPoints ( points ) ; assert . strictEqual ( Math . abs ( expectedX - points [ 0 ] ) < EPSILON , true ) ; assert . strictEqual ( Math . abs ( expectedY - points [ 1 ] ) < EPSILON , true ) ; } } ) ;