Results 1 to 6 of 6

Math Help - Defining the quadrant of an angle within the equation

  1. #1
    Newbie
    Joined
    Jan 2014
    From
    Somerset
    Posts
    6

    Defining the quadrant of an angle within the equation

    So I have to scale down a triangle in space to have a preset hypotinuse (i.e. shrinking a line and keeping the angle).
    initially I came up with (see case1.bmp).
    but this only allows for triangles in northwest. so I came up with (see case2b.bmp) to output the point on bothe sides.
    I have now hit the problem of if the moving point (Mx,My) has the same x value as the start point (Sx,Sy) then my method for picking the side becomes 0/0 which throws up errors everywhere.
    Anyone have an alternative method of doing this or have an equation that if a<b=-1 and if a>b=1? (I don't care what happens when a=b (0/0) because cos(Theta) will be 0 anyway.)
    Attached Thumbnails Attached Thumbnails Defining the quadrant of an angle within the equation-case1.bmp   Defining the quadrant of an angle within the equation-case2b.bmp  
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member
    Joined
    Dec 2012
    From
    Athens, OH, USA
    Posts
    709
    Thanks
    294

    Re: Defining the quadrant of an angle within the equation

    Hi,
    The attachment answers your problem. It shows the 4 possible locations of your angle theta, but the method indicated works regardless of the location of point M with respect to point S (the two points must be different).

    Defining the quadrant of an angle within the equation-mhfgeometry59.png
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie
    Joined
    Jan 2014
    From
    Somerset
    Posts
    6

    Re: Defining the quadrant of an angle within the equation

    Quote Originally Posted by johng View Post
    Hi,
    The attachment answers your problem. It shows the 4 possible locations of your angle theta, but the method indicated works regardless of the location of point M with respect to point S (the two points must be different).

    Click image for larger version. 

Name:	MHFgeometry59.png 
Views:	8 
Size:	19.7 KB 
ID:	30020
    that still has an if statement though.
    maybe I am looking at this wrong.
    What about determining the line Y=M*X+C that crosses (Mx,My) and (Sx,Sy) and calculating point P on that line?
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Super Member
    Joined
    Dec 2012
    From
    Athens, OH, USA
    Posts
    709
    Thanks
    294

    Re: Defining the quadrant of an angle within the equation

    Hi again,
    I assumed that your question was a programming problem in my previous response. Here is Java code implementing what I said earlier:

    Code:
      /* standardAngle computes and returns the angle from 0 to 2*pi of the 
         vector from (cx,cy) to (x1,y1).  However if the two points are the 
         same, a return of 0.
      */
      private double standardAngle(double x1, double y1, double cx, double cy) {
        double x, y, v, d;
        x = x1 - cx;
        y = y1 - cy;
        d = Math.sqrt(x * x + y * y);
        if (d == 0) {
          return (-1);
        }
        v = Math.acos(x / d);
        if (y < 0) {
          v = 2 * Math.PI - v;
        }
        return (v);
      }
    
      // assuming the variables are defined:
      double theta = standardAngle(mx, my, sx, sy);
      it (theta != -1) {
        px = sx + r * Math.cos(theta);
        py = sy + r * Math.sin(theta);
      }
      else {
        // some default action for the two points the same
      }
    Now as far as using the line from (sx,sy) to (mx,my) to intersect with the circle to find the desired point, yes, you can do it this way:

    First handle the case where sx=mx (vertical line).

    Otherwise, m={my-sy\over mx-sx},\,\, d=-m(sx)+sy

    Next substitute into the equation of the circle (x-sx)^2+(y-sy)^2=r^2

    to get the quadratic equation: (m^2+1)x^2+(-2sx+2m(d-sy))x+(sx)^2+(d-sy)^2-r^2=0

    Use the quadratic formula to solve this last equation. By the nature of the problem, there will be two solutions, say x1 and x2. You can decide which is the desired value by:
    if ((x1-sx)*(mx-sx) is positive)
    px = x1 is the correct x value
    else
    px = x2 is the correct x value.
    Once the correct x value is found, use the line equation to find the y value.

    If you encode all of the above, you'll probably get at least as much code as what I gave at the beginning. One possible advantage of this approach is that no transcendental function calls are made. However, I have found the standardAngle function useful in other contexts.
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Super Member
    Joined
    Dec 2012
    From
    Athens, OH, USA
    Posts
    709
    Thanks
    294

    Re: Defining the quadrant of an angle within the equation

    Hi again,
    It occurred to me that you might know about the parametric equation of a line. If you do, then the attachment shows yet a further solution to your problem:

    Defining the quadrant of an angle within the equation-mhfgeometry61.png
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Jan 2014
    From
    Somerset
    Posts
    6

    Re: Defining the quadrant of an angle within the equation

    Quote Originally Posted by johng View Post
    Hi again,
    It occurred to me that you might know about the parametric equation of a line. If you do, then the attachment shows yet a further solution to your problem:

    Click image for larger version. 

Name:	MHFgeometry61.png 
Views:	5 
Size:	18.2 KB 
ID:	30035
    Thanks I will try that.
    this is not a programing problem but it is a problem I have to solve repeatedly so I am trying to set up a single equation in MathCAD where I can just change the inputs of Mx and My and take the outputs of Px and Py without having to check if Mx is greater than Sx etc
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. determine the quadrant in which an angle lies. help!
    Posted in the Pre-Calculus Forum
    Replies: 7
    Last Post: April 19th 2012, 03:16 PM
  2. Name The Quadrant in which The Angle lies.
    Posted in the Trigonometry Forum
    Replies: 5
    Last Post: April 12th 2012, 05:05 PM
  3. Finding quadrant for a half angle.
    Posted in the Trigonometry Forum
    Replies: 2
    Last Post: October 25th 2010, 09:03 AM
  4. Equation of a quadrant (of a circle)
    Posted in the Advanced Algebra Forum
    Replies: 3
    Last Post: September 3rd 2010, 11:14 AM
  5. Replies: 3
    Last Post: March 17th 2010, 03:22 AM

Search Tags


/mathhelpforum @mathhelpforum