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


Java Transform3D.AFFINE属性代码示例

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


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

示例1: setTransform

/**
 * Sets the camera transform to <code>xform</code>.
 * 
 * @param xform
 *            a congruent transform with a positive determinant. (In other words, xform must not scale or transform to a left-handed coordinate system.)
 * @throws BadTransformException
 *             if xform is not congruent or has a negative determinant
 */
public void setTransform( Transform3D xform )
{
	if( xform.getBestType( ) == Transform3D.AFFINE )
	{
		throw new BadTransformException( "xform must be congruent" );
	}
	if( !xform.getDeterminantSign( ) )
	{
		throw new BadTransformException( "xform must have a positive determinant" );
	}
	
	this.xform.set( xform );
	invXformUpToDate = false;
	rotationUpToDate = false;
	locationUpToDate = false;
	panTiltRollUpToDate = false;
	vectorsUpToDate = false;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:26,代码来源:CameraPosition.java

示例2: transform

public void transform( Transform3D xform2 )
{
	if( xform.getBestType( ) == Transform3D.AFFINE )
	{
		throw new BadTransformException( "xform must be congruent" );
	}
	if( !xform.getDeterminantSign( ) )
	{
		throw new BadTransformException( "xform must have a positive determinant" );
	}
	
	xform.mul( xform2 , xform );
	invXformUpToDate = false;
	rotationUpToDate = false;
	locationUpToDate = false;
	panTiltRollUpToDate = false;
	vectorsUpToDate = false;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:18,代码来源:CameraPosition.java

示例3: getRollTiltPan

/**
 * Extracts the pan, tilt, and roll components of a transform. More specifically, it calculates the pan, tilt, and roll angles that transform the identity
 * orientation to the same orientation that the given transform does. <br>
 * <br>
 * Pan, tilt, and roll are defined as rotations about the Z, Y, and X axes respectively, and they are defined to occur in the order <b>roll first, then
 * tilt, then pan</b>. <br>
 * Thus the transform <code>rotZ(pan)*rotY(tilt)*rotX(roll)</code> rotates to the same orientation as the given transform does. <br>
 * <br>
 * If the tilt is +/- 90 degrees (i.e. tilting forward to point straight +Z or -Z), pan and roll become gimbal locked. In this case, pan is used to perform
 * the "roll" around the Z axis instead of actual roll, because we are usually operating on a camera with zero roll, and we want it to tilt away from
 * vertical to the same pan it began with. However, this means that if you tilt a camera with nonzero roll up 90 degrees, its roll will turn into pan, and
 * if you tilt it back down using pan/tilt/roll values obtained from this method it will tilt down to a different pan.
 * 
 * @param xform
 *            the transform to analyze. It must be congruent and right-handed - that is it must not scale anisotropically and it must have a positive
 *            determinant.
 * @param result
 *            the (roll, tilt, pan) angle result vector
 * @return <code>result</code>
 */
public Vector3f getRollTiltPan( Transform3D xform , Vector3f result )
{
	if( xform.getBestType( ) == Transform3D.AFFINE )
	{
		throw new BadTransformException( "xform must be congruent" );
	}
	if( !xform.getDeterminantSign( ) )
	{
		throw new BadTransformException( "xform must have a positive determinant" );
	}
	
	x1.set( xform );
	v1.set( 0 , 0 , 0 );
	x1.setTranslation( v1 );
	
	// calculate pan:
	// F' = Qzyx * F
	// pan = atan2(F'.y, F'.x)
	// UNLESS F' points straight +Z or -Z:
	// R' = Qzyx * R
	// pan = atan2(R'.y, R'.x) - PI / 2
	v1.set( 1 , 0 , 0 );
	x1.transform( v1 );
	if( v1.x == 0 && v1.y == 0 )
	{
		v1.set( 0 , 1 , 0 );
		x1.transform( v1 );
		result.z = (float) Math.atan2( v1.y , v1.x ) - (float) Math.PI / 2;
	}
	else
	{
		result.z = (float) Math.atan2( v1.y , v1.x );
	}
	
	// de-pan the transform
	// Qyx = Q-zQzyx
	x2.rotZ( -result.z );
	x1.mul( x2 , x1 );
	
	// calculate tilt:
	// F' = Qyx * F
	// tilt = atan2(-F'.z, F'.x)
	v1.set( 1 , 0 , 0 );
	x1.transform( v1 );
	result.y = (float) Math.atan2( -v1.z , v1.x );
	
	// de-tilt the transform
	// Qx = Q-yQyx
	x2.rotY( -result.y );
	x1.mul( x2 , x1 );
	
	// calculate roll:
	// R' = Qx * R
	// roll = atan2(R'.z, R'.y)
	v1.set( 0 , 1 , 0 );
	x1.transform( v1 );
	result.x = ( float ) Math.atan2( v1.z , v1.y );
	
	return result;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:80,代码来源:TransformComputer3f.java

示例4: getRollTiltPan

/**
 * Extracts the pan, tilt, and roll components of a transform. More specifically, it calculates the pan, tilt, and roll angles that transform the identity
 * orientation to the same orientation that the given transform does. <br>
 * <br>
 * Pan, tilt, and roll are defined as rotations about the Z, Y, and X axes respectively, and they are defined to occur in the order <b>roll first, then
 * tilt, then pan</b>. <br>
 * Thus the transform <code>rotZ(pan)*rotY(tilt)*rotX(roll)</code> rotates to the same orientation as the given transform does. <br>
 * <br>
 * If the tilt is +/- 90 degrees (i.e. tilting forward to point straight +Z or -Z), pan and roll become gimbal locked. In this case, pan is used to perform
 * the "roll" around the Z axis instead of actual roll, because we are usually operating on a camera with zero roll, and we want it to tilt away from
 * vertical to the same pan it began with. However, this means that if you tilt a camera with nonzero roll up 90 degrees, its roll will turn into pan, and
 * if you tilt it back down using pan/tilt/roll values obtained from this method it will tilt down to a different pan.
 * 
 * @param xform
 *            the transform to analyze. It must be congruent and right-handed - that is it must not scale anisotropically and it must have a positive
 *            determinant.
 * @param result
 *            the (roll, tilt, pan) angle result vector
 * @return <code>result</code>
 */
public Vector3d getRollTiltPan( Transform3D xform , Vector3d result )
{
	if( xform.getBestType( ) == Transform3D.AFFINE )
	{
		throw new BadTransformException( "xform must be congruent" );
	}
	if( !xform.getDeterminantSign( ) )
	{
		throw new BadTransformException( "xform must have a positive determinant" );
	}
	
	x1.set( xform );
	v1.set( 0 , 0 , 0 );
	x1.setTranslation( v1 );
	
	// calculate pan:
	// F' = Qzyx * F
	// pan = atan2(F'.y, F'.x)
	// UNLESS F' points straight +Z or -Z:
	// R' = Qzyx * R
	// pan = atan2(R'.y, R'.x) - PI / 2
	v1.set( 1 , 0 , 0 );
	x1.transform( v1 );
	if( v1.x == 0 && v1.y == 0 )
	{
		v1.set( 0 , 1 , 0 );
		x1.transform( v1 );
		result.z = Math.atan2( v1.y , v1.x ) - Math.PI / 2;
	}
	else
	{
		result.z = Math.atan2( v1.y , v1.x );
	}
	
	// de-pan the transform
	// Qyx = Q-zQzyx
	x2.rotZ( -result.z );
	x1.mul( x2 , x1 );
	
	// calculate tilt:
	// F' = Qyx * F
	// tilt = atan2(-F'.z, F'.x)
	v1.set( 1 , 0 , 0 );
	x1.transform( v1 );
	result.y = Math.atan2( -v1.z , v1.x );
	
	// de-tilt the transform
	// Qx = Q-yQyx
	x2.rotY( -result.y );
	x1.mul( x2 , x1 );
	
	// calculate roll:
	// R' = Qx * R
	// roll = atan2(R'.z, R'.y)
	v1.set( 0 , 1 , 0 );
	x1.transform( v1 );
	result.x = Math.atan2( v1.z , v1.y );
	
	return result;
}
 
开发者ID:jedwards1211,项目名称:breakout,代码行数:80,代码来源:TransformComputer3d.java


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