本文整理汇总了Java中org.poly2tri.geometry.polygon.PolygonPoint类的典型用法代码示例。如果您正苦于以下问题:Java PolygonPoint类的具体用法?Java PolygonPoint怎么用?Java PolygonPoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolygonPoint类属于org.poly2tri.geometry.polygon包,在下文中一共展示了PolygonPoint类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createCirclePolygon
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private Polygon createCirclePolygon( int n,
double scale,
double radius,
double x,
double y )
{
if( n < 3 ) n=3;
PolygonPoint[] points = new PolygonPoint[n];
for( int i=0; i<n; i++ )
{
points[i] = new PolygonPoint( scale*(x + radius*Math.cos( (2.0*Math.PI*i)/n )),
scale*(y + radius*Math.sin( (2.0*Math.PI*i)/n ) ));
}
return new Polygon( points );
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:17,代码来源:CDTHoleExample.java
示例2: createSquare
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private Polygon createSquare()
{
int r = 25, n = 500, m = 50;
PolygonPoint[] points = new PolygonPoint[n];
for( int i=0; i<n; i++ )
{
points[i] = new PolygonPoint( r*Math.cos( (2.0*Math.PI*i)/n ),
r*Math.sin( (2.0*Math.PI*i)/n ) );
}
Polygon p = new Polygon(points);
double w,dx,dy;
// w = 2*r*Math.cos(0.25*Math.PI);
w = 2*r;
dx = w/(m+1);
dy = w/(m+1);
for( int j=0; j<m; ++j )
{
for( int i=0; i<m; ++i )
{
p.addSteinerPoint( new TPoint( dx*(i+1) - 0.5*w, dy*(j+1) - 0.5*w ) );
}
}
return p;
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:27,代码来源:CDTSteinerPointExample.java
示例3: pointsFromFile
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private static void pointsFromFile(URL dataUrl, MathContext mathContext, List<PolygonPoint> outerRing, List<ArrayList<PolygonPoint>> holes) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new FileReader(dataUrl.getFile()));
List<PolygonPoint> polygonPointList = outerRing;
try {
String line;
while ((line = bufferedReader.readLine()) != null) {
if(line.isEmpty()) {
ArrayList<PolygonPoint> hole = new ArrayList<PolygonPoint>();
holes.add(hole);
polygonPointList = hole;
} else {
StringTokenizer stringTokenizer = new StringTokenizer(line, " ");
double x = new BigDecimal(stringTokenizer.nextToken()).round(mathContext).doubleValue();
double y = new BigDecimal(stringTokenizer.nextToken()).round(mathContext).doubleValue();
if (stringTokenizer.hasMoreTokens()) {
double z = new BigDecimal(stringTokenizer.nextToken()).round(mathContext).doubleValue();
polygonPointList.add(mkPt(x, y, z));
} else {
polygonPointList.add(mkPt(x, y));
}
}
}
} finally {
bufferedReader.close();
}
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:27,代码来源:TestConstrainedDelaunay.java
示例4: meshToPolygon
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
/**
* Need to recreate a polygon without holes from a triangulated 2d mesh
* only support IndexMode.triangles
*
* There are probably much better ways to recreate a polygon from a mesh
* but this is what I came up with
*
* @param mesh
* @return
*/
private static Polygon meshToPolygon( Mesh mesh )
{
ArrayList<DTSweepConstraint> edges;
HashMap<PolygonPoint,PolygonPoint> pointMap = new HashMap<PolygonPoint,PolygonPoint>(mesh.getMeshData().getVertexBuffer().limit()/3);
createConstraints( pointMap, mesh );
edges = findOuterEdges( pointMap );
return createPolygon( pointMap, edges );
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:21,代码来源:CDTColladaExample.java
示例5: findOuterEdges
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private static ArrayList<DTSweepConstraint> findOuterEdges( HashMap<PolygonPoint,PolygonPoint> pointMap )
{
DTSweepConstraint edge;
boolean outerEdge;
ArrayList<DTSweepConstraint> list = new ArrayList<DTSweepConstraint>();
for( PolygonPoint a : pointMap.values() )
{
if( a.getEdges() == null )
{
// Some points might not have edges since edges are assigned to
// the point with highest y value
continue;
}
for(Iterator<DTSweepConstraint> it = a.getEdges().iterator(); it.hasNext(); )
{
edge = it.next();
outerEdge = true;
for( DTSweepConstraint e : a.getEdges() )
{
if( edge != e )
{
if( edge.p == e.p && edge.q == e.q )
{
outerEdge = false;
}
}
}
if( outerEdge )
{
list.add( edge );
it.remove();
}
}
a.getEdges().clear();
}
return list;
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:40,代码来源:CDTColladaExample.java
示例6: lastToFirst
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private static void lastToFirst( PolygonPoint p )
{
PolygonPoint previous;
previous = p.getPrevious();
p.setNext( previous );
if( previous != null )
{
lastToFirst( previous );
previous.setPrevious( p );
}
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:12,代码来源:CDTColladaExample.java
示例7: firstToLast
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private static void firstToLast( PolygonPoint p )
{
PolygonPoint next;
next = p.getNext();
p.setPrevious( next );
if( next != null )
{
firstToLast( next );
next.setNext( p );
}
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:12,代码来源:CDTColladaExample.java
示例8: find
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private static PolygonPoint find( HashMap<PolygonPoint,PolygonPoint> map, PolygonPoint p )
{
PolygonPoint a;
a = map.get( p );
if( a == null )
{
map.put( p, p );
a = p;
}
return a;
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:12,代码来源:CDTColladaExample.java
示例9: polygonFromFile
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private Polygon polygonFromFile(URL file) throws IOException {
List<PolygonPoint> outerRing = new ArrayList<PolygonPoint>();
List<ArrayList<PolygonPoint>> holes = new ArrayList<ArrayList<PolygonPoint>>();
pointsFromFile(file, MathContext.DECIMAL64, outerRing, holes);
Polygon polygon = new Polygon(outerRing);
for(List<PolygonPoint> hole : holes) {
polygon.addHole(new Polygon(hole));
}
return polygon;
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:11,代码来源:TestConstrainedDelaunay.java
示例10: toPoints
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
public static List<PolygonPoint> toPoints( Vector3[] vpoints )
{
ArrayList<PolygonPoint> points = new ArrayList<PolygonPoint>(vpoints.length);
for( int i=0; i<vpoints.length; i++ )
{
points.add( new ArdorVector3PolygonPoint(vpoints[i]) );
}
return points;
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:10,代码来源:ArdorVector3PolygonPoint.java
示例11: setVertices
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
/**
* Sets the polygonal shape of this node
*
* @param vertices Vertex positions
* @param textureCoordinates Corresponding vertex texture coordinates
*/
public void setVertices( Vector2f[] vertices, Vector2f[] textureCoordinates ) {
if ( vertices.length > positionBuffer.capacity() ) {
updateMaxVertexCount( Math.max( vertices.length, positionBuffer.capacity() + 20 ) ); // update by at least 20
}
positionBuffer.clear();
textureBuffer.clear();
indexBuffer.clear();
// fill the position buffer
for ( Vector2f vertex : vertices ) {
positionBuffer.put( new float[] { vertex.x, vertex.y, 0 } );
}
positionBuffer.limit( positionBuffer.position() );
normalBuffer.limit( positionBuffer.position() ); // also set the limit on the normal buffer to the same position
// fill the texture buffer
for ( Vector2f textureCoordinate : textureCoordinates ) {
textureBuffer.put( new float[] { textureCoordinate.x, textureCoordinate.y } );
}
textureBuffer.limit( textureBuffer.position() );
// ignore polygons with less than 3 vertices
if ( vertices.length >= 3 ) {
// make a list of polygon points that we can refer to later
PolygonPoint[] points = new PolygonPoint[vertices.length];
for ( short i = 0; i < points.length; i++ ) {
points[i] = new IndexedPolygonPoint( i, vertices[i].getX(), vertices[i].getY() );
}
// create and triangulate our polygon
Polygon polygon = new Polygon( points );
Poly2Tri.triangulate( polygon );
// iterate through the triangles, and add their indices into the index buffer
List<DelaunayTriangle> triangles = polygon.getTriangles();
for ( DelaunayTriangle triangle : triangles ) {
// find the indices of the points
short[] indices = new short[] {
( (IndexedPolygonPoint) triangle.points[0] ).index,
( (IndexedPolygonPoint) triangle.points[1] ).index,
( (IndexedPolygonPoint) triangle.points[2] ).index };
// add the indices into the index buffer
indexBuffer.put( indices );
}
}
indexBuffer.limit( indexBuffer.position() );
// update the underlying vertex buffers
getBuffer( Type.Position ).updateData( positionBuffer );
getBuffer( Type.Normal ).updateData( normalBuffer );
getBuffer( Type.TexCoord ).updateData( textureBuffer );
getBuffer( Type.Index ).updateData( indexBuffer );
// update various statistics and counts
updateBound();
updateCounts();
}
开发者ID:mleoking,项目名称:PhET,代码行数:66,代码来源:PlanarPolygon.java
示例12: mkPt
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
private static PolygonPoint mkPt(double x, double y) {
return new PolygonPoint(x, y);
}
开发者ID:orbisgis,项目名称:poly2tri.java,代码行数:4,代码来源:TestConstrainedDelaunay.java
示例13: mousePressed
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
public void mousePressed() {
PolygonPoint point = new PolygonPoint((float) mouseX, (float) mouseY);
points.add(point);
}
开发者ID:cacheflowe,项目名称:haxademic,代码行数:5,代码来源:Poly2TriTest.java
示例14: drawTrianglesForBlob
import org.poly2tri.geometry.polygon.PolygonPoint; //导入依赖的package包/类
public void drawTrianglesForBlob(Blob b) {
// create points array, skipping over blob edge vertices
points.clear();
EdgeVertex eA;
for (int m=0;m<b.getEdgeNb();m+=10) {
eA = b.getEdgeVertexA(m);
if (eA != null) {
PolygonPoint point = new PolygonPoint(eA.x * p.width, eA.y * p.height);
points.add(point);
}
}
if (points.size() < 10) return;
// calculate triangles
doTriangulation();
// draw it
p.stroke(0,255,0);
p.strokeWeight(2);
p.fill(255, 120);
TriangulationPoint point1, point2, point3;
for (DelaunayTriangle triangle : triangles) {
point1 = triangle.points[0];
point2 = triangle.points[1];
point3 = triangle.points[2];
if( point1.getYf() > 0 && point1.getYf() < p.height &&
point2.getYf() > 0 && point2.getYf() < p.height &&
point3.getYf() > 0 && point3.getYf() < p.height &&
point1.getXf() > 0 && point1.getXf() < p.width &&
point2.getXf() > 0 && point2.getXf() < p.width &&
point3.getXf() > 0 && point3.getXf() < p.width) {
p.line( point1.getXf(), point1.getYf(), point2.getXf(), point2.getYf() );
p.line( point3.getXf(), point3.getYf(), point2.getXf(), point2.getYf() );
p.line( point1.getXf(), point1.getYf(), point3.getXf(), point3.getYf() );
// sometimes fill triangles
if (MathUtil.randBoolean(p) == true ) {
p.beginShape();
p.vertex( point1.getXf(), point1.getYf() );
p.vertex( point2.getXf(), point2.getYf() );
p.vertex( point3.getXf(), point3.getYf() );
p.endShape();
}
}
}
}
开发者ID:cacheflowe,项目名称:haxademic,代码行数:52,代码来源:KinectSilhouette.java
注:本文中的org.poly2tri.geometry.polygon.PolygonPoint类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论