Jump to content

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


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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.