【发布时间】:2015-07-16 03:40:04
【问题描述】:
从我在那里发布的图像中,我将图 C 中这些矩形的所有坐标保存在 Figure 类的数组中。
图:
public abstract class Figure {
private int left, right, height;
protected Coordinates[] coords;
public Figure() {
}
public Figure(int left, int right, int height, Coordinates[] coords) {
this.left = left;
this.right = right;
this.height = height;
this.coords = coords;
}
public int getRight() {
return right;
}
public int getLeft() {
return left;
}
public int getHeight() {
return height;
}
public Coordinates[] getCoords() {
return coords;
}
public abstract void setCoordinates();
public abstract void showCoordinates();
}
坐标:
public class Coordinates {
private float x, y;
public Coordinates() {
}
public Coordinates(float x, float y) {
this.x = x;
this.y = y;
}
public float getX() {
return x;
}
public float getY() {
return y;
}
}
问题是,我必须使用已经提到的数组中的坐标从整个图中找到轮廓的坐标,就像它在图 D (see the image) 中的方式一样。
示例(参见图片参考):
1st Rectangle Coordinates are: (1,0)(1,11)(5,11)(5,0)
2nd Rectangle Coordinates are: (2,0)(2,6)(7,6)(7,0)
3rd Rectangle Coordinates are: (3,0)(3,13)(9,13)(9,0)
4th Rectangle Coordinates are: (12,0)(12,7)(16,7)(7,0)
5th Rectangle Coordinates are: (14,0)(14,3)(25,3)(25,0)
6th Rectangle Coordinates are: (19,0)(19,18)(22,18)(22,0)
7th Rectangle Coordinates are: (23,0)(23,13)(29,13)(29,0)
8th Rectangle Coordinates are: (24,0)(24,4)(28,4)(28,0)
The Coordinates of the Silhouettes from all those rectangles should be:
(1,11)(3,13)(9,0)(12,7)(16,3)(19,18)(22,3)(23,13)(29,0)
This is where I'm stuck thinking how I'll get these coordinates.
我不是要求别人为我做这件事或类似的事情,我只是想从哪里开始,因为到目前为止我尝试过的所有方法都失败了,所以任何提示或想法都会派上用场!非常感谢你!晚安。
【问题讨论】:
标签: java coordinates rectangles