Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Circle Generator Mathematical Problem

Comments in 'Plugin Development' started by PEMapModder, Dec 31, 2013.

  1. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,325
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Question in the code comments
    PHP:
    public function generateFullCircle(Vector3 $centre,Level $level,$r,$blockid,$blockDmg=0,$arcA=0,$arcB=360){//angles in degrees, vectors in blocks
            
    $x=$centre->x;
            
    $y=$centre->y;
            
    $z=$centre->z;//abbr for the centre coords
            
    $block=BlockAPI::get($blockid);//get the Block object for $blockid
            
    $arcAccu=1;
            
    $rAccu=1;
            
    #$result=array();
            
    for($d=$arcA;$d<$arcB;$d=$d+$arcAccu){//changes the direction in the arc bit by bit; what is the optimal ArcAccuracy $arcAccu?
                
    $t=$d/180*M_PI;
                for(
    $rL=0;$rL<=$r;$r+$rAccu){//changes the length of the angle bit by bit to generate a solid circle; what is the optimal RadiusLengthAccuracy $rAccu?
                    
    $tX=sin($t)*$rL+$x;
                    
    $tZ=cos($t)*$rL+$z;
                    
    #result[]=
                        
    $level->setBlockRaw(new Vector3($tX,$y,$tZ),$block);
                }
            }
            
    #return $result;
        
    }
    Lambo likes this.

Share This Page

Advertisement