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


Java StraightLine3D类代码示例

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


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

示例1: pruneVertices

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
public int pruneVertices() {
	int pruned = 0;
	for (int i = 0; i < vertices.size(); ) {
		int index1 = i-1;
		int index2 = i;
		int index3 = i+1;
		if (index1 < 0) index1 = vertices.size()-1;
		if (index3 >= vertices.size()) index3 = 0;
		Vertex v1 = vertices.get(index1);
		Vertex v2 = vertices.get(index2);
		Vertex v3 = vertices.get(index3);
		StraightLine3D line3D = new StraightLine3D(v1.asJavaGeomPoint3D(), v3.asJavaGeomPoint3D());
		if (line3D.contains(v2.asJavaGeomPoint3D())) {
			// v2 DOES lie inside line v1-v3
			vertices.remove(i);
			++pruned;
		} else {
			// v2 does not lie inside line v1-v3
			++i;
		}
	}
	numVertices = vertices.size();
	return pruned;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:25,代码来源:BspNode.java

示例2: rayCast

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/** Ray cast, find the first collision between to points
  * 
  * @param from from point
  * @param to to point
  * @return result containing info about the first collision, if there is no collision, result containing nulls and NaNs
  */
 public RayCastResult rayCast(Location from, Location to) {
 	if ( dumpRayCastRequest ) {
 		try {
  		rayCastRequestDumper.writeObject( from );
	rayCastRequestDumper.writeObject( to );
} catch (IOException e) {
	throw new RuntimeException( "Raycast request dump failed.", e );
}
 	}
 	
 	StraightLine3D line = new StraightLine3D( from.asPoint3D(), to.asPoint3D() );
 	RayCastResult retval = rayCaster.getCollision( line );
 	
 	if ( retval == null ) {
 		retval = new RayCastResult( line, null, null, Double.NaN, null );
 	}
 	return retval;
 }
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:25,代码来源:LevelGeometry.java

示例3: project

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/**
	 * Project point P onto this surface in the Z axis.
	 * @param p Point2D to project
	 * @return The projected point as a Point6D object, or null if p is not in the domain of
	 * this surface.
	 */
	public Point6D project(Point2D p){
		StraightLine3D l = new StraightLine3D(new Point3D(p.getX(),p.getY(),0),Constants.zplus);
		for(Point2D tp : ps){
			//If the largest edge in the mesh could connect these points
			if(Utils2D.within(p,tp,MaxRad)){
				//Test the triangle associated with this point.
				Tri3D t = TriMap.get(tp);
				Point3D hit = t.lineIntersection(l);
				if(hit!=null) return new Point6D(hit,t.normal());
			}
			//Otherwise the associated triangle can't possibly reach this point.
		}

        // If we got here, that means the point is trying to be projected outside of the bounding box.
		Box3D b = this.boundingBox();
		System.out.println("Point " + p.getX()+" "+p.getY() + " Failed to project.");
		System.out.println("X bounds: "+ b.getMinX()+" : "+b.getMaxX()+" Y bounds: "+b.getMinY()+" : "+b.getMaxY());
//		return project(p);
		return null;
	}
 
开发者ID:nick-parker,项目名称:Bread,代码行数:27,代码来源:Surface3D.java

示例4: getLineIntersection

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/** Compute intersection of a line with this plane.
 * 
 * @param line line to compute intersection with
 * @return the intersection or null if the line is parallel
 */
public Point3D getLineIntersection( StraightLine3D line ) {
    double t = getLineIntersectionParametric(line);
    if ( !Double.isInfinite(t) && !Double.isNaN(t) ) {
    	return line.getPoint(t);
    } else {
    	return null;
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:14,代码来源:AxisAlignedPlane3D.java

示例5: getLineIntersectionParametric

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/** Compute intersection of a line with this plane.
 * 
 * @param line line to compute intersection with
 * @return parametric representation of the intersection in respect to the line or NaN if the line is parallel
 */
public double getLineIntersectionParametric( StraightLine3D line ) {
	double distance = origin-getAxisCoord(line.getOrigin());
	double directionInverse = getAxisCoord(line.getVectorInverse());
	if ( directionInverse > Shape3D.ACCURACY_INVERSE ) {
		return Double.NaN;
	}
	return distance*directionInverse;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:14,代码来源:AxisAlignedPlane3D.java

示例6: testComputeSignedDistance

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
@Test
public void testComputeSignedDistance() {
	Point3D threeOnes = new Point3D( 1.0, 1.0, 1.0 );
	Point3D minusThreeOnes = new Point3D( -1.0, -1.0, -1.0 );
	StraightLine3D diagonalLineThroughZero = new StraightLine3D( threeOnes, minusThreeOnes ); 
	for ( Axis3D axis : Axis3D.values() ) {
		AxisAlignedPlane3D plane = new AxisAlignedPlane3D( axis, 0 );
		assertEquals( "Failure for "+axis.name()+"-aligned plane.", 1.0, plane.asPlane3D().getSignedDistance( threeOnes ), 0.01 );
		assertEquals( "Failure for "+axis.name()+"-aligned plane.", 1.0, plane.getSignedDistance( threeOnes ), 0.01 );
		assertEquals( "Failure for "+axis.name()+"-aligned plane.", -1.0, plane.asPlane3D().getSignedDistance( minusThreeOnes ), 0.01 );
		assertEquals( "Failure for "+axis.name()+"-aligned plane.", -1.0, plane.getSignedDistance( minusThreeOnes ), 0.01 );
		
		assertEquals( "Intersection should be at (0,0,0).", 0.0, new Point3D(0,0,0).getDistance( plane.getLineIntersection(diagonalLineThroughZero) ), 0.01 );
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:16,代码来源:AxisAlignedPlane3DTest.java

示例7: projectPointToLinkLine

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/**
 * Projects 'point' to line formed by the 'link'.
 * 
 * @param link
 * @param point	
 */
public static Location projectPointToLinkLine(NavPointNeighbourLink link, ILocated point) {
	if (link == null || point == null || point.getLocation() == null) return null;
	StraightLine3D line = new StraightLine3D(link.getFromNavPoint().getLocation().asPoint3D(), link.getToNavPoint().getLocation().asPoint3D());
	Point3D result = line.projectPoint(point.getLocation().asPoint3D());
	return new Location(result);
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:13,代码来源:NavigationGraphHelper.java

示例8: isPointProjectionOnLinkSegment

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/**
 * Tells whether "point" projection to "link" is inside the "link segment".
 * @param link
 * @param point
 * @return
 */
public static Boolean isPointProjectionOnLinkSegment(NavPointNeighbourLink link, ILocated point) {
	if (link == null || point == null || point.getLocation() == null) return null;
	StraightLine3D line = new StraightLine3D(link.getFromNavPoint().getLocation().asPoint3D(), link.getToNavPoint().getLocation().asPoint3D());
	double u = line.project(point.getLocation().asPoint3D());
	return u >= 0 && u <= 1;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:13,代码来源:NavigationGraphHelper.java

示例9: isPointProjectionBeforeLinkSegment

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/**
 * Tells whether "point" projection to "link" is inside the "link segment".
 * @param link
 * @param point
 * @return
 */
public static Boolean isPointProjectionBeforeLinkSegment(NavPointNeighbourLink link, ILocated point) {
	if (link == null || point == null || point.getLocation() == null) return null;
	StraightLine3D line = new StraightLine3D(link.getFromNavPoint().getLocation().asPoint3D(), link.getToNavPoint().getLocation().asPoint3D());
	double u = line.project(point.getLocation().asPoint3D());
	return u < 0;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:13,代码来源:NavigationGraphHelper.java

示例10: isPointProjectionAfterLinkSegment

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
/**
 * Tells whether "point" projection to "link" is inside the "link segment".
 * @param link
 * @param point
 * @return
 */
public static Boolean isPointProjectionAfterLinkSegment(NavPointNeighbourLink link, ILocated point) {
	if (link == null || point == null || point.getLocation() == null) return null;
	StraightLine3D line = new StraightLine3D(link.getFromNavPoint().getLocation().asPoint3D(), link.getToNavPoint().getLocation().asPoint3D());
	double u = line.project(point.getLocation().asPoint3D());
	return u > 1;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:13,代码来源:NavigationGraphHelper.java

示例11: RayCastResult

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
public RayCastResult( StraightLine3D ray, Location hitLocation, Vector3D hitNormal, double hitDistance, Triangle hitTriangle ) {
	this.ray = ray;
	this.hitLocation = hitLocation;
	this.hitNormal = hitNormal;
	this.hitDistance = hitDistance;
	this.hitTriangle = hitTriangle;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:8,代码来源:RayCastResult.java

示例12: computeSideSignedDistanceSquare

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
@Override
public double computeSideSignedDistanceSquare(AxisAlignedPlane3D boundary, StraightLine3D ray) {
	double intersectionParametric = boundary.getLineIntersectionParametric(ray);
	double sign = Math.signum( boundary.getSignedDistance( ray.getOrigin() ) );
	if ( Double.isInfinite(intersectionParametric) || intersectionParametric < 0.0 || intersectionParametric > 1.0 ) {
		return sign * Double.POSITIVE_INFINITY;
	} else {
		return sign * ray.getOrigin().getDistanceSquare( ray.getPoint(intersectionParametric) );
	}
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:11,代码来源:RayCaster.java

示例13: getCollisions

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
@Override
public List<RayCastResult> getCollisions( StraightLine3D ray, double minDistanceSquare, double maxDistanceSquare, ArrayList<Triangle> data ) {
	LinkedList<RayCastResult> retval = new LinkedList<RayCastResult>();
	
	// now let's examine the ray's collisions with triangles
	for(Triangle triangle : data) {

		SimplePlanarPolygon3D trianglePolygon = triangle.planarPolygon;
		Plane3D trianglePlane = trianglePolygon.getPlane();
		Double intersectionParameter = ray.getPlaneIntersectionParametric(trianglePlane);
		if ( Double.isInfinite(intersectionParameter) || intersectionParameter < 0 || intersectionParameter > 1 ) {
			// no intersection or intersection in wrong direction or past the point
			continue;
		}

		Point3D intersection = ray.getPoint(intersectionParameter);
		double intersectionDistanceSquare = ray.getOrigin().getDistanceSquare(intersection);
		
		if ( intersectionDistanceSquare < minDistanceSquare || maxDistanceSquare < intersectionDistanceSquare ) {
			continue;
		}
		
		Point2D intersection2D = trianglePlane.getCoordinateSubsystem().project( intersection );
		SimplePolygon2D polygon2D = trianglePolygon.getPolygonIn2d();

		if ( !polygon2D.contains( intersection2D, triangle.signedAreaIn2dProjection ) ) {
			// intersection is outside the polygon
			continue;
		}

		Location intersectionLocation = new Location(intersection);
		retval.push( new RayCastResult( ray, intersectionLocation, trianglePlane.getNormalVector(), Math.sqrt(intersectionDistanceSquare), triangle ) );
	}

	Collections.sort( retval, hitDistanceComparator );

	return retval;
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:39,代码来源:RayCaster.java

示例14: lineIntersection

import math.geom3d.line.StraightLine3D; //导入依赖的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

示例15: testLineIntersect

import math.geom3d.line.StraightLine3D; //导入依赖的package包/类
@Test
public void testLineIntersect() {
    Plane3D plane = new Plane3D( new Point3D( 0, 0, 0), new Vector3D(1, 0, 0), new Vector3D( 0, 1, 1) );
    StraightLine3D line = new StraightLine3D( new Point3D( 1, 3, 0), new Point3D( 1, 3, 1) );
    assertEquals( new Point3D( 1, 3, 3), line.getPlaneIntersection(plane) );        
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:7,代码来源:Plane3DTest.java


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