二维点集包木窗 [英] Wraping of two dimensional point set

查看:147
本文介绍了二维点集包木窗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有点的2维的列表。

I have got a list of points in 2-dimension.

例如:

X = C(4,3,3,5,6,6,4)

x=c(4,3,3,5,6,6,4)

Y = C(5,3,1,0,1,3,5)

y=c(5,3,1,0,1,3,5)

这些2-D点的情节

我想提请至此设置这样的一个包装:

I would like to draw a wrapper of this point set like this :

请注意的是,在边界(包装)和最近点之间的垂直距离为2单位

Note that, the perpendicular distance between the boundary(wrapper) and the nearest point is 2 unit.

请注意:我有很多的点集像上面点集。我愿做同样的事情,所有的集合。

Note that: I have a number of point sets like the above point set. I would like to do the same thing for all the sets.

我想有这样的边界面。任何人都可以请建议我如何做到这一点。

I want to have this boundary polygon. Could anyone please suggest me how to do this.

任何想法大大AP preciated,的Janak。

Any ideas greatly appreciated, Janak.

推荐答案

使用Java,这变得非常简单。该程序演示的结果通过绘制它。大纲还可以通过迭代获得的 area.getPathIterator(AT),这将返回所有点,一个接一个。

Using Java, this becomes very simple. The program demonstrates the result by plotting it. The outline may also be obtained by iterating the area.getPathIterator(at), which will return all points, one by one.

import java.awt.*;
import java.awt.geom.*;
import java.util.*;

public class PointSet {
public static final int W = 2;
Area area = new Area();

public void add( double x, double y ){
    area.add( new Area( new Rectangle2D.Double( x-W, y-W,2*W, 2*W ) ) );
}
public void plot(){
    Board board = new Board();
    board.go( area );
}
public static void main( String[] args ){
    PointSet ps = new PointSet();
    ps.add( 4, 5);
    ps.add( 3, 3);
    ps.add( 3, 1);
    ps.add( 5, 0);
    ps.add( 6, 1);
    ps.add( 6, 3);
    ps.plot();
}
}

import java.awt.*;
import java.awt.geom.*;
import javax.swing.*;
import java.util.*;
public class Board extends JPanel {
Area area;
void go( Area area ) {
    this.area = area;
    JFrame frame = new JFrame("Circle Test");
    frame.getContentPane().add(this);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    repaint();
    frame.setPreferredSize(new Dimension(800,800));
    frame.pack();
    frame.setVisible(true);
}

public void paintComponent(Graphics g) {
  AffineTransform at = new AffineTransform();
  at.translate( 100, 100 );
  at.scale( 50, 50 );
  PathIterator pit = area.getPathIterator( at );
  Path2D path = new Path2D.Double();
  path.append( pit, true );
  Graphics2D g2d = (Graphics2D)g;
  g2d.draw( path );
}
}

这篇关于二维点集包木窗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆