Jump to content

Math God needed


Go to solution Solved by Barand,

Recommended Posts

Thanks for thee responses guys.

 

Ya I meant spaced around its circumference. So together all 20 objects forms a circle.

 

I think this is the formula I saw when I was trying to google it Barand.

 

I'm confused about the theta part

Do I use pie for that?

 

Also not sure how this would give me 20 spaced out. But I guess the theta would determine that.

 

so really I need 20 slices of pie and a object in the middle of each slice on the circumference.

 

Maybe I need to find the circumference first then divide it out by 20.

Then find what each one would be spaced out on the circumference.

Then some how use that number with a formula to find my x and y?

Edited by Shadowing
Link to comment
https://forums.phpfreaks.com/topic/300807-math-god-needed/#findComment-1531109
Share on other sites

All you need is theta. You have 20 objects so theta will start at zero and increase by 2*PI/20 for each one. Then, as in the diagram, if the circle has radius R and its centre is at cx,cy the x,y coordinates for each object are

x = cx + R * cos(theta)
y = cy - R * sin(theta)
Link to comment
https://forums.phpfreaks.com/topic/300807-math-god-needed/#findComment-1531110
Share on other sites

Here's an example

<?php
$width = 140;
$height = 140;
$rad = 60;
$dtheta = M_PI/10;

$im = "<svg width=\"$width\" height=\"$height\" viewBox=\"0 0 $width $height\" >\n
        <rect x='1' y='1' width='$width' height='$height' fill='black' />\n
        <g transform='translate(70,70)'>\n
        <circle cx='0' cy='0' r='$rad' stroke='white' fill='none' />\n";
for  ($theta=0; $theta<2*M_PI; $theta+=$dtheta) {
    $x = $rad*cos($theta);
    $y = $rad*sin($theta);
    $im .= "<circle cx='$x' cy='$y' r='5' fill='cyan' />\n";
}      
$im .= "</g></svg>\n";

echo $im;
?>

post-3105-0-25896600-1455486128_thumb.png

  • Like 2
Link to comment
https://forums.phpfreaks.com/topic/300807-math-god-needed/#findComment-1531115
Share on other sites

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.