如果我知道 30° 和半径,我想获得三角形上每个度“a”的 x 和 y 坐标。我也想在更多的角落使用它。
这是图片: https ://dl.dropboxusercontent.com/u/104060836/Image.png
任何帮助将不胜感激。
我已经尝试过这段代码:
/**
* Gets the points on the shape around the location.
* @param location
* @param diameter
* @param amount
* @param degreesBetweenPoint
* @return points
*/
public static List<Location> getShapeLinePoints(Location location, NecroPlane plane, double diameter, int amount, int degreesBetweenPoint) {
List<Location> points = new ArrayList<Location>();
double r = diameter / 2;
int c1 = 180 / amount;
int c2 = c1 / 2;
for (int i = 0; i < (360 / degreesBetweenPoint); i++) {
int d = i * degreesBetweenPoint;
int d1 = d;
while (d1 >= c1) {
d1 -= c1;
}
int d2 = 180 - c2 - d1;
double z = (r * Math.sin(Math.toRadians(c2))) / Math.sin(Math.toRadians(d2));
double x = Math.sin(Math.toRadians(d)) * z;
double y = Math.cos(Math.toRadians(d)) * z;
switch (plane) {
case XZ:
points.add(new Location(location.getWorld(), location.getX() + x, location.getY(), location.getZ() + y));
break;
case YZ:
points.add(new Location(location.getWorld(), location.getX(), location.getY() + y, location.getZ() + x));
break;
case XY:
default:
points.add(new Location(location.getWorld(), location.getX() + x, location.getY() + y, location.getZ()));
}
}
return points;
}
我让它工作了,如果有人需要,这里是解决方案:http: //pastie.org/8022687