Results 1 to 7 of 7

Math Help - Getting an angle from a curve and a straight line

  1. #1
    Newbie
    Joined
    Dec 2011
    Posts
    3

    Getting an angle from a curve and a straight line

    Ok, first things first. I'm a programmer, I'm actually working on a flash game and I'm always having a bad time trying to understand maths.

    What I'm trying to create here is an archer autonomously firing on a target using the right angle. The problem is, I can't manage to get that angle. I've tried tons of stuff to no avail so I shall put this into a simple drawing.

    Getting an angle from a curve and a straight line-mathproblem.png


    I have two points, A and B. I have the distance, which is X as well as the curve, that forms a circle, this circle's diameter being Y. Now what I lack is, the angle between the line and the curve at point A (?).

    Also, note that I'm not really good at maths, if at all. I may not understand complex terms and such.

    Well this is it. Thanks to whoever solves this or tries solving it!

    Also, if you need more information about my little problem just ask away as I'm aware that the info I gave may not be adequate.
    Last edited by drak68; December 23rd 2011 at 01:22 AM.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4

    Re: Getting an angle from a curve and a straight line

    Quote Originally Posted by drak68 View Post
    Ok, first things first. I'm a programmer, I'm actually working on a flash game and I'm always having a bad time trying to understand maths.

    What I'm trying to create here is an archer autonomously firing on a target using the right angle. The problem is, I can't manage to get that angle. I've tried tons of stuff to no avail so I shall put this into a simple drawing.

    Click image for larger version. 

Name:	MathProblem.png 
Views:	64 
Size:	7.7 KB 
ID:	23128


    I have two points, A and B. I have the distance, which is X as well as the curve, that forms a circle, this circle's diameter being Y. Now what I lack is, the angle between the line and the curve at point A (?).

    Also, note that I'm not really good at maths, if at all. I may not understand complex terms and such.

    Well this is it. Thanks to whoever solves this or tries solving it!

    Also, if you need more information about my little problem just ask away as I'm aware that the info I gave may not be adequate.
    Why are you using a circular arc for the trajectory?

    CB
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor

    Joined
    Apr 2005
    Posts
    16,233
    Thanks
    1795

    Re: Getting an angle from a curve and a straight line

    Unless you have, for some reason, decided you must use a semi-circular trajectory for your arrow, this is not so much a math problem as a physics problem. Physically, the trajectory, neglecting air resistance, is a parabola.

    Neglecting air resistance, the only force on the arrow is gravity, straight downward. That means the arrow has a downward acceleration of -g (g= 9.81 approximately) and 0 horizontal accelration: a_x=\frac{dv_x}{dt}= 0 and a_y= \frac{dv_y}{dt}= -g so v_x= v_0cos(\theta) and v_y= -gt+ v_0sin(\theta) where v_0 is the initial speed of the arrow and \theta is the angle.

    Now, v_x= \frac{dx}{dt}= v_0cos(\theta) and v_y= \frac{dy}{dt}= -gt+ v_0sin(\theta) so x= v_0cos(\theta)t and y= -\frac{g}{2}t^2+ v_0sin(\theta)t where I have taken the initial position of the arrow, the position of the archer, to be (0, 0). If you want other coordinates, add them.

    To determine the angle, \theta, you need to know two things in advance- the initial velocity of the arrow, v_0, and the distance from the archer to the target, X. Solve both x= v_0cos(\theta)t= X and y= -gt^2+ v_0sin(\theta)t= 0 for t. That's easy: from the first equation, t= \frac{X}{v_0cos(\theta)} and from the second, t(-gt+ v_0sin(\theta))= 0 so either t= 0 (the arrow was fired from height 0 so we get the initial time as a solution) or t= \frac{v_0sin(\theta)}{g}. Since you want the arrow to be at (X, 0) for one t, those must be the same: \frac{X}{v_0cos(\theta)}= \frac{v_0sin(\theta)}{g} which is the same as sin(\theta)cos(\theta)= \frac{gX}{v_0^2}.

    You can simplify that using the trig identity sin(2\theta)= 2 sin(\theta)cos(\theta) so that sin(\theta)cos(\theta)= \frac{1}{2}sin(2\theta)= \frac{gX}{v_0^2}. That is, \theta= \frac{1}{2}arcsin\left(\frac{gX}{2v_0^2}\right)

    Note that since sine cannot be larger than 1, if X is too large or v_0 is not large enough, this may be impossible- X is "out of range". Also, it will typically happen that there are two angles, between 0 and 90 degrees, that satisfy that equation.

    If you really want to use a circular trajectory, you can do this:
    Let r be the radius of the circle (so that Y= 2r). Drawing radii from the center of the circle to the endpoints of X, we have an isosceles triangle with two sides of length r and one of length X. Applying the cosine rule to that triangle, The angle at the center of the circle, \theta, satisfies X^2= 2r^2(1- cos(\theta)) so that \theta= arccos(1- \frac{X^2}{2r^2}). Writing the two "base" angles as \phi, we have, of course, 2\phi+ \theta= 2\pi so that \phi= \pi- \frac{\theta}{2}. The angle the circle makes with line X is the complement of that: \frac{\pi}{2}- \phi= \frac{\theta}{2}- \frac{\pi}{2}= \frac{1}{2}arccos(1- \frac{X^2}{2r^2})- \frac{\pi}{2}.

    That is in radians, of course.
    Last edited by HallsofIvy; December 23rd 2011 at 10:01 AM.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member ILikeSerena's Avatar
    Joined
    Dec 2011
    Posts
    733
    Thanks
    121

    Re: Getting an angle from a curve and a straight line

    The (parabola) trajectory is documented in wikipedia:


    The angle is documented as:
    \theta = {1\over 2}\arcsin({gX \over v_o^2})
    where g=9.81 {m \over s^2} and v_o is the initial speed.
    Last edited by ILikeSerena; December 23rd 2011 at 06:43 AM.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie
    Joined
    Dec 2011
    Posts
    3

    Re: Getting an angle from a curve and a straight line

    I've been using a circle because the arrow DOES makes a circle in the game. There is no gravity applied to it or anything, just a constant rotation and acceleration towards its current angle, which makes circles. I know its clearly not the best way to simulate projectiles but I felt like messing with gravity wasn't really a good idea, or just really time consuming for just a small part of the game.

    As for , it didn't work, probably because I'm not using gravity at all, or flash is just doing wierd stuff when trying to make complex equations.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Super Member ILikeSerena's Avatar
    Joined
    Dec 2011
    Posts
    733
    Thanks
    121

    Re: Getting an angle from a curve and a straight line

    All right.

    The angle that you ask for is:
    \theta = 90^o - \arccos({X \over Y})
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Dec 2011
    Posts
    3

    Re: Getting an angle from a curve and a straight line

    Wow. That actually worked. Thanks a lot I've been having headaches over this for weeks!
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Replies: 1
    Last Post: October 18th 2011, 12:45 PM
  2. [SOLVED] Line Integral along a straight line.
    Posted in the Calculus Forum
    Replies: 1
    Last Post: April 11th 2011, 08:18 PM
  3. Find the angle between two straight lines
    Posted in the Pre-Calculus Forum
    Replies: 5
    Last Post: November 14th 2010, 05:50 PM
  4. Replies: 18
    Last Post: October 17th 2010, 09:33 AM
  5. angle between straight lines
    Posted in the Algebra Forum
    Replies: 2
    Last Post: March 17th 2010, 10:01 AM

Search Tags


/mathhelpforum @mathhelpforum