# Trigonometric problem - help with angles

**URL:** <https://forum.kirupa.com/t/trigonometric-problem-help-with-angles/270514>\
**Category:** flash\
**Created:** [September 10, 2008, 5:02pm UTC](https://forum.kirupa.com/t/trigonometric-problem-help-with-angles/270514 "2008-09-10T17:02:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedro\_paulo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/pedro_paulo/32/2017_2.png) [@pedro\_paulo](https://forum.kirupa.com/u/pedro_paulo)\
**Post date:** [September 10, 2008, 5:02pm UTC](https://forum.kirupa.com/t/trigonometric-problem-help-with-angles/270514/1 "2008-09-10T17:02:27Z")

</div>

Hy, guys.

I´m writing some classes to help me with my trigonometric works in flash.  
I´he stopped at a question wich is taken my sleep. What I want to do is to take a point “A”, wich is inside a rectangular area. And than, with an angle “n”, calculate an ending point “B”. This end point B is at the border of my rectangular area.

The question is that, deppending on the position of the point “A” and the dimensions of my area, sometimes I have to use the sin and sometimes the cosin of the angle.

But I do not know wich one to use. Because the “A” point is not at the center of a square area. And I do not want to do a “fake” hitTest in a “enter\_frame” event handler.

The images bellow help to ilustrate my doubt.

1. Here, the easy step: the distance based on an angle:  
 ![](http://www.ppwebart.com/wmonline/simple_angle_distance_calculating.jpg)

Now the problem A. Here the solution is with the adjacent side of the triangle:  
 ![](http://www.ppwebart.com/wmonline/distance_with_box_limit_adjacent.jpg)

And with this angle, I need to use the opposite side of the triangle:  
 ![](http://www.ppwebart.com/wmonline/distance_with_box_limit_opposite.jpg)

Is there an Math solution to this, instead of use loopings to calculate and check the last possible position inside the area?

Thanks, guys!

pp
