當前位置: 首頁>>代碼示例>>Java>>正文


Java Vector3D.dotProduct方法代碼示例

本文整理匯總了Java中math.geom3d.Vector3D.dotProduct方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector3D.dotProduct方法的具體用法?Java Vector3D.dotProduct怎麽用?Java Vector3D.dotProduct使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在math.geom3d.Vector3D的用法示例。


在下文中一共展示了Vector3D.dotProduct方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPlaneIntersectionParametric

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/** Compute intersection with a plane
 * 
 * @param plane plane to compute intersection with
 * @return parametric representation of the intersection or NaN
 */
public double getPlaneIntersectionParametric(Plane3D plane) {
    // the plane normal
    Vector3D planeNormal = plane.getNormalVector();

    double normalLineDot = Vector3D.dotProduct(planeNormal, getVector());
    if ( Math.abs(normalLineDot) < Shape3D.ACCURACY ) {
    	// right angle between plane normal and line vector => line is parallel to the plane
    	return Double.NaN;
    }
    
    // the difference between origin of plane and origin of line
    Vector3D dp = new Vector3D(getOrigin(), plane.getOrigin());
    
    // compute ratio of dot products,
    return Vector3D.dotProduct(planeNormal, dp) / normalLineDot;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:22,代碼來源:StraightLine3D.java

示例2: overlap

import math.geom3d.Vector3D; //導入方法依賴的package包/類
public LineSegment3D[] overlap(Mesh3D m){
		LineSegment3D[] output = new LineSegment3D[m.triCount()*this.triCount()];
		int j=0;
		for(Tri3D tM:m.tris){
			ArrayList<Tri3D> relevantTris = this.triTree.getIntersectible(tM);
//			for(Tri3D tS:tris){
			for(Tri3D tS:relevantTris){
				//Skip any Tris that can't possibly reach each other.
				if(Math.abs(tS.getPoint3D(0).getZ()-tM.getPoint3D(0).getZ())>tS.zradius+tM.zradius) continue;
				if(tS.getPoint(0).distance(tM.getPoint(0))>tS.radius+tM.radius) continue;
//				System.out.println("Passed both prechecks.");
				Point3D[] hits = tS.overlap(tM);
				if(hits!=null){
					Vector3D edge = new Vector3D(hits[0],hits[1]);
					Vector3D cross = Vector3D.crossProduct(tS.normal(), tM.normal());
					//Orient line segments so that the inside of the model is CCW from them, viewed facing the surface normal.
					output[j]=Vector3D.dotProduct(edge, cross)>0 ? new LineSegment3D(hits[0],hits[1]) :
						new LineSegment3D(hits[1],hits[0]);
					j++;
				}
			}
		}
		return Arrays.copyOf(output,j);
	}
 
開發者ID:nick-parker,項目名稱:Bread,代碼行數:25,代碼來源:Surface3D.java

示例3: getMax

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
 * @param v Direction to search
 * @return The point on this mesh furthest in the v direction, or origin if this Mesh has no triangles.
 */
public Point3D getMax(Vector3D v){
	Point3D max = Constants.origin;
	double maxD = 0;
	boolean first = true;
	for(Tri3D t:tris){
		Point3D m = t.getMax(v);
		double d = Vector3D.dotProduct(v, new Vector3D(Constants.origin,m));
		if(d>maxD){
			maxD=d;
			max=m;
			continue;
		}
		if(first){
			first=false;
			maxD=d;
			max=m;
		}
	}
	return max;
}
 
開發者ID:nick-parker,項目名稱:Bread,代碼行數:25,代碼來源:Mesh3D.java

示例4: Tri3D

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
 * Create a Tri3D with CCW normal.
 */
public Tri3D(Point3D p0, Point3D p1, Point3D p2){
	this.ps = new Point3D[]{p0,p1,p2};
	Vector3D v1 = new Vector3D(p0,p1);
	Vector3D v2 = new Vector3D(p0,p2);
	this.u = v1;
	this.v = v2;
	this.udotv = Vector3D.dotProduct(u,v);
	this.denom = Math.pow(Vector3D.dotProduct(u,v),2)-u.normSq()*v.normSq();
	this.pl = new Plane3D(p0,u,v);
	LineSegment3D e0 = new LineSegment3D(p0, p1);
	LineSegment3D e1 = new LineSegment3D(p1, p2);
	LineSegment3D e2 = new LineSegment3D(p2, p0);
	this.es = new LineSegment3D[]{e0,e1,e2};
	this.originDot = Utils3D.PointDot(pl.normal(), pl.origin());
	this.radius = Math.max(Utils3D.length(e0),Utils3D.length(e2));
	this.xyradius= Math.sqrt(Math.max(Math.pow(p1.getX()-p0.getX(), 2)+Math.pow(p1.getY()-p0.getY(), 2),
			Math.pow(p2.getX()-p0.getX(), 2)+Math.pow(p2.getY()-p0.getY(), 2)));
	this.zradius = Math.max(Math.abs(p0.getZ()-p1.getZ()), Math.abs(p0.getZ()-p2.getZ()));
}
 
開發者ID:nick-parker,項目名稱:Bread,代碼行數:23,代碼來源:Tri3D.java

示例5: G1

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
 * Write a gcode command to move to an absolute position.
 * @param p
 */
private void G1(Point6D p){
	Vector3D mv = new Vector3D(last,p);
	double cos = Vector3D.dotProduct(mv, Constants.zplus)/mv.norm();
	//Limit the speed based on the maximum z speed and XY speeds specified in the slicer object.
	if(mv.norm()==0) SetSpeed(s.zSpeed);
	else if(Math.abs(Math.abs(cos)-1)<Constants.tol) SetSpeed(s.zSpeed);
	else{
		SetSpeed(Math.min(Math.abs(s.zSpeed/cos),s.xySpeed));
	}
	w.print("G1 X"+Constants.xyz.format(p.getX()) + " Y" +
			Constants.xyz.format(p.getY()) + " Z" +
			Constants.xyz.format(p.getZ()) +
			" E"+Constants.ext.format(currE));
	if(p.normal != Constants.zero && this.s.fiveaxis){
		Vector3D n = p.normal.normalize();
		w.print(" I" + Constants.xyz.format(n.getX()) +
				" J" + Constants.xyz.format(n.getY()) +
				" K" + Constants.xyz.format(n.getZ()));
	}
	w.print(" E"+Constants.ext.format(currE) + "\n");
	
}
 
開發者ID:nick-parker,項目名稱:Bread,代碼行數:27,代碼來源:GcodeExport.java

示例6: project

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/** Project a point to 2D coordinate subsystem of the plane
 * 
 * @param point point to project onto plane and then compute its coordinates in coordinate subsystem of the plane.
 * @return 2D coordinates in coordinate subsystem of the plane
 */
public Point2D project(Point3D point) {
    Vector3D originOffset = new Vector3D(plane.getOrigin(), plane.project(point));
    
    return new Point2D(
        Vector3D.dotProduct(originOffset,getXUnitVector()),
        Vector3D.dotProduct(originOffset,getYUnitVector())
    );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:14,代碼來源:Plane3DCoordinateSubsystem.java

示例7: project

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/** Project a point onto plane
 * 
 * @param point point to project
 * @return point within plane that lies in direction of normal vector from input point
 */
public Point3D project(Point3D point) {
    Vector3D planeNormal = getNormalVector();
    
    // the difference between origin of plane and the point
    Vector3D dp = new Vector3D( point, getOrigin() );
    
    // compute ratio of dot products,
    double t = Vector3D.dotProduct(planeNormal, dp);
    return new Point3D(
    		point.getX()+t*planeNormal.getX(),
    		point.getY()+t*planeNormal.getY(),
    		point.getZ()+t*planeNormal.getZ()
    );
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:20,代碼來源:Plane3D.java

示例8: getSignedDistance

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/** Get signed distance determined by normal vector
 * 
 * @param point point to get signed distance of
 * @return positive distance if point is in direction of the normal vector
 */
public double getSignedDistance(Point3D point) {
    Point3D projectedPoint = project(point);
    Vector3D pointOffset = new Vector3D(projectedPoint, point);
    double dotProduct = Vector3D.dotProduct(getNormalVector(), pointOffset);
    return point.getDistance(projectedPoint)*Math.signum(dotProduct);
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:12,代碼來源:Plane3D.java

示例9: TolContains

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
	 * Contains with a tolerance.
	 * @param p
	 * @param tol Tolerance to account for floating point issues.
	 * @return
	 */
	private boolean TolContains(Point3D p, double tol) {
		if(p==null) return false;
		if(!pl.contains(p)) return false;
		//http://geomalgorithms.com/a06-_intersect-2.html
		Vector3D w = new Vector3D(ps[0],p);
		double[] p2d = new double[]{(udotv*Vector3D.dotProduct(w,v)-v.normSq()*Vector3D.dotProduct(w, u))/denom,
				(udotv*Vector3D.dotProduct(w,u)-u.normSq()*Vector3D.dotProduct(w, v))/denom};
		return p2d[0]>=-1*tol&&p2d[1]>=-1*tol&&p2d[0]<=1+tol&&p2d[1]<=1+tol&&p2d[0]+p2d[1]<=1+tol;
//		return p2d[0]>=0&&p2d[1]>=0&&p2d[0]<=1&&p2d[1]<=1&&p2d[0]+p2d[1]<=1;
	}
 
開發者ID:nick-parker,項目名稱:Bread,代碼行數:17,代碼來源:Tri3D.java

示例10: getMax

import math.geom3d.Vector3D; //導入方法依賴的package包/類
public Point3D getMax(Vector3D vec) {
	double d1 = Vector3D.dotProduct(u, vec);
	double d2 = Vector3D.dotProduct(v, vec);
	if(d1<0&&d1<d2) return Utils3D.copyPoint(ps[0]);
	if(d1>d2) return Utils3D.copyPoint(ps[1]);
	return Utils3D.copyPoint(ps[2]);
}
 
開發者ID:nick-parker,項目名稱:Bread,代碼行數:8,代碼來源:Tri3D.java

示例11: lineIntersection

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
 * Compute intersection of a line with this plane. Uses algorithm 1 given
 * in: <a href="http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/">
 * http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/</a>.
 * 
 * @param line the line which intersects the plane
 * @return the intersection point
 */
public Point3D lineIntersection(StraightLine3D line) {
    // the plane normal
    Vector3D n = this.normal();

    // the difference between origin of plane and origin of line
    Vector3D dp = new Vector3D(line.origin(), this.origin());

    // compute ratio of dot products,
    // see http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/
    double t = Vector3D.dotProduct(n, dp)
            /Vector3D.dotProduct(n, line.direction());

    return line.point(t);
}
 
開發者ID:pokowaka,項目名稱:android-geom,代碼行數:23,代碼來源:Plane3D.java

示例12: getDistance

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
 * Returns distance of this segment from 'segment'.
 * <p><p>
 * Based on: http://softsurfer.com/Archive/algorithm_0106/ 
 * <p>
 * dist3D_Segment_to_Segment()
 * 
 * @param segment
 * @return
 */
public double getDistance(LineSegment3D segment) {
	LineSegment3D thisSegment = this;
    Vector3D u = new Vector3D(thisSegment.getFirstPoint(), thisSegment.getLastPoint());
    Vector3D v = new Vector3D(segment.getFirstPoint(), segment.getLastPoint());
    Vector3D w = new Vector3D(segment.getFirstPoint(), thisSegment.getFirstPoint());
    double   a = Vector3D.dotProduct(u,u);        // always >= 0
    double   b = Vector3D.dotProduct(u,v);
    double   c = Vector3D.dotProduct(v,v);        // always >= 0
    double   d = Vector3D.dotProduct(u,w);
    double   e = Vector3D.dotProduct(v,w);
    double   D = a*c - b*b;       // always >= 0
    double   sc, sN, sD = D;      // sc = sN / sD, default sD = D >= 0
    double   tc, tN, tD = D;      // tc = tN / tD, default tD = D >= 0

    // compute the line parameters of the two closest points
    if (D < MathUtils.EPSILON) { // 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) < MathUtils.EPSILON ? 0.0 : sN / sD);
    tc = (Math.abs(tN) < MathUtils.EPSILON ? 0.0 : tN / tD);

    // get the difference of the two closest points
    //       dP = w + (sc * u) - (tc * v);
    Vector3D dP = w.plus(u.times(sc).minus(v.times(tc)));  // = S1(sc) - S2(tc)

    return dP.getLength();   // return the closest distance
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:81,代碼來源:LineSegment3D.java

示例13: project

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
 * Compute the position of the orthogonal projection of the given point on
 * this line.
 */
public double project(Point3D point) {
    Vector3D vl = this.getVector();
    Vector3D vp = new Vector3D(this.getOrigin(), point);
    return Vector3D.dotProduct(vl, vp)/vl.getNormSq();
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:10,代碼來源:StraightLine3D.java

示例14: PointDot

import math.geom3d.Vector3D; //導入方法依賴的package包/類
public static double PointDot(Vector3D v, Point3D p){
	Vector3D v2 = new Vector3D(p);
	return Vector3D.dotProduct(v, v2);
}
 
開發者ID:nick-parker,項目名稱:Bread,代碼行數:5,代碼來源:Utils3D.java

示例15: project

import math.geom3d.Vector3D; //導入方法依賴的package包/類
/**
 * Compute the position of the orthogonal projection of the given point on
 * this line.
 */
public double project(Point3D point) {
    Vector3D vl = this.direction();
    Vector3D vp = new Vector3D(this.origin(), point);
    return Vector3D.dotProduct(vl, vp)/vl.normSq();
}
 
開發者ID:pokowaka,項目名稱:android-geom,代碼行數:10,代碼來源:StraightLine3D.java


注:本文中的math.geom3d.Vector3D.dotProduct方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。