Jump to content

echoing out all the coordinates of a circle? [WARNING:Genius needed]


onedumbcoder

Recommended Posts

I been trying to figure this out and i am just to stupid to get it.  :'(

 

how do i echo out the x and y value as i go around a circle? lets say the radius of a circle is 10, and I go around the circle at 10 degree increments, how do I echo out what each y and x values are?

 

 

Personally after reading [WARNING:Genius needed]

I wasn't going to reply as I find post that are labelled like this are only done so to get a quicker response, hence I intentionally ignore them, for awhile,

 

however I decided to have some fun, and relive some old school coding, of drawing :)

 

remove the GD stuff and uncomment the echo for the function you need (also for each 10th degrees your need 36 side (360 / 10)

 

<?php
header("Content-type: image/png");
drawCircle(100, 100, 50, 100);

function drawCircle($centerX, $centerY, $radius, $sides){
$im = @imagecreate(500, 500)  or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$color = imagecolorallocate($im, 0, 0, 0);
for($i=0; $i<=$sides; $i++)
{
	$pointRatio = $i/$sides;
	$xSteps = cos($pointRatio*2*pi());
	$ySteps = sin($pointRatio*2*pi());

	$pointX = $centerX + $xSteps * $radius;
	$pointY = $centerY + $ySteps * $radius;

	// echo "$pointX, $pointY\n";
	imageellipse($im, $pointX, $pointY, 1, 1, $color);
}
imagepng($im);
imagedestroy($im);
}
?>

 

Great just over 11 minutes, that's how long my genius dream lasted thanks corbin  :cry:

 

Yeah I know, as I said the subject is just to get people to view it, I think drawing a circle was one of the first programs I ever created.  ::)

 

I found it a little iconic I used the imageellipse() function to draw the dots of a circle  :P

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.