本文整理匯總了Java中javax.vecmath.Vector3d.dot方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector3d.dot方法的具體用法?Java Vector3d.dot怎麽用?Java Vector3d.dot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.vecmath.Vector3d
的用法示例。
在下文中一共展示了Vector3d.dot方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getTorsionAngleRadians
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
public static double getTorsionAngleRadians(double[] a, double[] b, double[] c, double[] d,
Vector3d r1, Vector3d r2, Vector3d r3) {
// a --r1--> b --r2--> c --r3--> d
// get r1 x r2 ==> r1
// and r2 x r3 ==> r3
// then
// sinTheta/cosTheta = r2.(r1 x r3)/(r1 . r3)
sub(b, a, r1);
sub(c, b, r2);
r2.normalize();
r1.cross(r1, r2); //p1
sub(d, c, r3);
r3.cross(r2, r3); //p2
double p1dotp2 = r1.dot(r3);
r1.cross(r3, r1);
double theta = Math.atan2(
-r2.dot(r1), // sin theta ~ r2.(p2 x p1) / |r2|
p1dotp2); // cos theta ~ p1.p2
return theta;
}
示例2: areAntiPodal
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
private boolean areAntiPodal(Vertex v, Edge e){
double t1=0;
double t2=1;
for (Vertex w:convexHull.neighborVertices(v)){
Vector3d v1=e.getNFaces().get(0).getNormal();
Vector3d v2=e.getNFaces().get(1).getNormal();
double p=v1.dot(GeometryUtils.vectorSubtract(w.pnt, v.pnt));
double q=GeometryUtils.vectorSubtract(v1, v2).dot(GeometryUtils.vectorSubtract(w.pnt, v.pnt));
if (q>0){
t2=Double.min(t2,p/q);
}else if (q<0){
t1=Double.max(t1, p/q);
} else if (p<0){
return false;
}
}
return t1<=t2;
}
示例3: rayTriangleIntersection3D
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
public static Point3d rayTriangleIntersection3D(Ray ray, Triangle t){
Plane p=new Plane(t.p0.asPoint3d(),t.p1.asPoint3d(),t.p2.asPoint3d());
Line3d l=new Line3d(ray.getPoint(),ray.getDirection());
Vector3d n=p.getNormal();
if(approEqual(n.dot(ray.getDirection()),0)){
return null; // ray parallel with plane or on the plane
}else{
if(pointOnPlane(ray.getPoint(),p)){
if(outsideTriangle(ray.getPoint(),t)){
return null;
}else{
return ray.getPoint();
}
}else{
Point3d v0;
if(!isOnLine(t.p0.asPoint3d(),l)){
v0=t.p0.asPoint3d();
}else{
v0=t.p1.asPoint3d();
}
double si=(n.dot(GeometryUtils.vectorSubtract(v0, ray.getPoint())))/(n.dot(ray.getDirection()));
Vector3d inter=GeometryUtils.vectorAdd(GeometryUtils.vectorAdd(v0.asVector3d(),GeometryUtils.vectorSubtract(ray.getPoint(), v0)),GeometryUtils.vectorMul(ray.getDirection(), si));
Point3d point=new Point3d(inter.x,inter.y,inter.z);
if(ray.getDirection().dot(GeometryUtils.vectorSubtract(point, ray.getPoint()))>0-EPS){
if(outsideTriangle(point,t)){
return null;
}return point;
}else{
return null; // point not on the ray
}
}
}
}
示例4: outline
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
private static Polygon outline(Polyhedron polyhedron,Vector3d random){
random.normalize();
double dot=Double.NEGATIVE_INFINITY;
Vertex start=null;
for(Vertex vertex:polyhedron.vertices){
double e=random.dot(new Vector3d(vertex.pnt.x,vertex.pnt.y,vertex.pnt.z));
if (e>dot) {
dot=e;
start=vertex;
}
}
Vertex current=start;
Vertex next=new Vertex(null, 0);
LineString exterior=new LineString();
exterior.addPoint(start.pnt);
while (next!=start){
dot=Double.NEGATIVE_INFINITY;
for(Edge edge:current.edges){
Vertex another=edge.anotherVertex(current);
Vector3d v=GeometryUtils.vectorSubtract(another.pnt, current.pnt);
v.normalize();
double d=v.dot(random);
if(d>dot){
dot=d;
next=another;
}
}
exterior.addPoint(next.pnt);
current=next;
}
Polygon polygon=new Polygon(exterior);
return polygon;
}
示例5: distancePointSegment3D
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
static double distancePointSegment3D(Point3d pt, Segment seg) throws GeometryException {
Vector3d diff = GeometryUtils.vectorSubtract(pt, seg.p0.asPoint3d());
Vector3d segvec = GeometryUtils.vectorSubtract(seg.p1.asPoint3d(), seg.p0.asPoint3d());
double d = diff.dot(segvec);
if (d <= 0)
return (diff.length());
if ((d * diff.length()) > (segvec.length()))
return distancePointPoint3D(pt, seg.p1.asPoint3d());
Vector3d cr = new Vector3d();
cr.cross(segvec,diff);
return cr.length() / (segvec.length());
}
示例6: transBack
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
private Point3d transBack(Point3d point,BoxOrientation bo){
Vector3d n1=GeometryUtils.vectorAdd(new Vector3d(1,0,0), transform(GeometryUtils.vectorSubtract(new Vector3d(1,0,0), bo.getN1()),bo));
Vector3d n2=GeometryUtils.vectorAdd(new Vector3d(0,1,0), transform(GeometryUtils.vectorSubtract(new Vector3d(0,1,0), bo.getN2()),bo));
Vector3d n3=GeometryUtils.vectorAdd(new Vector3d(0,0,1), transform(GeometryUtils.vectorSubtract(new Vector3d(0,0,1), bo.getN3()),bo));
Vector3d v=point.asVector3d();
return new Point3d(v.dot(n1),v.dot(n2),v.dot(n3));
}
示例7: areSidePodal
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
private boolean areSidePodal(Edge e1,Edge e2){
Vector3d e1v1=e1.getNFaces().get(0).getNormal();
Vector3d e1v2=e1.getNFaces().get(1).getNormal();
Vector3d e2v1=e2.getNFaces().get(0).getNormal();
Vector3d e2v2=e2.getNFaces().get(1).getNormal();
double a=e1v2.dot(e2v2);
double b=GeometryUtils.vectorSubtract(e1v1, e1v2).dot(e2v2);
double c=GeometryUtils.vectorSubtract(e2v1, e2v2).dot(e1v2);
double d=GeometryUtils.vectorSubtract(e1v1, e1v2).dot(GeometryUtils.vectorSubtract(e2v1, e2v2));
double v1=Double.min(Double.min(Double.min(a, a+b), a+c), a+b+c+d);
double v2=Double.max(Double.max(Double.max(a, a+b), a+c), a+b+c+d);
return v1<=0+EPS&&v2>=0-EPS;
}
示例8: getLargestSurface
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
public double getLargestSurface() {
Vector3d v=GeometryUtils.vectorSubtract(max, min);
double l=v.dot(orientation.getN1());
double w=v.dot(orientation.getN2());
double h=v.dot(orientation.getN3());
return (Math.max(l*w, Math.max(l*h, w*h)));
}
示例9: getVolume
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
public double getVolume(){
Vector3d v=GeometryUtils.vectorSubtract(max, min);
double l=v.dot(orientation.getN1());
double w=v.dot(orientation.getN2());
double h=v.dot(orientation.getN3());
return Math.abs(l*w*h);
}
示例10: computeValue
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
@Override
protected String computeValue(Geometry geometry){
List<TriangulatedSurface> surfaces=null;
try {
surfaces = new Stitching().stitches(geometry);
} catch (GeometryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
TriangulatedSurface lowest=null;
for (TriangulatedSurface surface:surfaces){
if(lowest!=null){
if(elevation(surface)<elevation(lowest)){
lowest=surface;
}
}else{
lowest=surface;
}
}
Vector3d normal=Normal.normal(lowest.triangleN(0));
double dot=normal.dot(new Vector3d(0,0,-1));
if ((dot>1-EPS&&dot<1+EPS)||(dot>-1-EPS&&dot<-1+EPS)){
return writeEwkt(lowest);
}else{
return null;
}
}
示例11: computeValue
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
@Override
protected double computeValue(Geometry geometry) {
List<TriangulatedSurface> surfaces=null;
try {
surfaces = new Stitching().stitches(geometry);
} catch (GeometryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return Double.NaN;
}
TriangulatedSurface lowest=null;
for (TriangulatedSurface surface:surfaces){
if(lowest!=null){
if(elevation(surface)<elevation(lowest)){
lowest=surface;
}
}else{
lowest=surface;
}
}
Vector3d normal=Normal.normal(lowest.triangleN(0));
double dot=normal.dot(new Vector3d(0,0,-1));
if ((dot>1-EPS&&dot<1+EPS)||(dot>-1-EPS&&dot<-1+EPS)){
return Area.area(lowest);
}else{
return Double.NaN;
}
}
示例12: computeValue
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
@Override
protected String computeValue(Geometry geometry) {
List<TriangulatedSurface> surfaces=null;
try {
surfaces = new Stitching().stitches(geometry);
} catch (GeometryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
TriangulatedSurface top=null;
for (TriangulatedSurface surface:surfaces){
if(top!=null){
if(elevation(surface)>elevation(top)){
top=surface;
}
}else{
top=surface;
}
}
Vector3d normal=Normal.normal(top.triangleN(0));
double dot=normal.dot(new Vector3d(0,0,1));
if ((dot>1-EPS&&dot<1+EPS)||(dot>-1-EPS&&dot<-1+EPS)){
return writeEwkt(top);
}else{
return null;
}
}
示例13: projectToPlane
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
public static Point3d projectToPlane(Point pt,Plane p){
Vector3d vector=GeometryUtils.vectorSubtract(pt.asPoint3d(), p.p0);
Vector3d n=p.getNormal();
double dist=vector.dot(n);
return new Point3d(pt.asPoint3d().x-dist*n.x,pt.asPoint3d().y-dist*n.y,pt.asPoint3d().z-dist*n.z);
}
示例14: distanceSegmentSegment3D
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
private static double distanceSegmentSegment3D(Segment s1, Segment s2) {
Vector3d u = GeometryUtils.vectorSubtract(s1.p1.asPoint3d(),s1.p0.asPoint3d());
Vector3d v = GeometryUtils.vectorSubtract(s2.p1.asPoint3d(),s2.p0.asPoint3d());
Vector3d w = GeometryUtils.vectorSubtract(s1.p0.asPoint3d(),s2.p0.asPoint3d());
double a = u.dot(u);
double b = u.dot(v);
double c = v.dot(v);
double d = u.dot(w);
double e = v.dot(w);
double D = a * c - b * b;
double sc, sN, sD = D;
double tc, tN, tD = D;
// compute the line parameters of the two closest points
if (D < EPS) { // the lines are almost parallel
sN = 0.0; // force using point P0 on segment S1
sD = 1.0; // to prevent possible division by 0.0 later
tN = e;
tD = c;
} else { // get the closest points on the infinite lines
sN = (b * e - c * d);
tN = (a * e - b * d);
if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
sN = 0.0;
tN = e;
tD = c;
} else if (sN > sD) { // sc > 1 => the s=1 edge is visible
sN = sD;
tN = e + b;
tD = c;
}
}
if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
tN = 0.0;
// recompute sc for this edge
if (-d < 0.0)
sN = 0.0;
else if (-d > a)
sN = sD;
else {
sN = -d;
sD = a;
}
} else if (tN > tD) { // tc > 1 => the t=1 edge is visible
tN = tD;
// recompute sc for this edge
if ((-d + b) < 0.0)
sN = 0;
else if ((-d + b) > a)
sN = sD;
else {
sN = (-d + b);
sD = a;
}
}
// finally do the division to get sc and tc
sc = (Math.abs(sN) < EPS ? 0.0 : sN / sD);
tc = (Math.abs(tN) < EPS ? 0.0 : tN / tD);
u.scaleAdd(sc, w);
v.scale(tc);
Vector3d dP = GeometryUtils.vectorSubtract(u, v);
return dP.length(); // return the closest distance
}
示例15: transform
import javax.vecmath.Vector3d; //導入方法依賴的package包/類
private Point3d transform(Point3d point, BoxOrientation bo){
Vector3d v=point.asVector3d();
return new Point3d(v.dot(bo.getN1()),v.dot(bo.getN2()),v.dot(bo.getN3()));
}