2

I'm trying to make Norths directions diagram like this: http://www.physicalgeography.net/fundamentals/images/azimuth.jpg

Diagram I made is dynamic. Every time I put new latitude and longitude, the lines change place. The problem is that I dont know how to rotate image and change its coordinates at the same time.

Left side- how it actually looks -> right side- how i'd like it to look like

My code:

printN = (Graphics2D) jPanel8.getGraphics();
      printN.draw(new Line2D.Double(102, 250, 102, 80));

      Image img1 = Toolkit.getDefaultToolkit().getImage("resources/bez.png");


      declX = 102 + 150 * Math.sin(Math.toRadians(nC.getMagDeclination(getLatitude(), getLongitude())));
      declY = 0 + 150 * Math.cos(Math.toRadians(nC.getMagDeclination(getLatitude(), getLongitude())));


      printN.draw(new Line2D.Double(102, 250, declX, declY));
      printN.drawImage(img1, (int)declX - 5, (int)declY, this);

      convX = 102 + 150 * Math.sin(Math.toRadians(nC.getConvergence(getLatitude(), getLongitude())));
      convY = 0 + 150 * Math.cos(Math.toRadians(nC.getConvergence(getLatitude(), getLongitude())));

      printN.draw(new Line2D.Double(102, 250, convX, convY));

Thanks! :)

wojteck
  • 71
  • 6

0 Answers0