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


Java Vector3D.crossProduct方法代码示例

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


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

示例1: createRegularPolygonVertices

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
/** Build the vertices representing a regular polygon.
 * @param center center of the polygon (the center is in the inside half)
 * @param meridian point defining the reference meridian for first polygon vertex
 * @param outsideRadius distance of the vertices to the center
 * @param n number of sides of the polygon
 * @return vertices array
 */
private static S2Point[] createRegularPolygonVertices(final Vector3D center, final Vector3D meridian,
                                                      final double outsideRadius, final int n) {
    final S2Point[] array = new S2Point[n];
    final Rotation r0 = new Rotation(Vector3D.crossProduct(center, meridian),
                                     outsideRadius, RotationConvention.VECTOR_OPERATOR);
    array[0] = new S2Point(r0.applyTo(center));

    final Rotation r = new Rotation(center, MathUtils.TWO_PI / n, RotationConvention.VECTOR_OPERATOR);
    for (int i = 1; i < n; ++i) {
        array[i] = new S2Point(r.applyTo(array[i - 1].getVector()));
    }

    return array;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:22,代码来源:SphericalPolygonsSet.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

示例3: 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


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