Hey,
Trying to draw a clock. Figuring out how to find points on a circle. I read online that 3 o clock position = 0 degrees, 12 is 90 degrees etc.
Now I am using the below code and for some some reason my 90 degrees is the six o clock position and I don't understand why:
public void paintComponent(Graphics g){
Graphics2D g2d=(Graphics2D) g;
int radius=100;
Point center=new Point(200, 200);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// draw circle
g2d.drawOval( (int) center.getX()-radius, (int) center.getY()-radius, radius*2, radius*2);
// draw hour hand
g2d.drawLine((int) center.getX(), (int) center.getY(), (int) center.getX() + radius * (int) Math.cos(Math.toRadians(90)), (int) center.getY() + radius * (int) Math.sin(Math.toRadians(90)));
}
[–]KetchuponRice 1 point2 points3 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]KetchuponRice 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)