当前位置: 首页>>代码示例>>Java>>正文


Java LinAlgHelpers.scale方法代码示例

本文整理汇总了Java中net.imglib2.util.LinAlgHelpers.scale方法的典型用法代码示例。如果您正苦于以下问题:Java LinAlgHelpers.scale方法的具体用法?Java LinAlgHelpers.scale怎么用?Java LinAlgHelpers.scale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.imglib2.util.LinAlgHelpers的用法示例。


在下文中一共展示了LinAlgHelpers.scale方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: get

import net.imglib2.util.LinAlgHelpers; //导入方法依赖的package包/类
@Override
public AffineTransform3D get( final double t )
{
	final double[] qDiffCurrent = new double[ 4 ];
	final double[] qCurrent = new double[ 4 ];
	LinAlgHelpers.quaternionPower( qDiff, t, qDiffCurrent );
	LinAlgHelpers.quaternionMultiply( qStart, qDiffCurrent, qCurrent );

	final double scaleCurrent = scaleStart + t * scaleDiff;

	final double[] xg0Current = new double[ 3 ];
	final double[] tCurrent = new double[ 3 ];
	LinAlgHelpers.scale( xg0Diff, -( t * scaleEnd / scaleCurrent ), xg0Current );
	for ( int r = 0; r < 3; ++r )
		xg0Current[ r ] -= xg0Start[ r ];
	final double[][] Rcurrent = new double[ 3 ][ 3 ];
	LinAlgHelpers.quaternionToR( qCurrent, Rcurrent );
	LinAlgHelpers.mult( Rcurrent, xg0Current, tCurrent );

	final double[][] m = new double[ 3 ][ 4 ];
	for ( int r = 0; r < 3; ++r )
	{
		for ( int c = 0; c < 3; ++c )
			m[ r ][ c ] = scaleCurrent * Rcurrent[ r ][ c ];
		m[ r ][ 3 ] = scaleCurrent * tCurrent[ r ];
	}

	final AffineTransform3D transform = new AffineTransform3D();
	transform.set( m );
	return transform;
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:32,代码来源:SimilarityTransformAnimator3D.java

示例2: get

import net.imglib2.util.LinAlgHelpers; //导入方法依赖的package包/类
@Override
public AffineTransform3D get( final double t )
{

	final double scaleCurrent = scaleStart + t * scaleDiff;
	final double angleCurrent = startAngle + t * totalAngle;
	
	final double[] xg0Current = new double[ 3 ];
	final double[] tCurrent = new double[ 3 ];
	LinAlgHelpers.scale( xg0Diff, -( t * scaleEnd / scaleCurrent ), xg0Current );
	for ( int r = 0; r < 3; ++r )
		xg0Current[ r ] -= xg0Start[ r ];
	
	double[][] Rcurrent = Rotation2DHelpers.rotationToMatrix( angleCurrent );
	LinAlgHelpers.mult( Rcurrent, xg0Current, tCurrent );
	

	final double[][] m = new double[ 3 ][ 4 ];
	for ( int r = 0; r < 3; ++r )
	{
		for ( int c = 0; c < 3; ++c )
			m[ r ][ c ] = scaleCurrent * Rcurrent[ r ][ c ];
		m[ r ][ 3 ] = scaleCurrent * tCurrent[ r ];
	}
	
	final AffineTransform3D transform = new AffineTransform3D();
	transform.set( m );
	transform.set( 1.0, 2, 2 );
	
	return transform;
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:32,代码来源:SimilarityTransformAnimator2D.java

示例3: SimilarityTransformAnimator3D

import net.imglib2.util.LinAlgHelpers; //导入方法依赖的package包/类
public SimilarityTransformAnimator3D( final AffineTransform3D transformStart, final AffineTransform3D transformEnd, final double cX, final double cY, final long duration )
{
	super( duration );
	this.cX = cX;
	this.cY = cY;

	qStart = new double[ 4 ];
	final double[] qStartInv = new double[ 4 ];
	final double[] qEnd = new double[ 4 ];
	final double[] qEndInv = new double[ 4 ];
	qDiff = new double[ 4 ];
	Affine3DHelpers.extractRotation( transformStart, qStart );
	LinAlgHelpers.quaternionInvert( qStart, qStartInv );

	Affine3DHelpers.extractRotation( transformEnd, qEnd );
	LinAlgHelpers.quaternionInvert( qEnd, qEndInv );

	LinAlgHelpers.quaternionMultiply( qStartInv, qEnd, qDiff );
	if ( qDiff[ 0 ] < 0 )
		LinAlgHelpers.scale( qDiff, -1, qDiff );

	scaleStart = Affine3DHelpers.extractScale( transformStart, 0 );
	scaleEnd = Affine3DHelpers.extractScale( transformEnd, 0 );
	scaleDiff = scaleEnd - scaleStart;

	final double[] tStart = new double[ 3 ];
	final double[] tEnd = new double[ 3 ];
	for ( int d = 0; d < 3; ++d )
	{
		tStart[ d ] = transformStart.get( d, 3 ) / scaleStart;
		tEnd[ d ] = transformEnd.get( d, 3 ) / scaleEnd;
	}

	xg0Start = new double[3];
	final double[] xg0End = new double[3];
	xg0Diff = new double[3];

	final double[][] R = new double[ 3 ][ 3 ];
	LinAlgHelpers.quaternionToR( qStartInv, R );
	LinAlgHelpers.mult( R, tStart, xg0Start );
	LinAlgHelpers.scale( xg0Start, -1, xg0Start );
	LinAlgHelpers.quaternionToR( qEndInv, R );
	LinAlgHelpers.mult( R, tEnd, xg0End );
	LinAlgHelpers.scale( xg0End, -1, xg0End );
	LinAlgHelpers.subtract( xg0End, xg0Start, xg0Diff );
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:47,代码来源:SimilarityTransformAnimator3D.java

示例4: SimilarityTransformAnimator2D

import net.imglib2.util.LinAlgHelpers; //导入方法依赖的package包/类
public SimilarityTransformAnimator2D( final AffineTransform3D transformStart, final AffineTransform3D transformEnd, final double cX, final double cY, final long duration )
{
	super( duration );
	
	startAngle = Rotation2DHelpers.extractRotation( transformStart );
	final double endAngle = Rotation2DHelpers.extractRotation( transformEnd );
	
	scaleStart = Rotation2DHelpers.extractScale( transformStart, 0 );
	scaleEnd   = Rotation2DHelpers.extractScale( transformEnd, 0 );
	scaleDiff = scaleEnd - scaleStart;
	
	totalAngle = Rotation2DHelpers.shorterAngleBetweenRotations( startAngle, endAngle );
	
	cosInvAngleStart = Math.cos( -startAngle );
	sinInvAngleStart = Math.sin( -startAngle );
	
	cosInvAngleEnd = Math.cos( -endAngle );
	sinInvAngleEnd = Math.sin( -endAngle );
	
	final double[] tStart = new double[ 3 ];
	final double[] tEnd = new double[ 3 ];
	for ( int d = 0; d < 3; ++d )
	{
		tStart[ d ] = transformStart.get( d, 3 ) / scaleStart;
		tEnd[ d ] = transformEnd.get( d, 3 ) / scaleEnd;
	}
	
	xg0Start = new double[3];
	final double[] xg0End = new double[3];
	xg0Diff = new double[3];
	
	// inverse rotate scaled starting 
	Rotation2DHelpers.cosSinMult( tStart, xg0Start, cosInvAngleStart, sinInvAngleStart );
	LinAlgHelpers.scale( xg0Start, -1, xg0Start );
		
	Rotation2DHelpers.cosSinMult( tEnd, xg0End, cosInvAngleEnd, sinInvAngleEnd );
	LinAlgHelpers.scale( xg0End, -1, xg0End );
	
	LinAlgHelpers.subtract( xg0End, xg0Start, xg0Diff );
	
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:42,代码来源:SimilarityTransformAnimator2D.java

示例5: main

import net.imglib2.util.LinAlgHelpers; //导入方法依赖的package包/类
public static void main( final String[] args )
{
	final int w = 400;
	final int h = 400;
	final int nPoints = 100000;
	final Random rand = new Random( 123124 );

	final ArrayList< Point > points = new ArrayList< Point >();
	for ( int i = 0; i < nPoints; ++i )
	{
		final long x = rand.nextInt( w );
		final long y = rand.nextInt( h );
		points.add( new Point( x, y ) );
	}

	final double[][] planes = new double[ 5 ][ 3 ]; // unit normal x, y; d

	double[] plane = planes[ 0 ];
	plane[ 0 ] = 1;
	plane[ 1 ] = 1;
	LinAlgHelpers.scale( plane, 1.0 / LinAlgHelpers.length( plane ), plane );
	plane[ 2 ] = 230;

	plane = planes[ 1 ];
	plane[ 0 ] = -1;
	plane[ 1 ] = 1;
	LinAlgHelpers.scale( plane, 1.0 / LinAlgHelpers.length( plane ), plane );
	plane[ 2 ] = -30;

	plane = planes[ 2 ];
	plane[ 0 ] = 0.1;
	plane[ 1 ] = -1;
	LinAlgHelpers.scale( plane, 1.0 / LinAlgHelpers.length( plane ), plane );
	plane[ 2 ] = -230;

	plane = planes[ 3 ];
	plane[ 0 ] = -0.5;
	plane[ 1 ] = -1;
	LinAlgHelpers.scale( plane, 1.0 / LinAlgHelpers.length( plane ), plane );
	plane[ 2 ] = -290;

	plane = planes[ 4 ];
	plane[ 0 ] = -1;
	plane[ 1 ] = 0.1;
	LinAlgHelpers.scale( plane, 1.0 / LinAlgHelpers.length( plane ), plane );
	plane[ 2 ] = -200;

	System.out.println( "partitioning list of points:" );
	BenchmarkHelper.benchmarkAndPrint( 20, false, new Runnable()
	{
		@Override
		public void run()
		{
			for ( int i = 0; i < 500; ++i )
			{
				final ArrayList< Point >[] insideoutside = getInsidePoints( points, planes );
				if ( insideoutside[ 0 ].size() > 1000000 )
					System.out.println( "bla" );
			}
		}
	} );

	System.out.println( "partitioning kdtree of points:" );
	final KDTree< Point > kdtree = new KDTree< Point >( points, points );
	final ClipConvexPolytopeKDTree< Point > clipper = new ClipConvexPolytopeKDTree< Point >( kdtree );
	BenchmarkHelper.benchmarkAndPrint( 20, false, new Runnable()
	{
		@Override
		public void run()
		{
			for ( int i = 0; i < 500; ++i )
			{
				clipper.clip( planes );
			}
		}
	} );
}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:78,代码来源:ClipConvexPolytopeKDTreeBenchmark.java


注:本文中的net.imglib2.util.LinAlgHelpers.scale方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。