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


Java Vector3D.subtract方法代码示例

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


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

示例1: fill

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
@Override
public Set<Vector3D> fill(List<Vector3D> vertices) {
    Set<Vector3D> result = new HashSet<>();

    if (vertices.isEmpty()) return result;

    Vector3D pivot = vertices.get(0);

    for (int i = 1; i < vertices.size() - 1; ++i) {
        Vector3D current = vertices.get(i);
        Vector3D next = vertices.get(i + 1);

        Vector3D currentToNext = next.subtract(current);
        double dist = current.distance(next);
        double jump = getJump(pivot, current, next);

        for (double j = 0; j <= dist; j += jump) {
            Vector3D interpolated = current.add(currentToNext.scalarMultiply(j / dist));
            Set<Vector3D> linePoints = algorithm.draw(pivot, interpolated);
            result.addAll(linePoints);
        }
    }

    return result;
}
 
开发者ID:plushmonkey,项目名称:modelviewer,代码行数:26,代码来源:LinePolygonFiller.java

示例2: draw

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
@Override
public Set<Vector3D> draw(Vector3D from, Vector3D to) {
    Set<Vector3D> result = new HashSet<>();
    double dist = from.distance(to);
    Vector3D between = to.subtract(from);

    for (double i = 0; i <= dist; ++i) {
        Vector3D interpolated = from.add(between.scalarMultiply(i / dist));

        result.add(interpolated);
    }
    return result;
}
 
开发者ID:plushmonkey,项目名称:modelviewer,代码行数:14,代码来源:InterpolateLineAlgorithm.java

示例3: cotangent

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
private double cotangent(Vector3D a, Vector3D b, Vector3D c) {
    Vector3D ba = a.subtract(b);
    Vector3D bc = c.subtract(b);

    return ba.dotProduct(bc) / bc.crossProduct(ba).getNorm();
}
 
开发者ID:plushmonkey,项目名称:modelviewer,代码行数:7,代码来源:BukkitSceneView.java

示例4: getRayIntersection

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
@Override
public double[] getRayIntersection(Vector3D rayOrigin, Vector3D rayDir) {

	// See http://www.lighthouse3d.com/tutorials/maths/ray-triangle-intersection/
	double[] result = new double[1];

	Vector3D e1 = this.verts[1].pos.subtract(this.verts[0].pos);
	Vector3D e2 = this.verts[2].pos.subtract(this.verts[0].pos);

	Vector3D h = rayDir.crossProduct(e2);

	double a = e1.dotProduct(h);

	if (a > -0.00001 && a < 0.00001) {
		result[0] = -1;
		return result;
	}

	double f = 1.0 / a;

	Vector3D s = rayOrigin.subtract(this.verts[0].pos);

	double u = f * s.dotProduct(h);

	if (u < 0.0 || u > 1.0) {
		result[0] = -1;
		return result;
	}

	Vector3D q = s.crossProduct(e1);

	double v = f * rayDir.dotProduct(q);

	if (v < 0.0 || u + v > 1.0) {
		result[0] = -1;
		return result;
	}

	double t = f * e2.dotProduct(q);

	if (t > 0.00001) {
		result[0] = t;
		return result;
	}

	result[0] = -1;
	return result;
}
 
开发者ID:GIScience,项目名称:helios,代码行数:49,代码来源:Triangle.java

示例5: getRayIntersection

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
@Override
public double[] getRayIntersection(Vector3D rayOrigin, Vector3D rayDir) {

	// TODO 4: Source?

	Vector3D origin = rayOrigin.subtract(this.center);

	double[] result = new double[2];

	// Compute A, B and C coefficients:
	double a = rayDir.dotProduct(rayDir);
	double b = 2 * rayDir.dotProduct(origin);
	double c = origin.dotProduct(origin) - this.radius * this.radius;

	// Find discriminant:
	double disc = b * b - 4 * a * c;

	// if discriminant is negative there are no real roots, so return
	// false as ray misses sphere:
	if (disc < 0) {
		result[0] = -1;
		return result;
	}

	// compute q:
	double distSqrt = Math.sqrt(disc);

	double q = 0;

	if (b < 0) {
		q = (-b - distSqrt) / 2;
	} else {
		q = (-b + distSqrt) / 2;
	}

	double t0 = q / a;
	double t1 = c / q;

	if (t0 > t1) {
		double temp = t0;
		t0 = t1;
		t1 = temp;
	}

	// if t1 is less than zero, the object is in the ray's negative direction
	// and consequently the ray misses the sphere
	if (t1 < 0) {
		result[0] = -1;
		return result;
	}

	// if t0 is less than zero, the intersection point is at t1
	if (t0 < 0) {
		result[0] = t1;
		return result;
	}

	// else the intersection point is at t0
	else {
		result[0] = t0;
		return result;
	}
}
 
开发者ID:GIScience,项目名称:helios,代码行数:64,代码来源:Sphere.java

示例6: getVisiblePoints

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
HashSet<VisiblePoint> getVisiblePoints(Vector3D rayOrigin) {

		HashSet<VisiblePoint> result = new HashSet<>();

		for (Vector3D testPoint : vtps) {

			Vector3D rayDir = testPoint.subtract(rayOrigin);

			if (rayDir.getNorm() == 0) {
				continue;
			}

			rayDir = rayDir.normalize();

			// Otherwise, check for intersection with a primitive using the kdtree:
			RaySceneIntersection intersect = scene.getIntersection(rayOrigin, rayDir, false);

			// TODO 4: Try to get true incidence angle
			double incidenceAngle = (Math.PI / 4);

			double intersectDistance = Double.MAX_VALUE;

			if (intersect != null) {
				intersectDistance = rayOrigin.distance(intersect.point);
				incidenceAngle = intersect.prim.getIncidenceAngle_rad(rayOrigin, rayDir);
			}

			double testpointRayDistance = Vector3D.crossProduct(rayDir, testPoint.subtract(rayOrigin)).getNorm();

			if (testpointRayDistance < cfg_hitTolerance_m && rayOrigin.distance(testPoint) <= intersectDistance + cfg_hitTolerance_m) {

				VisiblePoint rsc = new VisiblePoint();
				rsc.angle = incidenceAngle;
				rsc.pos = testPoint;

				result.add(rsc);
			}
		}

		return result;
	}
 
开发者ID:GIScience,项目名称:helios,代码行数:42,代码来源:AbstractSurveyPlanner.java


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