So, I have added a constructor that makes it possible to create triangles with the expression
new Triangle(x1, y1, x2, y2, x3, y3) where (x1,y1), (x2,y2), (x3,y3) are the three
vertices of the triangle. However, I need to make getVertices return (x1,y1,0), (x2,y2,0), (x3,y3,0); that is, the coordinates
given to the constructor, with coordinate z set to 0.
below is code for a triangular prism, im trying to shorten/reformat so it works for a triangle, with a different formula.
private List<Point> getVertices() {
List<Point> result = new ArrayList<>();
result.add(new Point(x1 + x, y1 + y, z - height / 2.0));
result.add(new Point(x2 + x, y2 + y, z - height / 2.0));
result.add(new Point(x3 + x, y3 + y, z - height / 2.0));
result.add(new Point(x1 + x, y1 + y, z + height / 2.0));
result.add(new Point(x2 + x, y2 + y, z + height / 2.0));
result.add(new Point(x3 + x, y3 + y, z + height / 2.0));
return result;
any help would be greatly appreciated
question from:
https://stackoverflow.com/questions/65863284/how-to-re-format-getvertices-to-return-x1-y1-0-x2-y2-0-x3-y3-0 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…