# Math help

**URL:** https://forum.kirupa.com/t/math-help/319264
**Category:** Uncategorized
**Created:** [February 14, 2011, 5:41pm UTC](https://forum.kirupa.com/t/math-help/319264 "2011-02-14T17:41:52Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![kill\_robot\_kill](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/kill_robot_kill/32/359_2.png) [@kill\_robot\_kill](https://forum.kirupa.com/u/kill_robot_kill)
#### Post date: [February 14, 2011, 5:41pm UTC](https://forum.kirupa.com/t/math-help/319264/1 "2011-02-14T17:41:52Z")

</div>

sigh…hey guess what that stuff you sleep through in those math classes you don’t want to take may actually come in handy…needless to say I was the one sleeping.

here’s what I’d like to do:  
I am creating a ‘word map’ brainstorming chart. Basically you type an idea into a bubble, then click a button that will add a sub-bubble of that brainstormed idea. [Example](http://1.bp.blogspot.com/_XVvKQQWEds4/R0hlviyA7OI/AAAAAAAACBQ/iX4KvL22gIE/s320/word%2Bmap.GIF)

I’ll need to generate a random X/Y within a set of boundaries (the stage) that is determined by the parent bubble’s X/Y and a maximum buffer X/Y so the bubbles are grouped nicely together.

```auto

var bnd_Left = 10;
var bnd_Top = 10;
var bnd_Right = 290;
var bnd_Bottom = 290;
//
var parentBubble = 150;
var buffer = 50;
//
X = Math.floor(Math.random()*(1+bnd_Right-bnd_Left))+bnd_Left;
Y = Math.floor(Math.random()*(1+bnd_Bottom-bnd_Top))+bnd_Top;

```

So I have my stage boundaries 300x300 stage with a 10 pixel buffer. The original bubble is at 150x150. The example above works, it will give me a random X/Y, but there is no limit of the number generated there is then no organization to it, so I need to limit the X/Y by adding the restrictions of the parentBubble X/Y as the starting point so that the bubbles will radiate out in 50 pixel increments
