PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Sep 19, 2019 8:31 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Sun Jan 30, 2005 12:30 pm 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com
Pretty obvious code, but its useful. This function will generate an n sided shape with a given radius.
Syntax: [ Download ] [ Hide ]
function shape($number_of_edges,$radius=100) {

                $p = array();

                $degrees = 360/$number_of_edges;

                for ($i=0;$i<$number_of_edges;$i++) {

                        $cos = cos(deg2rad($degrees*$i));

                        $sin = sin(deg2rad($degrees*$i));

                        $x = 0;

                        $y = $radius;

                        $p[] = round($cos*($x) - $sin*($y));

                        $p[] = round($sin*($x) + $cos*($y));

                }

                return $p;

        }


Last edited by onion2k on Sun Dec 03, 2006 8:09 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 26, 2005 10:16 am 
Offline
Site Admin
User avatar

Joined: Tue Dec 23, 2003 3:10 am
Posts: 11470
Location: Toronto


Top
 Profile  
 
 Post subject:
PostPosted: Sat Dec 02, 2006 12:06 am 
Offline
Forum Contributor

Joined: Fri Jul 16, 2004 9:04 pm
Posts: 407
Location: NY


Top
 Profile  
 
 Post subject:
PostPosted: Sun Dec 03, 2006 8:09 am 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com
Done.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group