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


Java Vector3D类代码示例

本文整理汇总了Java中math.geom3d.Vector3D的典型用法代码示例。如果您正苦于以下问题:Java Vector3D类的具体用法?Java Vector3D怎么用?Java Vector3D使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Vector3D类属于math.geom3d包,在下文中一共展示了Vector3D类的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: PositionShape

import math.geom3d.Vector3D; //导入依赖的package包/类
/**
 * Position shape so that its highest point is layerHeight/2 above the part's lowest point.
 */
private void PositionShape(){
	Box3D shapeBb = shape.boundingBox();
	Box3D partBb = part.boundingBox();

       double xOffset = bedCenter.getX() - ((partBb.getMaxX() - partBb.getMinX()) * 0.5);
       double yOffset = bedCenter.getY() - ((partBb.getMaxY() - partBb.getMinY()) * 0.5);

       Vector3D mv = new Vector3D(xOffset,yOffset,partBb.getMinZ()-shapeBb.getMaxZ()+layerHeight);
	shape.move(mv);
       part.move(new Vector3D(xOffset, yOffset,0));
	shapeBb = shape.boundingBox();
	System.out.println("New max Z: " + shapeBb.getMaxZ());
	Vector3D layerUp = new Vector3D(0,0,layerHeight);
	Vector3D layerDown = new Vector3D(0,0,-layerHeight);
	//Moving Down should never be printed unless boundingBox is broken.
	while(!checkEmpty(-1)){
		System.out.println("Moving Down");
		shape.move(layerDown);
	}
	//This is necessary because contacting bounding boxes does not imply contacting meshes.
	while(checkEmpty(0)){
		System.out.println("Moving up");
		shape.move(layerUp);
	}
}
 
开发者ID:nick-parker,项目名称:Bread,代码行数:29,代码来源:Slicer.java

示例3: slice

import math.geom3d.Vector3D; //导入依赖的package包/类
public void slice(Writer w){
//		PositionShape();
		part.move(new Vector3D(0, 0, zMin));
		GcodeExport g = new GcodeExport(w, this);
		g.writeFromFile("start.gcode");
		g.setTempAndWait(this.printTemp);
//		Point2D last = new Point2D(shape.boundingBox().getMinX(),shape.boundingBox().getMinY());
		Point2D last = new Point2D(0,0);
		ArrayList<Extrusion3D> br = Brim.brim(this, brimCount, last);
		if(brimCount!=0){
			g.addLayer(br, -1);
			last = new Point2D(br.get(br.size()-1).lastPoint().getX(),br.get(br.size()-1).lastPoint().getY());
		}
		for(int n=0;n<layerCount;n++){
			last = doLayer(n,g,last);
		}
		g.writeFromFile("end.gcode");
		g.close();
	}
 
开发者ID:nick-parker,项目名称:Bread,代码行数:20,代码来源:Slicer.java

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

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

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

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

示例8: boundingBox

import math.geom3d.Vector3D; //导入依赖的package包/类
public Box3D boundingBox() {
    Vector3D v = this.direction();

    // line parallel to (Ox) axis
    if (Math.hypot(v.getY(), v.getZ())<Shape3D.ACCURACY)
        return new Box3D(x0, x0, Double.NEGATIVE_INFINITY,
                Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
                Double.POSITIVE_INFINITY);

    // line parallel to (Oy) axis
    if (Math.hypot(v.getX(), v.getZ())<Shape3D.ACCURACY)
        return new Box3D(Double.NEGATIVE_INFINITY,
                Double.POSITIVE_INFINITY, y0, y0, Double.NEGATIVE_INFINITY,
                Double.POSITIVE_INFINITY);

    // line parallel to (Oz) axis
    if (Math.hypot(v.getX(), v.getY())<Shape3D.ACCURACY)
        return new Box3D(Double.NEGATIVE_INFINITY,
                Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY,
                Double.POSITIVE_INFINITY, z0, z0);

    return new Box3D(Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
            Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY);
}
 
开发者ID:pokowaka,项目名称:android-geom,代码行数:26,代码来源:StraightLine3D.java

示例9: getBoundingBox

import math.geom3d.Vector3D; //导入依赖的package包/类
@Override
  public Box3D getBoundingBox() {
      Vector3D v = this.getVector();

      // line parallel to (Ox) axis
      if (JavaGeomMath.hypot(v.getY(), v.getZ())<Shape3D.ACCURACY)
          return new Box3D(
      		origin.getX(), origin.getX(),
      		Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
      		Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY
  		);

      // line parallel to (Oy) axis
      if (JavaGeomMath.hypot(v.getX(), v.getZ())<Shape3D.ACCURACY)
          return new Box3D(
      		Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
      		origin.getY(), origin.getY(),
      		Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY
  		);

      // line parallel to (Oz) axis
      if (JavaGeomMath.hypot(v.getX(), v.getY())<Shape3D.ACCURACY)
          return new Box3D(
      		Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
      		Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
      		origin.getZ(), origin.getZ()
  		);

      return new Box3D(
	Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
	Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY,
	Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY
);
  }
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:35,代码来源:StraightLine3D.java

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

示例11: createPlaneDefinedByPoints

import math.geom3d.Vector3D; //导入依赖的package包/类
/** Construct from points in plane
 * 
 * Picks 3 anchors from provided list of points, see {@link #pickAnchors(Collection)}
 * 
 * @param pointsInPlane points that lie in the constructed plane, must contain at least 3 linearly independent points
 */
public static Plane3D createPlaneDefinedByPoints(Collection<Point3D> pointsInPlane) {
    Point3D[] anchors = pickAnchors(pointsInPlane);
    return new Plane3D( 
        anchors[0],
        new Vector3D(anchors[0],anchors[1]),
        new Vector3D(anchors[0],anchors[2]) 
    );
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:15,代码来源:Plane3D.java

示例12: getNormalVector

import math.geom3d.Vector3D; //导入依赖的package包/类
/** Get the normal vector
 * <p>
 * Normal is normalized.
 */
public Vector3D getNormalVector() {
	if ( normal == null ) {
		normal = Vector3D.crossProduct(vector1, vector2).getOpposite().getNormalizedVector();
	}
	return normal;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:11,代码来源:Plane3D.java

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

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

示例15: rateAnchors

import math.geom3d.Vector3D; //导入依赖的package包/类
/** Rate the ability of points to define a plane
 * 
 * Anchors need to be distant from each other (to avoid floating point math inaccuracies) and must be linearly independent.
 */
protected static double rateAnchors(Point3D a, Point3D b, Point3D c) {
    Vector3D ab = new Vector3D(a, b);
    Vector3D ac = new Vector3D(a, c);
    Vector3D abn = ab.getNormalizedVector();
    Vector3D acn = ac.getNormalizedVector();
    double linearIndependencyFactor = Math.min( abn.minus(acn).getLength(), abn.plus(acn).getLength() );
    double distanceFactor = Math.min(ab.getLength(), ac.getLength());
    return distanceFactor*linearIndependencyFactor;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:14,代码来源:Plane3D.java


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