本文整理汇总了Java中org.apache.commons.math3.geometry.euclidean.threed.Vector3D.distance方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3D.distance方法的具体用法?Java Vector3D.distance怎么用?Java Vector3D.distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.math3.geometry.euclidean.threed.Vector3D
的用法示例。
在下文中一共展示了Vector3D.distance方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: addTestPoint
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
void addTestPoint(Vector3D rayOrigin, Vector3D rayDir) {
TreeMap<Double, Primitive> hitPrims = scene.getIntersections(rayOrigin, rayDir, false);
if (hitPrims == null) {
return;
}
Iterator<Entry<Double, Primitive>> iter = hitPrims.entrySet().iterator();
while (iter.hasNext()) {
Entry<Double, Primitive> entry = (Entry<Double, Primitive>) iter.next();
double hitDistance = entry.getKey();
Vector3D hitPos = rayOrigin.add(rayDir.scalarMultiply(hitDistance));
if (hitPos.distance(lastAddedTestPoint) >= cfg_gridSizeVTP_m || true) {
vtps.add(hitPos);
lastAddedTestPoint = hitPos;
}
}
}
示例3: computeBarycentricWeights
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
private List<Double> computeBarycentricWeights(Vector3D p, List<Vector3D> vertices) {
List<Double> weights = new ArrayList<>();
double weightSum = 0;
int n = vertices.size();
for (int i = 0; i < n; ++i) {
Vector3D curr = vertices.get(i);
Vector3D prev = vertices.get((i + n - 1) % n);
Vector3D next = vertices.get((i + 1) % n);
double norm = p.subtract(curr).getNorm();
double weight;
double epsilon = 0.05;
double c1 = prev.subtract(curr).crossProduct(p.subtract(curr)).getNorm();
double c2 = next.subtract(curr).crossProduct(p.subtract(curr)).getNorm();
if (next.subtract(curr).crossProduct(p.subtract(curr)).getNorm() <= epsilon * next.subtract(curr).getNorm() || c1 == 0.0 || c2 == 0.0) {
weight = p.distance(prev) / next.distance(prev);
} else {
double cot1 = cotangent(p, curr, prev);
double cot2 = cotangent(p, curr, next);
weight = (cot1 + cot2) / (norm * norm);
}
weights.add(weight);
weightSum += weight;
}
for (int i = 0; i < weights.size(); ++i)
weights.set(i, weights.get(i) / weightSum);
return weights;
}
示例4: 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;
}
示例5: getJump
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
private double getJump(Vector3D vertexA, Vector3D vertexB, Vector3D vertexC) {
double atob = vertexA.distance(vertexB);
double atoc = vertexA.distance(vertexC);
double maxDist = Math.max(atob, atoc);
return 1.0 / Math.max(maxDist, 20);
}
示例6: GetInterpolationJump
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
private double GetInterpolationJump(Vector3D first, Vector3D second) {
double jump = first.distance(second);
if (jump == 0.0) jump = 1.0;
return 1.0 / (2 * jump);
}
示例7: 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;
}