Draw circle with method of transformation of rotation

Draw circle with method of transformation of rotation

Algoritmus method for rotation transformation:

   int stredx=polx;   int stredy=poly; // circle center

   double p1;  // help variable
   int r; // radius r
   double pi=3.141592654;
   int poc_iter=12; // points on circle

   p1=poc_iter;
   double alfa=(2*pi)/p1; // rotation angle  

  // start point
  double x1=mx-polx;
  double y1=my-poly;

  double x2,y2; 

  for (int i=0;i < poc_iter;i++)
     {

        // rotation of point x1, y1 around center about angle alpha
        x2=x1*Math.cos(alfa) - y1*Math.sin(alfa);
        y2=x1*Math.sin(alfa) + y1*Math.cos(alfa);
 
        // Draw line from [x1,y1] to [x2,y2]
        go.drawLine(polx+(int)(x1),poly+(int)(y1),polx+(int)(x2),poly+(int)(y2));        

        x1=x2;y1=y2;
      } 

$$$APPLET

Applet Draw circle with method of transformation of rotation, define point on circle

Copyright (c) 1999-2017 Juraj Štugel. www.netgraphics.sk