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


Java Vector3d.set方法代码示例

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


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

示例1: restorativeForceAndDistance

import javax.vecmath.Vector3d; //导入方法依赖的package包/类
public static double restorativeForceAndDistance(Vector3d a, Vector3d b, Vector3d vab) {
  
  // a and b will be set to the force on the atom when r > r0
  
  vab.sub(a, b);
  double rab = vab.length();
  if (rab < 0.1) {// atoms are too close to each other
    randomizeUnitVector(vab);
    rab = 0.1;
  }
  vab.normalize();
  a.set(vab);
  a.scale(-1); // -drab/da
  b.set(vab); // -drab/db

  return rab;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:18,代码来源:Util.java

示例2: randomizeUnitVector

import javax.vecmath.Vector3d; //导入方法依赖的package包/类
private static void randomizeUnitVector(Vector3d v) {
  Random ptr = new Random();

  // obtain a random vector with 0.001 <= length^2 <= 1.0, normalize
  // the vector to obtain a random vector of length 1.0.
  double l;
  do {
    v.set(ptr.nextFloat() - 0.5, ptr.nextFloat() - 0.5, ptr.nextFloat() - 0.5);
    l = v.lengthSquared();
  } while ((l > 1.0) || (l < 1e-4));
  v.normalize();
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:13,代码来源:Util.java

示例3: sub

import javax.vecmath.Vector3d; //导入方法依赖的package包/类
public static void sub(double[] a, double[] b, Vector3d result) {
  result.set(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:4,代码来源:Util.java

示例4: restorativeForceAndTorsionAngleRadians

import javax.vecmath.Vector3d; //导入方法依赖的package包/类
public static double restorativeForceAndTorsionAngleRadians(Vector3d i, Vector3d j,
                                                    Vector3d k, Vector3d l) {
  // This is adapted from http://scidok.sulb.uni-saarland.de/volltexte/2007/1325/pdf/Dissertation_1544_Moll_Andr_2007.pdf
  // Many thanks to Andreas Moll and the BALLView developers for this

  // Bond vectors of the three atoms

  i.sub(j, i);
  j.sub(k, j);
  k.sub(l, k);

  double len_ij = i.length();
  double len_jk = j.length();
  double len_kl = k.length();

  if (isNearZero(len_ij) || isNearZero(len_jk) || isNearZero(len_kl)) {
    i.set(0, 0, 0);
    j.set(0, 0, 0);
    k.set(0, 0, 0);
    l.set(0, 0, 0);
    return 0.0;
  }

  double ang = vectorAngleRadians(i, j);
  double sin_j = Math.sin(ang);
  double cos_j = Math.cos(ang);
  
  ang = vectorAngleRadians(j, k);
  double sin_k = Math.sin(ang);
  double cos_k = Math.cos(ang);

  // normalize the bond vectors:

  i.normalize();
  j.normalize();
  k.normalize();

  // use i, k, and l for temporary variables as well
  i.cross(i, j);  //a
  l.cross(j, k);  //b
  k.cross(i, l);  //c

  double theta = -Math.atan2(
      k.dot(j),  // ((ij x jk) x (jk x kl)) . jk 
      i.dot(l)); //  (ij x jk) . (jk x kl)
      
  i.scale(1. / len_ij / sin_j / sin_j);
 
  l.scale(-1. / len_kl / sin_k / sin_k);

  j.set(i);
  j.scale(-len_ij / len_jk * cos_j - 1.);
  k.set(l);
  k.scale(-len_kl / len_jk * cos_k);
  j.sub(k);
  
  k.set(i);
  k.add(j);
  k.add(l);
  k.scale(-1);

  return theta;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:64,代码来源:Util.java

示例5: getVector

import javax.vecmath.Vector3d; //导入方法依赖的package包/类
private Vector3d getVector(double x, double y, double z) {
    Vector3d vector = this.vectorPool.getInstance();
    vector.set(x, y, z);
    return vector;
}
 
开发者ID:gegy1000,项目名称:BlockSystems,代码行数:6,代码来源:Matrix.java

示例6: castTo

import javax.vecmath.Vector3d; //导入方法依赖的package包/类
public int castTo( float[] pos, BufferedImage image, Point3d worldHit, Vector3d worldNormal ) {

		com.jme3.math.Vector3f worldDir = new com.jme3.math.Vector3f( pos[ 0 ], pos[ 1 ], pos[ 2 ] );
		worldDir = worldDir.subtract( Jme3z.to(location) );

		com.jme3.math.Vector3f dir = inverseGeomRot.mult( worldDir );

		double angle = (( Math.atan2( -dir.x, dir.z ) + Math.PI ) % ( Math.PI * 2 )) / ( Math.PI * 2 );
		double elevation = (Math.atan2( -dir.y, Math.sqrt( dir.x * dir.x + dir.z * dir.z ) ) + Math.PI / 2) / Math.PI ;

		double[] rgb = new double[3];
		
		if (image != null)
		{
			double  x = angle * image.getWidth(), 
					y = elevation * image.getHeight(), 
					xF = x - Math.floor( x ), 
					yF = y - Math.floor( y );

			get( image, Math.floor( x ), Math.floor( y ), ( 1 - xF ) * ( 1 - yF ), rgb );
			get( image, Math.ceil ( x ), Math.floor( y ), xF * ( 1 - yF ), rgb );
			get( image, Math.ceil ( x ), Math.ceil ( y ), xF * yF, rgb );
			get( image, Math.floor( x ), Math.ceil ( y ), ( 1 - xF ) * yF, rgb );
		}
		
		if (worldHit != null) {
			
			worldHit.x = Double.NaN;
			
			if (planeNameCache.get() != name) {
				planeNameCache.set( name );
				planeMaskCache.set (getPlanePano() );
			}
			
			if ( planeMaskCache.get() != null ) {
				
				double  x = Mathz.clamp( (1-angle) * planeMaskCache.get().getWidth(), 0, planeMaskCache.get().getWidth()-1 ),
						y = elevation * planeMaskCache.get().getHeight();
				
				Color c = new Color ( planeMaskCache.get().getRGB( (int) x, (int) y ) );
				
				int planeNo = (c.getRed() + c.getGreen() + c.getBlue() ) / 3;
				
				if (planeNo < planes.size() && planeNo != 0) {
					
					LinearForm3D plane = new LinearForm3D ( planes.get( planeNo ) );
					
					{
						double tmp = plane.B;
						plane.B = plane.C;
						plane.C = tmp;
						plane.D = -plane.D;
						
						plane.A = -plane.A;
						
					}
					
					Point3d pt = plane.collide( new Point3d(), Jme3z.from( dir ) );
					
					{
						
						com.jme3.math.Vector3f ptm = Jme3z.to( pt );
						
						worldHit.set( Jme3z.from ( geomRot.mult( ptm ) ) );
						worldHit.add( location );

						worldNormal.set( Jme3z.from ( geomRot.mult( Jme3z.to(plane.normal()) ) ) );
					}
				}
			}
			 
			
		}
		
		return Colour.asInt( (int) rgb[ 0 ], (int) rgb[ 1 ], (int) rgb[ 2 ] );
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:77,代码来源:Pano.java


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