# Math problem

**URL:** <https://forum.kirupa.com/t/math-problem/331591>\
**Category:** Uncategorized\
**Created:** [September 6, 2013, 3:52am UTC](https://forum.kirupa.com/t/math-problem/331591 "2013-09-06T03:52:02Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tompa](https://avatars.discourse-cdn.com/v4/letter/t/6de8d8/32.png) [@Tompa](https://forum.kirupa.com/u/Tompa)\
**Post date:** [September 6, 2013, 3:52am UTC](https://forum.kirupa.com/t/math-problem/331591/1 "2013-09-06T03:52:02Z")

</div>

![](http://forum.kirupa.com/uploads/kirupa/6699/72d5ab00856be902.jpg)

_(Just to clarify: I want the blue box to be placed like the brown box)_

I am calculating the angle from\*\* point A(green) \*\*to \*\*point B(center)  
\*\*

```auto

bluebox.x = (greendot.x - bluebox.width) + (Math.cos(angle) * (bluebox.width * 0.5));
bluebox.y = (greendot.y - bluebox.height) + (Math.sin(angle) * (bluebox.height * 0.5));

```

If the blue box was an circle instead, my example would work\* (edge to edge),  
\*but now when I’m using squares instead, this problem occurs.

Any tips on how I can solve this is very appreciated!

\*Thanks in advance,  
Tompa  
\*
