本文整理匯總了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;
}
示例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();
}
示例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]);
}
示例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;
}
示例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;
}
示例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 ] );
}