本文整理汇总了Java中javax.vecmath.Vector3d类的典型用法代码示例。如果您正苦于以下问题:Java Vector3d类的具体用法?Java Vector3d怎么用?Java Vector3d使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector3d类属于javax.vecmath包,在下文中一共展示了Vector3d类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: steerCurrLink
import javax.vecmath.Vector3d; //导入依赖的package包/类
private Vector3d steerCurrLink(NavPointNeighbourLink currLink, NavPointNeighbourLink nextLink) {
Location projection = NavigationGraphHelper.projectPointToLinkLine(currLink, bot.getLocation());
double distance = NavigationGraphHelper.NAV_LINK_GET_DISTANCE.getDistance(currLink, bot.getLocation());
double ratio;
if (currLink.getCollisionR() <= 0) {
ratio = 0;
} else {
ratio = distance / (double)currLink.getCollisionR();
}
Location result = projection.sub(bot.getLocation()).scale(ratio).setZ(0);
if (SteeringManager.DEBUG) {
System.out.println("StickToPathSteer: HAS LINK");
System.out.println("StickToPathSteer: collision radius = " + currLink.getCollisionR());
System.out.println("StickToPathSteer: distance = " + distance);
System.out.println("StickToPathSteer: ratio = " + ratio);
System.out.println("StickToPathSteer: result = [" + result.x + ", " + result.y + ", " + result.z + "]");
System.out.println("StickToPathSteer: length = " + result.getLength());
}
return result.asVector3d();
}
示例2: prepareRays
import javax.vecmath.Vector3d; //导入依赖的package包/类
private void prepareRays() {
/*Délky postranních paprsků jsou 8 a 12. Délky šikmých se vynásobí 2 a předního se vynásobí odmocninou(3).*/
int shortLength = 8;
int longLength = 12;
shortSideRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * shortLength * DISTANCE_FROM_THE_WALL / 166f); //8
longSideRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * longLength * DISTANCE_FROM_THE_WALL / 166f); //12
shortSideFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * shortLength * 2 * DISTANCE_FROM_THE_WALL / 166f); //20
longSideFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * longLength * 2 * DISTANCE_FROM_THE_WALL / 166f); //30
shortFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * shortLength * Math.sqrt(3) * DISTANCE_FROM_THE_WALL / 166f); //18
longFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * longLength * Math.sqrt(3) * DISTANCE_FROM_THE_WALL / 166f); //27
//Five rays are created.
LinkedList<SteeringRay> rayList = new LinkedList<SteeringRay>();
rayList.add(new SteeringRay(NLEFT, new Vector3d(0, -1, 0), longSideRayLength));
rayList.add(new SteeringRay(NLEFTFRONT, new Vector3d(Math.sqrt(3), -1, 0), longSideFrontRayLength));
rayList.add(new SteeringRay(NRIGHTFRONT, new Vector3d(Math.sqrt(3), 1, 0), longSideFrontRayLength));
rayList.add(new SteeringRay(NRIGHT, new Vector3d(0, 1, 0), longSideRayLength));
rayList.add(new SteeringRay(NFRONT, new Vector3d(1, 0, 0), longFrontRayLength));
rayManager.addRays(SteeringType.WALL_FOLLOWING, rayList, this);
raysReady = false;
//System.out.println("Rays wall preparation end.");
}
示例3: computeFrontCollisionVector
import javax.vecmath.Vector3d; //导入依赖的package包/类
/**If it's really the front collision, the "mirror vector" is returned. Otherwise the unchanged parameter normal is returned.*/
private Vector3d computeFrontCollisionVector(Vector3d normal) {
Vector3d av = botself.getVelocity().getVector3d();
Vector3d result = new Vector3d(normal.x, normal.y, 0);
Vector3d negativeActual = new Vector3d(-av.x, -av.y, 0);
if (SteeringManager.DEBUG) System.out.println("Angle "+SteeringTools.radiansToDegrees(normal.angle(negativeActual)));
if (result.angle(negativeActual) <= Math.PI/2) {
boolean turnLeft;
if (result.angle(negativeActual) == 0) {
turnLeft = random.nextBoolean();
} else {
turnLeft = SteeringTools.pointIsLeftFromTheVector(av, result);
}
Vector3d turn = SteeringTools.getTurningVector2(av, turnLeft); //Tady se původně používal getTurningVector1.
turn.normalize();
turn.scale(0.5); //Aby neměl rotační vektor tak velký vliv.
result.add(turn);
result.normalize();
if (SteeringManager.DEBUG) System.out.println("Obstacle avoidance front collision: turn left "+turnLeft);
}
return result;
}
示例4: SteeringManager
import javax.vecmath.Vector3d; //导入依赖的package包/类
/**
* Creates the new SteeringManager. This class manages the whole navigation layer of the steered bot. The manager calls steerings to compute the force, combines all forces and sends the computed next velocity to the locomotion layer (modul locomotion).
* @param bot The bot, who should be steered be these steerings.
* @param raycasting The instance of the class Raycasting.
* @param locomotion The AdvancedLocomotion of the bot.
*/
public SteeringManager(UT2004Bot bot, Raycasting raycasting, AdvancedLocomotion locomotion) {
this.botself = bot;
//this.raycasting = raycasting;
this.locomotion = locomotion;
this.multiplier = 1;
rayManager = new RaycastingManager(botself, raycasting);
mySteerings = new HashMap<SteeringType,ISteering>();
steeringWeights = new HashMap<SteeringType, Double>();
steeringForces = new HashMap<SteeringType, Vector3d>();
steeringManagerInitialized();
myActualVelocity = new Vector3d();
myNextVelocity = new Vector3d();
drawRaycasting = false;
canEnlargeVelocity = true;
}
示例5: buildProfile
import javax.vecmath.Vector3d; //导入依赖的package包/类
public static Prof buildProfile( Line3d oLine, Point3d cen ) {
Matrix4d to2D = new Matrix4d();
Vector3d c2 = oLine.dir(), c3 = new Vector3d();
c2.normalize();
c3.cross( c2, UP );
to2D.setIdentity();
to2D.setRow( 0, c3.x, c3.y, c3.z, 0 );
to2D.setRow( 1, UP.x, UP.y, UP.z, 0 );
to2D.setRow( 2, c2.x, c2.y, c2.z, 0 );
{
Point3d start = new Point3d( cen.x, 0, cen.z );
to2D.transform( start );
to2D.m03 = -start.x;
to2D.m13 = -start.y;
to2D.m23 = -start.z;
to2D.m33 = 1;
}
Prof monotonic = new Prof(to2D, c2);
return monotonic;
}
示例6: sliceTri
import javax.vecmath.Vector3d; //导入依赖的package包/类
public static List<Line> sliceTri(ObjRead mesh, double h, int majorAxis ) {
int[] flatAxis = new int[] { ( majorAxis + 1 ) % 3, ( majorAxis + 2 ) % 3 };
if (flatAxis[0] > flatAxis[1]) {
int tmp = flatAxis[0];
flatAxis[0] = flatAxis[1];
flatAxis[1] = tmp;
}
Vector3d sliceNormal = new Vector3d(
majorAxis == 0 ? 1: 0,
majorAxis == 1 ? 1: 0,
majorAxis == 2 ? 1: 0),
slicePt = new Vector3d( sliceNormal );
slicePt.scale(h);
LinearForm3D slicePlane = new LinearForm3D(sliceNormal, slicePt);
return slice(mesh, flatAxis, slicePlane, Double.MAX_VALUE, null, Double.MAX_VALUE).stream().map(l -> new Line(l.start.x, l.start.z, l.end.x, l.end.z)).collect(Collectors.toList());
}
示例7: combineTransformation
import javax.vecmath.Vector3d; //导入依赖的package包/类
static Matrix4d combineTransformation(Matrix4d matrix, Vector3d translation, Vector3d rotation) {
Matrix4d gM = new Matrix4d(matrix);
Matrix4d m = new Matrix4d();
m.setIdentity();
m.setTranslation(translation);
gM.mul(m);
m.setIdentity();
m.rotZ(rotation.z);
gM.mul(m);
m.setIdentity();
m.rotY(rotation.y);
gM.mul(m);
m.setIdentity();
m.rotX(rotation.x);
gM.mul(m);
return gM;
}
示例8: getTorsionAngleRadians
import javax.vecmath.Vector3d; //导入依赖的package包/类
public static double getTorsionAngleRadians(double[] a, double[] b, double[] c, double[] d,
Vector3d r1, Vector3d r2, Vector3d r3) {
// a --r1--> b --r2--> c --r3--> d
// get r1 x r2 ==> r1
// and r2 x r3 ==> r3
// then
// sinTheta/cosTheta = r2.(r1 x r3)/(r1 . r3)
sub(b, a, r1);
sub(c, b, r2);
r2.normalize();
r1.cross(r1, r2); //p1
sub(d, c, r3);
r3.cross(r2, r3); //p2
double p1dotp2 = r1.dot(r3);
r1.cross(r3, r1);
double theta = Math.atan2(
-r2.dot(r1), // sin theta ~ r2.(p2 x p1) / |r2|
p1dotp2); // cos theta ~ p1.p2
return theta;
}
示例9: 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;
}
示例10: rotateAABB
import javax.vecmath.Vector3d; //导入依赖的package包/类
/**
* Rotate an {@link AxisAlignedBB} by the specified rotation matrix.
*
* @param axisAlignedBB The AABB
* @param rotationMatrix The rotation matrix
* @param forcePositive If true, set each coordinate of the rotated AABB to it absolute value
* @return The rotated AABB
*/
public static AxisAlignedBB rotateAABB(AxisAlignedBB axisAlignedBB, Matrix3d rotationMatrix, boolean forcePositive) {
// Extract the minimum and maximum coordinates of the AABB into vectors
final Vector3d minCoords = new Vector3d(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ);
final Vector3d maxCoords = new Vector3d(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ);
// Rotate the vectors in-place
rotationMatrix.transform(minCoords);
rotationMatrix.transform(maxCoords);
if (forcePositive) {
// Get the absolute value of the coordinates
minCoords.absolute();
maxCoords.absolute();
}
// Return an AABB with the new coordinates
return new AxisAlignedBB(minCoords.getX(), minCoords.getY(), minCoords.getZ(), maxCoords.getX(), maxCoords.getY(), maxCoords.getZ());
}
示例11: BlockImpl
import javax.vecmath.Vector3d; //导入依赖的package包/类
public BlockImpl(final int x, final int y, final int z, final ChunkImpl chunk, final BlockMaterialData type)
{
this.x = (byte) x;
this.y = y;
this.z = (byte) z;
this.chunk = chunk;
this.type = type;
this.lazyBox = new LazyValue<>(() -> {
final int x1 = this.x + (this.chunk.getX() << 4);
final int x2 = (x1 >= 0) ? (x1 + 1) : (x1 - 1);
final int y1 = this.z + (this.chunk.getZ() << 4);
final int y2 = y1 + 1;
final int z1 = this.z + (this.chunk.getZ() << 4);
final int z2 = (z1 >= 0) ? (z1 + 1) : (z1 - 1);
return BoundingBox.fromCorners(new Vector3d(x1, y1, z1), new Vector3d(x2, y2, z2));
});
this.state = getBlockState(this);
}
示例12: createCompass
import javax.vecmath.Vector3d; //导入依赖的package包/类
public static Group createCompass() {
Appearance ap = Compass.generateAppearance(Color.pink, 0.5, true);
Cone c = new Cone(1f, 5f, ap);
Transform3D tf = new Transform3D();
tf.rotX(Math.PI / 2);
Transform3D tf1 = new Transform3D();
tf1.setTranslation(new Vector3d(10, 15, -40));
TransformGroup tg = new TransformGroup(tf);
tg.addChild(c);
TransformGroup tg2 = new TransformGroup(tf1);
tg2.addChild(tg);
return tg2;
}
示例13: zoomOn
import javax.vecmath.Vector3d; //导入依赖的package包/类
/**
* Permet de déplacer de manière à centrer sur le point P(x y z )
* @param x
* @param y
* @param z
* @param direction
* Il s'agit de la direction dans laquelle est regardée le
* point. La caméra se trouvera à la translation vecteur appliqué à P
* La norme du vecteur indique la distance entre la caméra et le
* point
*/
public void zoomOn(double x, double y, double z, Vecteur direction) {
Transform3D viewTrans = new Transform3D();
if (direction == null) {
return;
}
if (direction.norme() == 0) {
return;
}
// point the view at the center of the object
Point3d center = new Point3d(x + this.translate.x, y + this.translate.y, z + this.translate.z);
Point3d eyePos = new Point3d(x + this.translate.x + direction.getX(), y + this.translate.y
+ direction.getY(), z + this.translate.z + direction.getZ());
viewTrans.setIdentity();
viewTrans.lookAt(eyePos, center, new Vector3d(0, 0, 1));
// set the view transform
viewTrans.invert();
InterfaceMap3D.tgvu.setTransform(viewTrans);
}
示例14: updateViewPlatformTransform
import javax.vecmath.Vector3d; //导入依赖的package包/类
/**
* Updates the given view platform transformation from yaw angle, pitch angle and scale.
*/
private void updateViewPlatformTransform(TransformGroup viewPlatformTransform, float viewYaw, float viewPitch,
float viewScale)
{
// Default distance used to view a 2 unit wide scene
double nominalDistanceToCenter = 1.4 / Math.tan(Math.PI / 8);
// We don't use a TransformGroup in scene tree to be able to share the same scene
// in the different views displayed by OrientationPreviewComponent class
Transform3D translation = new Transform3D();
translation.setTranslation(new Vector3d(0, 0, nominalDistanceToCenter));
Transform3D pitchRotation = new Transform3D();
pitchRotation.rotX(viewPitch);
Transform3D yawRotation = new Transform3D();
yawRotation.rotY(viewYaw);
Transform3D scale = new Transform3D();
scale.setScale(viewScale);
pitchRotation.mul(translation);
yawRotation.mul(pitchRotation);
scale.mul(yawRotation);
viewPlatformTransform.setTransform(scale);
}
示例15: normal
import javax.vecmath.Vector3d; //导入依赖的package包/类
public static Vector3d normal(Geometry g) throws GeometryException {
switch ( g.geometryTypeId() ) {
case TYPE_POINT:
case TYPE_LINESTRING:
return normal((LineString)g) ;
case TYPE_POLYGON:
return normal( (Polygon)g);
case TYPE_TRIANGLE:
return normal( (Triangle)g);
case TYPE_MULTIPOINT:
case TYPE_MULTILINESTRING:
case TYPE_MULTIPOLYGON:
case TYPE_GEOMETRYCOLLECTION:
case TYPE_TRIANGULATEDSURFACE:
case TYPE_POLYHEDRALSURFACE:
}
throw new GeometryException( "missing case in SFCGAL::algorithm::area3D" );
}