本文整理汇总了Java中org.apache.commons.math3.geometry.euclidean.threed.Vector3D类的典型用法代码示例。如果您正苦于以下问题:Java Vector3D类的具体用法?Java Vector3D怎么用?Java Vector3D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector3D类属于org.apache.commons.math3.geometry.euclidean.threed包,在下文中一共展示了Vector3D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeMeasurement
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
public synchronized void writeMeasurement(Measurement m) {
// ############# BEGIN Write measured point to output file ############
if (mPointsFileWriter != null) {
Vector3D shifted = m.position.add(scanner.platform.scene.getShift());
String line = String.format(outputFileLineFormatString, shifted.getX(), shifted.getY(), shifted.getZ(), m.intensity, m.echo_width, m.returnNumber, m.pulseReturnNumber, m.fullwaveIndex, m.hitObjectId);
line += "\n";
try {
mPointsFileWriter.write(line);
} catch (IOException e) {
e.printStackTrace();
}
}
// ############# END Write measured point to output file ############
}
示例2: getMin
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
public Vector3D getMin() {
List<Face> faces = getFaces();
List<Vertex> vertices = getVertices();
double xMin = 0, yMin = 0, zMin = 0;
for (int i = 0; i < faces.size(); ++i) {
Face face = faces.get(i);
for (int a = 0; a < 3; ++a) {
Vector3D vertex = vertices.get(face.getIndex(a)).getPosition();
xMin = Math.min(vertex.getX(), xMin);
yMin = Math.min(vertex.getY(), yMin);
zMin = Math.min(vertex.getZ(), zMin);
}
}
return new Vector3D(xMin, yMin, zMin);
}
示例3: getMax
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
public Vector3D getMax() {
List<Face> faces = getFaces();
List<Vertex> vertices = getVertices();
double xMax = 0, yMax = 0, zMax = 0;
for (int i = 0; i < faces.size(); ++i) {
Face face = faces.get(i);
for (int a = 0; a < 3; ++a) {
Vector3D vertex = vertices.get(face.getIndex(a)).getPosition();
xMax = Math.max(vertex.getX(), xMax);
yMax = Math.max(vertex.getY(), yMax);
zMax = Math.max(vertex.getZ(), zMax);
}
}
return new Vector3D(xMax, yMax, zMax);
}
示例4: sample
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
@Override
public Vector3D sample(double u, double v) {
u = u % 1.0f;
v = v % 1.0f;
if (u < 0)
u += 1.0;
if (v < 0)
v += 1.0;
u = Math.max(0.0f, Math.min(u, 1.0f));
v = Math.max(0.0f, Math.min(v, 1.0f));
int x = (int)((image.getWidth() - 1) * u);
int y = (int)((image.getHeight() - 1) * (1 - v));
x = Math.min(Math.max(0, x), image.getWidth() - 1);
y = Math.min(Math.max(0, y), image.getHeight() - 1);
Color color = new Color(image.getRGB(x, y));
return new Vector3D(color.getRed() / 255.0, color.getGreen() / 255.0, color.getBlue() / 255.0);
}
示例5: getTypeFromColor
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
public ColorType getTypeFromColor(Vector3D color) {
double best_dist = Double.MAX_VALUE;
ColorType best_match = null;
for (Map.Entry<Vector3D, ColorType> entry : types.entrySet()) {
double dist = entry.getKey().distance(color);
if (dist < best_dist) {
best_dist = dist;
best_match = entry.getValue();
}
}
if (best_match == null)
return new ColorType(1, (byte)0);
return best_match;
}
示例6: processScanLine
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
private Set<Vector3D> processScanLine(double y, Vector3D pa, Vector3D pb, Vector3D pc, Vector3D pd) {
Set<Vector3D> result = new HashSet<>();
double gradient1 = pa.getY() != pb.getY() ? (y - pa.getY()) / (pb.getY() - pa.getY()) : 1;
double gradient2 = pc.getY() != pd.getY() ? (y - pc.getY()) / (pd.getY() - pc.getY()) : 1;
double sx = interpolate(pa.getX(), pb.getX(), gradient1);
double ex = interpolate(pc.getX(), pd.getX(), gradient2);
double z1 = interpolate(pa.getZ(), pb.getZ(), gradient1);
double z2 = interpolate(pc.getZ(), pd.getZ(), gradient2);
for (double x = sx; x < ex; x += JUMP) {
double gradient = (x - sx) / (ex - sx);
double z = interpolate(z1, z2, gradient);
Vector3D location = new Vector3D((int)x, (int)y, (int)z);
result.add(location);
}
return result;
}
示例7: initialize
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
@Override
public void initialize(AppStateManager stateManager, Application app) {
super.initialize(stateManager, app);
mWorldNode.attachChild(mLegMarkersGroup);
mMoveCursorModel = mAssetManager.loadModel("Models/movecursor.obj");
mMoveCursorModel.setName("moveCursor");
mMoveCursorModel.setLocalTranslation(0, 0, 1f);
mMoveCursorModel.setCullHint(CullHint.Always);
updateSceneGraph();
Vector3D bs = sim.getScanner().platform.scene.getAABB().getSize();
maxMoveSpeedH = Math.max(bs.getX(), bs.getY()) * 0.003;
inputManager.addListener(mActionListener, "up", "down", "left", "right", "pgup", "pgdown");
}
示例8: assertVector3DEquals
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
private void assertVector3DEquals(final String message,
final Vector3D expected, final Vector3D result) throws AssertionError
{
if (Double.compare(expected.getX(), result.getX()) != 0 || Double.compare(
expected.getY(), result.getY()) != 0 || Double.compare(expected.getZ(),
result.getZ()) != 0)
{
throw new AssertionError(message);
}
}
示例9: SphericalPolygonsSet
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
/** Build a polygons set representing a hemisphere.
* @param pole pole of the hemisphere (the pole is in the inside half)
* @param tolerance below which points are consider to be identical
*/
public SphericalPolygonsSet(final Vector3D pole, final double tolerance) {
super(new BSPTree<Sphere2D>(new Circle(pole, tolerance).wholeHyperplane(),
new BSPTree<Sphere2D>(Boolean.FALSE),
new BSPTree<Sphere2D>(Boolean.TRUE),
null),
tolerance);
}
示例10: getIntersections
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
public TreeMap<Double, Primitive> getIntersections(Vector3D rayOrigin, Vector3D rayDir, boolean groundOnly) {
double[] tMinMax = bbox.getRayIntersection(rayOrigin, rayDir);
// if tMinMax == null, it doesn't. In this case, we can abort here:
if (tMinMax == null) {
return null;
}
KdTreeRaycaster raycaster = new KdTreeRaycaster(kdtree);
return raycaster.searchAll(rayOrigin, rayDir, tMinMax[0], tMinMax[1], groundOnly);
}
示例11: simulatePulse
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
@Override
public void simulatePulse(ExecutorService execService, Vector3D absoluteBeamOrigin, Rotation absoluteBeamAttitude, int state_currentPulseNumber, long currentGpsTime) {
// TODO Auto-generated method stub
// Submit pulse computation task to multithread executor service:
AbstractPulseRunnable worker = new FullWaveformPulseRunnable(this, absoluteBeamOrigin, absoluteBeamAttitude, state_currentPulseNumber, currentGpsTime);
// Submit pulse runnable to worker threads:
execService.execute(worker);
}
示例12: 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;
}
示例13: getIntersection
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
public RaySceneIntersection getIntersection(Vector3D rayOrigin, Vector3D rayDir, boolean groundOnly) {
double[] tMinMax = bbox.getRayIntersection(rayOrigin, rayDir);
// if tMinMax == null, it doesn't. In this case, we can abort here:
if (tMinMax == null) {
return null;
}
boolean bruteForce = false;
RaySceneIntersection result = null;
if (!bruteForce) {
KdTreeRaycaster raycaster = new KdTreeRaycaster(kdtree);
result = raycaster.search(rayOrigin, rayDir, tMinMax[0], tMinMax[1], groundOnly);
} else {
double minDist = Double.MAX_VALUE;
for (Primitive p : this.primitives) {
double[] hitDist = p.getRayIntersection(rayOrigin, rayDir);
if ((hitDist[0] >= 0 && hitDist[0] < minDist)) {
minDist = hitDist[0];
result = new RaySceneIntersection();
result.prim = p;
result.point = rayOrigin.add(rayDir.scalarMultiply(minDist));
}
}
}
return result;
}
示例14: capturePoint
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
void capturePoint(Vector3D beamOrigin, Vector3D beamDir, double distance, double intensity, double echo_width, int returnNumber, int pulseReturnNumber, int fullwaveIndex, String hitObjectId) {
// Abort if point distance is below mininum scanner range:
if (distance < detector.cfg_device_rangeMin_m) {
return;
}
// ########## BEGIN Apply gaussian range accuracy error ###########
double precision = this.detector.cfg_device_accuracy_m / 2;
double error = -precision + Math.random() * (precision * 2);
error += boxMullerRandom(0.0, this.detector.cfg_device_accuracy_m / 2);
distance += error;
// ########## END Apply gaussian range accuracy error ###########
// Calculate final recorded point coordinates:
Vector3D pointPos = beamOrigin.add(beamDir.scalarMultiply(distance));
Measurement m = new Measurement();
m.position = pointPos;
m.distance = distance;
m.intensity = intensity;
m.echo_width = echo_width;
m.returnNumber = returnNumber;
m.pulseReturnNumber = pulseReturnNumber;
m.fullwaveIndex = fullwaveIndex;
m.beamOrigin = beamOrigin;
m.beamDirection = beamDir;
m.hitObjectId = hitObjectId;
detector.writeMeasurement(m);
detector.mBuffer.add(m);
}
示例15: captureFullWave
import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入依赖的package包/类
private void captureFullWave(ArrayList<Double> fullwave, int fullwaveIndex, double min_time, double max_time, Vector3D beamOrigin, Vector3D beamDir, Long gpstime) {
// add noise to fullwave
/*
double precision = 0.01 * Collections.max(fullwave);
double error = -precision + Math.random() * (precision * 2);
error += boxMullerRandom(0.0, this.detector.cfg_device_accuracy_m / 2);
for (Double f : fullwave) f+=error;
*/
fwDetector.writeFullWave(fullwave, fullwaveIndex, min_time, max_time, beamOrigin, beamDir, gpstime);
}