I have an indefinite amount of points on a map based around a center. They should be arranged in a polygon, so their angle is 360/amount of points (http://prntscr.com/8z2w3z). I have a center point, a length and directions so it should be possible to find coordinates for the points. As I'm working with Bukkit to create a minecraft plugin the only way to add locations is to add their coordinates, so I can't simply give them a direction. Here is the code I expected to work, but didn't:
float teamAngle = angle * teamNumber;
Location spawnPoint = mapCenter;
float relX = (float)Math.cos(Math.toRadians(teamAngle))*radius;
float relZ = (float)Math.sin(Math.toRadians(teamAngle))*radius;
spawnPoint.add(new Location(Bukkit.getWorld("world"), relX, 0, relZ, 0, 0));
teamAngle
is φ for each point, so with 4 points, it would be 0, 90, 180 and 270radius
is simply a float based on the map size/2 * 0.8. It might not be the best variable name
With 4 points, I'd expect something like this (map width 100 => radius 40, center at (0|0) ):
- A(40|0)
- B(0|-40)
- C(-40|040)
- D(0|40)
EDIT: In fact as a commenter has said, the coords need to be a bit different, i changed it above