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


Java Vector3D.scalarMultiply方法代码示例

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


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

示例1: doPhysicsStep

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
void doPhysicsStep(int simFrequency_hz) {

		// ############## BEGIN Update vehicle position #################

		Vector3D drag_accel = this.getVelocity().scalarMultiply(mCfg_drag * simFrequency_hz);
		Vector3D accel = mCfg_g_accel.add(mEngineForce).subtract(drag_accel);
		Vector3D delta_v = accel.scalarMultiply(1.0 / simFrequency_hz);

		this.setVelocity(this.getVelocity().add(delta_v));
		// NOTE: Update of position happens in Platform base class

		// ################ BEGIN Check vertical distance to ground (EXPENSIVE!) ###############
		/*
		if (mCheckGround) {

			Vector3D pos = getPosition();

			Vector3D ground = scene.getGroundPointAt(pos);

			mIsOnGround = (ground != null && pos.getZ() < ground.getZ());

			if (mIsOnGround) {
				setPosition(new Vector3D(pos.getX(), pos.getY(), ground.getZ()));

				Vector3D v = getVelocity();

				if (v.getNorm() > 0 && v.getZ() < 0) {
					setVelocity(new Vector3D(v.getX(), v.getY(), 0));
				}
			}
		}
		*/
		// ################ END Check vertical distance to ground (EXPENSIVE!) ###############

		// ############## END Update vehicle position #################
	}
 
开发者ID:GIScience,项目名称:helios,代码行数:37,代码来源:SimplePhysicsPlatform.java

示例2: intersect

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
/**
 * Determine point of intersection with another arc
 *
 * @return point of intersection, or null if there is no unique intersection
 */
public GeoPoint intersect(GeoArc arcB) {
    GeoArc arcA = this;

    // If either arc is zero-length, no solution exists
    if (arcA.length() < TOLERANCE) return null;
    if (arcB.length() < TOLERANCE) return null;

    // Convert points to cartesian
    Vector3D p1 = arcA.pointA.toCartesian();
    Vector3D p2 = arcA.pointB.toCartesian();
    Vector3D p3 = arcB.pointA.toCartesian();
    Vector3D p4 = arcB.pointB.toCartesian();

    // Determine planes on which arcs lie
    Vector3D vA = Vector3D.crossProduct(p1, p2);
    Vector3D vB = Vector3D.crossProduct(p3, p4);

    // Zero vector indicates antipodal points, which have no solution
    if (vA.getNormSq() <= 0) return null;
    if (vB.getNormSq() <= 0) return null;

    // Determine line where planes intersect (which lies between points of circle intersection)
    Vector3D v = Vector3D.crossProduct(vA.normalize(), vB.normalize());
    double vLenSq = v.getNormSq();

    // Zero vector indicates arcs on the same plane, which would have infinite solutions
    if (vLenSq <= 0) return null;

    // Normalize to unit length, which will result in a point on the sphere surface
    v = v.scalarMultiply(1 / Math.sqrt(vLenSq));

    // Convert the intersection points from cartesian to GeoPoint
    GeoPoint s1 = new GeoPoint(v);
    GeoPoint s2 = new GeoPoint(v.negate());

    // If one of the points lies on both arcs, it is the solution
    if (arcA.contains(s1) && arcB.contains(s1)) {
        return s1;
    }
    if (arcA.contains(s2) && arcB.contains(s2)) {
        return s2;
    }

    return null;
}
 
开发者ID:cadouthat,项目名称:geo-java,代码行数:51,代码来源:GeoArc.java


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