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


Java Vector3D.dotProduct方法代码示例

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


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

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

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

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

示例4: sameOrientationAs

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D; //导入方法依赖的package包/类
/** {@inheritDoc} */
public boolean sameOrientationAs(final Hyperplane<Sphere2D> other) {
    final Circle otherC = (Circle) other;
    return Vector3D.dotProduct(pole, otherC.pole) >= 0.0;
}
 
开发者ID:biocompibens,项目名称:SME,代码行数:6,代码来源:Circle.java


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