Java Code Examples for mpicbg.models.AffineModel3D#set()

The following examples show how to use mpicbg.models.AffineModel3D#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GlobalOpt.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public static void main( String[] args )
{
	// multiple keys can map to the same value
	final HashMap< ViewId, Tile< AffineModel3D > > map = new HashMap<ViewId, Tile<AffineModel3D>>();
	
	final AffineModel3D m1 = new AffineModel3D();
	final AffineModel3D m2 = new AffineModel3D();

	final Tile< AffineModel3D > tile1 = new Tile<AffineModel3D>( m1 );
	final Tile< AffineModel3D > tile2 = new Tile<AffineModel3D>( m2 );
	
	final ViewId v11 = new ViewId( 1, 1 );
	final ViewId v21 = new ViewId( 2, 1 );
	final ViewId v12 = new ViewId( 1, 2 );
	final ViewId v22 = new ViewId( 2, 2 );
	
	map.put( v11, tile1 );
	map.put( v21, tile2 );

	map.put( v12, tile1 );
	map.put( v22, tile2 );
	
	m1.set( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 );
	m2.set( 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2 );

	System.out.println( map.get( v11 ).getModel() );
	System.out.println( map.get( v21 ).getModel() );
	
	System.out.println( map.get( v12 ).getModel() );
	System.out.println( map.get( v22 ).getModel() );		
}
 
Example 2
Source File: TransformUtils.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public static AffineModel3D getAffineModel3D( Transform3D transform )
{
	final double[] m = new double[16];
	transform.get( m );

	AffineModel3D model = new AffineModel3D();
	model.set( m[0], m[1], m[2], m[3], m[4], m[5], m[6], m[7], m[8], m[9], m[10], m[11] );

	return model;
}
 
Example 3
Source File: TransformUtils.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
public static void main( String[] args )
{
	AffineModel3D m = new AffineModel3D();
	m.set( 0.87912226f, 0.425894f, 0.21391234f, -169.3024f, -0.47269103f, 0.836501f, 0.2771809f, 42.627777f, -0.0608882f, -0.34479034f, 0.93670285f, 246.59639f );
	Transform3D t = TransformUtils.getTransform3D1( m );
	Vector3d s = new Vector3d();
	t.getScale( s );
	System.out.println( s );
}
 
Example 4
Source File: IOFunctions.java    From SPIM_Registration with GNU General Public License v2.0 4 votes vote down vote up
public static AffineModel3D getModelFromFile( final File file )
{
	final AffineModel3D model = new AffineModel3D();
			
	try 
	{
		final BufferedReader in = TextFileAccess.openFileRead( file );
		
		// get 12 entry double array
		final double m[] = new double[ 12 ];
		
		// the default if nothing is written
		String savedModel = "AffineModel3D";

		while ( in.ready() )
		{
			String entry = in.readLine().trim();
			
			if (entry.startsWith("m00:"))
				m[ 0 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m01:"))
				m[ 1 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m02:"))
				m[ 2 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m03:"))
				m[ 3 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m10:"))
				m[ 4 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m11:"))
				m[ 5 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m12:"))
				m[ 6 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m13:"))
				m[ 7 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m20:"))
				m[ 8 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m21:"))
				m[ 9 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m22:"))
				m[ 10 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("m23:"))
				m[ 11 ] = Double.parseDouble(entry.substring(5, entry.length()));
			else if (entry.startsWith("model:"))
				savedModel = entry.substring(7, entry.length()).trim();
		}

		in.close();
		
		if ( !savedModel.equals("AffineModel3D") )
			IOFunctions.println( "Warning: Loading a '" + savedModel + "' as AffineModel3D!" );
			
		model.set( m[ 0 ], m[ 1 ], m[ 2 ], m[ 3 ], m[ 4 ], m[ 5 ], m[ 6 ], m[ 7 ], m[ 8 ], m[ 9 ], m[ 10 ], m[ 11 ] );
		
	} 
	catch (IOException e) 
	{
		IJ.log( "Cannot find file: " + file.getAbsolutePath() + ": " + e );
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
	
	return model;
}