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


Java LinearForm3D类代码示例

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


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

示例1: collide

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
/**
 *
 * This is a robust collision of a's adjacent edges with a horizontal plane at the given height
 * When Two parallel edges are given, we can assume that the
 */
public static Tuple3d collide (Corner a, double height)
{
    LinearForm3D ceiling = new LinearForm3D( 0, 0, 1, -height );

    // this can cause Jama not to return...
    if ( a.prevL.linearForm.hasNaN() || a.nextL.linearForm.hasNaN() )
                throw new Error();

        try {
            return ceiling.collide(a.prevL.linearForm, a.nextL.linearForm);
        } catch (RuntimeException e) {
            assert (a.prevL.sameDirectedLine(a.nextL));

            // a vector in the direction of uphill from a
            Vector3d dir = new Vector3d ( a.prevL.uphill );
            dir.normalize();
            // via similar triangle (pyramids)
            dir.scale(height - a.z);
            dir.add(a);

            //assume, they're all coincident?
            return new Point3d (dir.x, dir.y, height);
        }
}
 
开发者ID:twak,项目名称:campskeleton,代码行数:30,代码来源:Edge.java

示例2: buildPlanes

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
private void buildPlanes( File file ) {

		if ( !file.exists() || planes != null )
			return;

		planes = new ArrayList<>();

		try {
			for ( String line : Files.readAllLines( file.toPath() ) ) {
				double[] params = Arrays.stream( line.split( "[,\\s]" ) ).mapToDouble( Double::parseDouble ).toArray();
				planes.add( new LinearForm3D( params[ 0 ], params[ 1 ], params[ 2 ], params[ 3 ] ) );
			}
		} catch ( IOException e ) {
			e.printStackTrace();
		}
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:17,代码来源:Pano.java

示例3: sliceTri

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
public static List<Line> sliceTri(ObjRead mesh, double h, int majorAxis ) {
	
	 int[] flatAxis = new int[] { ( majorAxis + 1 ) % 3, ( majorAxis + 2 ) % 3 };
	 
	 if (flatAxis[0] > flatAxis[1]) {
		 int tmp = flatAxis[0];
		 flatAxis[0] = flatAxis[1];	
		 flatAxis[1] = tmp;
	 }
	 
	Vector3d sliceNormal = new Vector3d(
			majorAxis == 0 ? 1: 0, 
			majorAxis == 1 ? 1: 0,
			majorAxis == 2 ? 1: 0),
			
			slicePt = new Vector3d( sliceNormal );
	
	slicePt.scale(h);
	LinearForm3D slicePlane = new LinearForm3D(sliceNormal, slicePt);

	return slice(mesh, flatAxis, slicePlane, Double.MAX_VALUE, null, Double.MAX_VALUE).stream().map(l -> new Line(l.start.x, l.start.z, l.end.x, l.end.z)).collect(Collectors.toList());
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:23,代码来源:ObjSlice.java

示例4: inside

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
private boolean inside( Point3d pt, List<LinearForm3D> halfPlanes ) {
	
	for (LinearForm3D lf : halfPlanes)
		if (!lf.inFront( pt ))
			return false;
	
	return true;
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:9,代码来源:MiniGen.java

示例5: cut

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
private static LinearForm3D cut(Point3d a, Point3d b, Point3d c) {
		
		Vector3d ab = new Vector3d(b);
		ab.sub(a);
		Vector3d bc = new Vector3d(c);
		bc.sub(b);
		
		ab.normalize();
		bc.normalize();
		
//		if ( true || ab.z > 0.0 || bc.z > 0.0) {
			ab.add( bc );
			ab.normalize();
			
			return new LinearForm3D( toXZ( ab ), toXZ( b ) );
//		}
//		Vector2d ab2 = new Vector2d( ab.x, ab.y ),
//				bc2 = new Vector2d( bc.x, bc.y );
//		
//		ab2.normalize();
//		bc2.normalize();
//		
//		ab2.add( bc2 );
//		
//		Vector3d normal = new Vector3d(ab2.x , ab2.y, 0);
//		normal.normalize();
//		
//		return new LinearForm3D( toXZ( normal ), toXZ( b ) );
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:30,代码来源:GreebleEdge.java

示例6: angle

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
private static double angle( Collection<LinearForm3D> lfs, Line3d line ) {
	
	double min = Double.MAX_VALUE;
	
	for ( LinearForm3D lf : lfs ) {
		Point3d s = lf.project( line.start ), e = lf.project( line.end );
		min = Math.min( min, line.angle( new Line3d( s, e ).dir() ) );
	}
	
	return min;
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:12,代码来源:Tube.java

示例7: cap

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
private static void cap( MeshBuilder out, Collection<LinearForm3D> after, 
		Vector3d along, List<Point3d> profilePts, boolean reverse ) {

	MultiMap<LinearForm3D, Point3d>faces = new MultiMap<>();
	for (Point3d p : profilePts) {
		List<LinearForm3D> hit = new ArrayList<>();
		Point3d c = clip (p, along, after, hit);
		for (LinearForm3D h : hit)
			faces.put( h, c );
	}
	
	for (Map.Entry<LinearForm3D, List<Point3d>> e : faces.map.entrySet()) 
		out.add ( new Loop<Point3d> ( e.getValue() ).singleton(), reverse );
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:15,代码来源:Tube.java

示例8: findCorner

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
/**
 * @return the loop corner whose nextL points to the given edge and whose
 * bisectors for the edge contain the collision.
 */
public static Corner findCorner (Edge in, Point3d collision, Skeleton skel)
{
    for (Corner lc : in.currentCorners)
    {
            if ( lc.nextL == in )
            {
                // the two edges that form the bisector with this edge
                LinearForm3D prev = lc.prevC.nextL.linearForm.clone(); // clone not needed now?
                LinearForm3D next = lc.nextC.nextL.linearForm.clone();

                double pDist = prev.pointDistance( collision ),
                       nDist = next.pointDistance( collision );

                double prevDot = prev.normal().dot( in.direction() ),
                       nextDot = next.normal().dot( in.direction() );

                // depending on if the angle is obtuse or reflex, we'll need to flip the normals
                // to the convention that a point with a positive plane distance is on the correct side of both bisecting planes

                if ( prevDot < 0 ) // should only be 0 if two edges are parallel!
                    pDist = -pDist;
                if ( nextDot > 0 )
                    nDist = -nDist;

                // important constant - must prefer to accept rather than "leak" a collision
                final double c = -0.0001;

                if ( pDist >= c && nDist >= c ) // a bit of slack!
                    return lc;
            }
    }
    return null; // no candidates
}
 
开发者ID:twak,项目名称:campskeleton,代码行数:38,代码来源:EdgeCollision.java

示例9: calculateLinearForm

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
/**
 * finds the Ax + By + Cz = D form of the edge
 * Called when the the weight of the edge changes
 */
public void calculateLinearForm()
{
    calculateUphill();
    
    // find normal from uphill and edge
    Vector3d norm = getPlaneNormal();
    
    linearForm = new LinearForm3D( norm, new Vector3d(start.x, start.y, start.z)  );
}
 
开发者ID:twak,项目名称:campskeleton,代码行数:14,代码来源:Edge.java

示例10: buildProfile

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
public static Prof buildProfile( ObjRead mesh, Line3d oLine, Point3d cen, 
			double minH, double maxH,
			double minD, double maxD,
			Tweed tweed, Node dbg ) {

		Prof monotonic = buildProfile( oLine, cen );
		
		Vector3d dir = oLine.dir();
		dir.normalize();
		Vector3d sliceNormal = new Vector3d( dir.x, 0, dir.z );
		
		LinearForm3D lf = new LinearForm3D( sliceNormal, cen );
		
		List<Line3d> lines = ObjSlice.sliceTri( mesh, lf, 0.5,
				new Vector3d( -dir.z, 0, dir.x ), Math.PI / 2 +  0.1 );
		
//		dbg.attachChild( Jme3z.lines( tweed, lines, ColorRGBA.Blue, 2 ) );
		
		Line3d first = null;
		double closestStart = Double.MAX_VALUE;

		for ( Line3d l : lines ) {
			
			if ( l.start.y > l.end.y )
				l.reverse();
			
			double dist = l.distanceSquared( cen );
			
			if ( dist < closestStart ) {
				closestStart = dist;
				first = l;
			}
		}

		if ( first == null ) {
			return null;
//			lines.clear();
//			monotonic.add( cen );
//			monotonic.add( new Point3d( cen.x, cen.y - 500, cen.z ) );
		} else {
			climb( lines, first, monotonic, maxH, true );
			climb( lines, first, monotonic, minH, false );
		}

		{
			double tol = 0.2;

			minD -= tol;
			maxD += tol;
			
			LinearForm min = new LinearForm( Mathz.UP ).findC( new Point2d(minD,0) );
			LinearForm max = new LinearForm( Mathz.UP ).findC( new Point2d(maxD,0) );
			
			for (int i = 0; i < monotonic.size()-1; i ++) {
				Point2d a = monotonic.get(i), b = monotonic.get(i+1);
				
				if (a.x < minD && b.x < minD) {
					monotonic.remove(i);
					i--;
				} else if (a.x < minD) {
					monotonic.set(i, new LinearForm ( new Line(a,b) ).intersect( min ) );
				} else if (b.x < minD) {
					monotonic.set(i+1, new LinearForm ( new Line(a,b) ).intersect( min ) );
					b.x = minD + Math.ulp(minD);
				}
				
				if (a.x > maxD && b.x > maxD) {
					monotonic.remove(i);
					i--;
				} else if (a.x > maxD) {
					monotonic.set(i, new LinearForm ( new Line(a,b) ).intersect( max ) );
				} else if (b.x > maxD) {
					monotonic.set(i+1, new LinearForm ( new Line(a,b) ).intersect( max ) );
					b.x = maxD - Math.ulp(maxD);
				}
			}
		}
		
		return monotonic; 
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:81,代码来源:Prof.java

示例11: tube

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
public static void tube (MeshBuilder out, 
			Collection<LinearForm3D> before, Collection<LinearForm3D> after, 
			Line3d line, LinearForm3D left, LinearForm3D right, CrossGen gen ) {
		
		if (angle ( before, line) < 0.1 || angle ( after, line ) < 0.1 )
			return; // too pointy to touch
		
		Point3d middle = line.fromPPram( 0.5 );
		
		Vector3d along = line.dir();
		along.normalize();
		Vector3d nAlong = new Vector3d (along);
		nAlong.negate();
		
		Vector3d o1 = left.normal(), u1 = new Vector3d();
		u1.cross( along, o1 );
		
		Frame frame = Mathz.buildFrame ( o1, u1, along, middle);
		
		Vector3d u2 = right.normal();
		u2.cross( u2, along );
//		u2.add( middle );
		
		Vector2d leftDir = Mathz.toXY ( frame, u1 );
		Vector2d rightDir = Mathz.toXY ( frame, u2 );
		
		List<Point3d> profilePts = gen.gen( leftDir, rightDir ).stream().
				map( p -> Mathz.fromXY( frame, p ) ).collect( Collectors.toList() );
		
		List<LinearForm3D> dummy = new ArrayList<>();
		
		for (Pair <Point3d, Point3d> pair : new ConsecutivePairs<Point3d>( profilePts, true ) ) {
			
			Point3d 
					f1 = clip ( pair.first (), along , after , dummy ),
					f2 = clip ( pair.second(), along , after , dummy ),
					b1 = clip ( pair.first (), nAlong, before, dummy ),
					b2 = clip ( pair.second(), nAlong, before, dummy );

			out.add (f2, f1, b1, b2);
		}
		
//		cap( out, after ,  along, profilePts, true  );
//		cap( out, before, nAlong, profilePts, false );
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:46,代码来源:Tube.java

示例12: moulding

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
protected void moulding( Matrix4d to3d, DRectangle rect, MeshBuilder mb ) {
	
	double hh = rect.height/2;
	
	Point3d start = new Point3d (rect.x, 0, rect.y+hh), end = new Point3d (rect.getMaxX(), 0, rect.y+hh);
	
	to3d.transform( start );
	to3d.transform( end   );
	
	Line3d line= new Line3d(start, end);
	
	Vector3d dir = line.dir();
	dir.normalize();
	Vector3d nDir = new Vector3d( dir );
	nDir.scale( -1 );
	
	LinearForm3D left = new LinearForm3D( nDir, start ), right = new LinearForm3D( dir, end);
	
	LinearForm3D wall = new LinearForm3D( to3d.m01,to3d.m11,to3d.m21 );
	wall.findD(start);
	
	Tube.tube( mb, Collections.singleton( left ), Collections.singleton( right ), 
			line, wall, wall, new CrossGen() {
				
				@Override
				public List<Point2d> gen( Vector2d down, Vector2d up ) {
					
					Vector2d d = new Vector2d(down);
					d.normalize();
					
					Vector2d dP = new Vector2d(d.y, -d.x );
					
					List<Point2d> out = new ArrayList();
					
					for (double[] coords : new double[][] {
						{1.00, 0.00},
						{1.00, 0.05},
						{0.66, 0.05},
						{0.66, 0.10},
						{0.33, 0.10},
						{0.33, 0.17},
						{0.00, 0.17},
						{0.00, 0.00},
						} ) {
							Point2d tmp = new Point2d(d);
							tmp.scale (coords[0] * rect.height - hh);
							Point2d tmp2 = new Point2d( dP );
							tmp2.scale (coords[1]);
							tmp.add(tmp2);
						
							out.add(tmp);
					}
					
					return out;
				}
			} );
	
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:59,代码来源:Greeble.java

示例13: roofTween

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
private static LinearForm3D roofTween( SharedEdge a, SharedEdge b, Face f ) {
	
	if (a == null || b == null)
		return null;
	
	Vector3d aD = a.dir(f);
	
	if (aD == null)
		return null;
	
	aD.normalize();
	
	Vector3d bD = b.dir(f);
	
	if (bD == null)
		return null;
	
	bD.normalize();
	
	aD.add(bD);
	
	aD.normalize();
	
	Point3d pt = a.getEnd( f );
	
	return new LinearForm3D( new Vector3d(aD.x, aD.z, aD.y), new Point3d(pt.x, pt.z, pt.y)  );
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:28,代码来源:GreebleEdge.java

示例14: project

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
public boolean project (Matrix4d to2d, Matrix4d to3d, Loop<? extends Point2d> facade, LinearForm3D facePlane, Vector3d perp ) {

			boolean allInside = true;
			
			for (int i = 0; i < 4; i++) {
				
//				Point3d proj = new Point3d(corners[i]);
				
				Point3d sec = facePlane.collide( corners[i], perp );
				
				if (sec != null) {
				
				to2d.transform( sec );
				
				boolean inside = Loopz.inside( new Point2d (sec.x, sec.z), facade );
				
				allInside &= inside;
				
				if ( inside ) {
					sec.y = 0;
					to3d.transform( sec );
					found[i] = sec;
				}
				}
			}
			
			return allInside;
		}
 
开发者ID:twak,项目名称:chordatlas,代码行数:29,代码来源:Greeble.java

示例15: castTo

import org.twak.utils.geom.LinearForm3D; //导入依赖的package包/类
public int castTo( float[] pos, BufferedImage image, Point3d worldHit, Vector3d worldNormal ) {

		com.jme3.math.Vector3f worldDir = new com.jme3.math.Vector3f( pos[ 0 ], pos[ 1 ], pos[ 2 ] );
		worldDir = worldDir.subtract( Jme3z.to(location) );

		com.jme3.math.Vector3f dir = inverseGeomRot.mult( worldDir );

		double angle = (( Math.atan2( -dir.x, dir.z ) + Math.PI ) % ( Math.PI * 2 )) / ( Math.PI * 2 );
		double elevation = (Math.atan2( -dir.y, Math.sqrt( dir.x * dir.x + dir.z * dir.z ) ) + Math.PI / 2) / Math.PI ;

		double[] rgb = new double[3];
		
		if (image != null)
		{
			double  x = angle * image.getWidth(), 
					y = elevation * image.getHeight(), 
					xF = x - Math.floor( x ), 
					yF = y - Math.floor( y );

			get( image, Math.floor( x ), Math.floor( y ), ( 1 - xF ) * ( 1 - yF ), rgb );
			get( image, Math.ceil ( x ), Math.floor( y ), xF * ( 1 - yF ), rgb );
			get( image, Math.ceil ( x ), Math.ceil ( y ), xF * yF, rgb );
			get( image, Math.floor( x ), Math.ceil ( y ), ( 1 - xF ) * yF, rgb );
		}
		
		if (worldHit != null) {
			
			worldHit.x = Double.NaN;
			
			if (planeNameCache.get() != name) {
				planeNameCache.set( name );
				planeMaskCache.set (getPlanePano() );
			}
			
			if ( planeMaskCache.get() != null ) {
				
				double  x = Mathz.clamp( (1-angle) * planeMaskCache.get().getWidth(), 0, planeMaskCache.get().getWidth()-1 ),
						y = elevation * planeMaskCache.get().getHeight();
				
				Color c = new Color ( planeMaskCache.get().getRGB( (int) x, (int) y ) );
				
				int planeNo = (c.getRed() + c.getGreen() + c.getBlue() ) / 3;
				
				if (planeNo < planes.size() && planeNo != 0) {
					
					LinearForm3D plane = new LinearForm3D ( planes.get( planeNo ) );
					
					{
						double tmp = plane.B;
						plane.B = plane.C;
						plane.C = tmp;
						plane.D = -plane.D;
						
						plane.A = -plane.A;
						
					}
					
					Point3d pt = plane.collide( new Point3d(), Jme3z.from( dir ) );
					
					{
						
						com.jme3.math.Vector3f ptm = Jme3z.to( pt );
						
						worldHit.set( Jme3z.from ( geomRot.mult( ptm ) ) );
						worldHit.add( location );

						worldNormal.set( Jme3z.from ( geomRot.mult( Jme3z.to(plane.normal()) ) ) );
					}
				}
			}
			 
			
		}
		
		return Colour.asInt( (int) rgb[ 0 ], (int) rgb[ 1 ], (int) rgb[ 2 ] );
	}
 
开发者ID:twak,项目名称:chordatlas,代码行数:77,代码来源:Pano.java


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