Results 1 to 15 of 15

Thread: Intersections

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    4

    Intersections

    Hi, I hope someone can help me figure out the solution to this problem. I have four ultrasound receivers positioned along two axis. These are the black dots on the blue and orange lines. From these I get a pair of distance measurements a & b from the origin. From these I want to work out an intersection position x,y.

    The axis of the receivers is fixed at the angle A= B from the X,Y plane. Should be easy, but my trig is so rusty and I'm so much more concerned with the electronics I hoped a maths guru could point me in the right direction!


  2. #2
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    391

    Re: Intersections

    Hi, here's my attempt (I hope I understood the problem correctly). Hopfefully others will take a look and check for errors or offer alternative solutions (probably less complicated and cluttered )

    I have attached a new illustration to make it easier to follow my approach to the problem. I used greek letters in the illustration but I don't know how to write them here so I just spell them out. Sorry about that, hopefully it's clear enough. Also, there may be some constraints on this solution as far as what angle ranges it is valid but this may give you a start.

    Notation:

    a the distance given from the origin along the first receiver axis.
    b the distance given from the origin along the second receiver axis

    ax the projection of a along the x-axis.
    bx the projection of b along the x-axis.

    alpha the angle between the x axis and the first receiver axis
    beta the angle between the x-axis and the second receiver axis

    l (lowercase L) extends from the points (-ax, 0) to (bx, 0) on the x-axis

    c the segment from point (-ax,0) to (x,y)

    d the segment from point (bx, 0) to (x,y)

    (note: l, c, and d form a triangle)

    delta the angle opposite side d

    gamma the angle opposite side c

    lambda the angle opposite side l

    cx the length of side c projected along the x-axis
    cy the length of side c projected along the y-axis

    omega the angle made between side c and cy

    ===

    calculations

    delta = pi/2 - alpha
    gamma = pi/2 - beta = pi/2 - alpha

    so delta = alpha

    lambda = pi - delta - gamma = pi - 2(delta) = pi - 2(pi/2 - alpha)
    lambda = 2 alpha


    ax = a/cos(alpha)
    bx = b/cos(beta) = b/cos(alpha)

    l = ax + bx

    omega = pi/2 - delta = pi/2 - (pi/2 - alpha) = alpha
    omega = alpha

    Now we can calculate the point (x,y) by the fact that

    x = -ax + cx
    y = -cy

    First calculate side c:

    By law of sines we have

    l/sin(lambda) = c/sin(gamma)

    c = [sin(gamma)/sin(lambda)] * l

    since gamma = pi/2 - alpha and sin(pi/2 -alpha) = cos(alpha)
    sin(gamma) = cos(alpha)

    and lambda = 2alpha, substituting gives

    c = cos(alpha)/sin(2*alpha) * l

    now we can calculate cx and cy by

    cx = c * sin(omega) = c * sin(alpha)
    cy = c * cos(omega) = c * cos(alpha)

    now you can use these values to compute x and y by the equations above
    x = -ax + cx
    y = -cy
    Attached Images Attached Images  
    Last edited by wy125; Nov 14th, 2008 at 04:06 PM.

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    4

    Re: Intersections

    Perhaps I should try and explain the origin of the diagram a bit more. I have four fixed-position Ultrasound receivers (labelled RX) and one moving transmitter (labelled TX). I already do a little bit of trig to work out the distance in mm along each axis (o->A o->B) using the difference in time of flight. If the geometry of the four RX units was set out in a simple 90 degree cross, the job would be done and my two distance measurements would be my final x,y coordinate.

    Unfortunately the application dictates the geometry I've shown in the diagram. At least the radius R is identical for all for RX units as is the angle theta from the X and Y axis.

    [/QUOTE]

    I obviously need to do some more trig using R, theta, A & B to get my final x,y but I can't see how to go about it.

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    4

    Re: Intersections

    Thankyou wy125 - you posted your reply while I was preparing my second diagram. I think you've interpreted it correctly anyway, and I will have a good look at your solution now. I may ask questions afterwards!

  5. #5
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    391

    Re: Intersections

    Okay sure thing. Can I ask what you're using this for? It sounds very interesting....

  6. #6
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Intersections

    L1(x) = orange line = mx
    L2(x) = blue line = -mx
    Green line attached to blue line intersects that line at a distance b from the origin going right. This occurs when distance[(L2(x0), x0), origin] = b, or when x0^2+m^2x0^2 = (1+m^2)x0^2 = b^2 -> x0 = b/sqrt(1+m^2). Similarly this happens for the other line (the x coordinate of the intersection is unchanged).

    Now construct a line through the point of intersection on the blue line perpendicular to it. This is just P2(x) = x/m + q2 for some q2. Solve for q2: P1(x0) = L1(x0). Similarly P1(x) = -x/m + q2, solving for q2 in the same way.

    From here, intersect lines P1 and P2 to get the x coordinate, and then plug that in to either to find the y coordinate.

    Plugging the above in to Mathematica with m = sin theta, I got

    x = -(1/4) (a + b) (-3 + Cos[2 Theta]) Sec[Theta]
    y = -(1/2) (a - b) (-3 + Cos[2 Theta]) Csc[2 Theta]


    Note that I've taken a and be to be signed distances. If they correspond to moving to the left, they should be negative, positive to the right.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  7. #7
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    391

    Re: Intersections

    Quote Originally Posted by jemidiah
    Plugging the above in to Mathematica with m = sin theta, I got
    Shouldn't you use m = tan(theta)?

  8. #8
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Intersections

    Blargh. Yup, it should be. Will redo it more rigorously later.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  9. #9
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Intersections

    Below is my redo of this problem with the proper slope and better naming conventions. I just did it in Mathematica because it can do the mundane intersection stuff easily. The syntax should be pretty intuitive, and the comments descriptive enough.

    This leads to the answer:
    x = 1/2 (dblue+dorange) Sec(theta)
    y = 1/2 (-dblue+dorange) Csc(theta)

    dblue and dorange are just a and b, but renamed so that dblue is the distance from the origin on the blue line, and similarly with dorange.

    Name:  Lines.jpg
Views: 177
Size:  127.2 KB
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  10. #10
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    391

    Re: Intersections

    Thought it would be interesting to compare our results:

    After substituting and simplifying I get:

    X = (b - a)/2 * sec(alpha)
    Y = -(a + b)/2 * csc(alpha)


    It looks we have the same form but signs are off. I'll take a look a bit further.... Are we using the same sign conventions?



    Calculations:
    X = -ax + cx = -a/cos(alpha) + c * sin(alpha)
    X = -a/cos(alpha) + l *cos(alpha)*sin(alpha)/sin(2*alpha)

    using sin(2*alpha) = 2 * sin(alpha)*cos(alpha) gives

    X = -a/cos(alpha) + l/2

    substituting l = ax + bx = a/cos(alpha) + b/cos(alpha) gives

    X = -a/cos(alpha) + [a/cos(alpha) + b/cos(alpha)]/2
    X = [b/cos(alpha) - a/cos(alpha)]/2

    X = (b - a)/2 * sec(alpha)


    and

    Y = -cy = -c *cos(alpha) = -l *cos(alpha)/sin(2*alpha) * cos(alpha)
    Y = -l/2 *cos(alpha)/sin(alpha)
    substituting for l = a/cos(alpha) + b/cos(alpha) gives

    Y = -(a + b)/2 * csc(alpha)
    Last edited by wy125; Nov 15th, 2008 at 10:58 AM.

  11. #11
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Intersections

    Interesting, if we differ in the sign of our a's our answers agree. I got to looking at these lines:

    ax = a/cos(alpha)
    bx = b/cos(beta) = b/cos(alpha)

    Shouldn't it be times cos(alpha) instead of divided by? This way ax will be a larger number than a violating the triangle inequality, I think. If this is indeed the difference it's amazing it came out to just a sign convention.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  12. #12
    Hyperactive Member
    Join Date
    Mar 2002
    Location
    Boston, MA
    Posts
    391

    Re: Intersections

    no, the divided by is right. Perhaps my notation isn't clear but ax and bx are the distances along the x-axis from the origin made by the perpendicular lines extended from the orange and blue lines. They do not represent the x coordinates of a and b. ax and bx are the hypotenuses in their respective triangles.

    In your notation, are a and b positive when they extend toward negative y along the orange and blue lines (just like in the drawing legion drew)?

  13. #13
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Intersections

    Ah, I see it now. In my notation, a and b are positive when they extend towards positive x; I guess I disregarded the initial drawing as just an arbitrarily drawn example instead of something representing the usual state of the system (i.e. one where having positive coordinates would be convenient).

    If yours require extending negative y to be [edit]positive[/edit], then one of ours should have a reverse sign convention--dorange or a, in fact. So we agree
    Last edited by jemidiah; Nov 16th, 2008 at 06:15 PM.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  14. #14
    I don't do your homework! opus's Avatar
    Join Date
    Jun 2000
    Location
    Good Old Europe
    Posts
    3,863

    Re: Intersections

    That really sounds loke the old Hyperbolic fixing, sorry I don't have the formulas for that. I learned to solve using pencil, divider and "try and error".

    However, I have one question: Do you really have only the time-difference between the receptions or do you also have the complete time a signal took to get to any of the recievers. Having the later, the problem would be easily solved, without any *big* mathematic stuff.
    You're welcome to rate this post!
    If your problem is solved, please use the Mark thread as resolved button


    Wait, I'm too old to hurry!

  15. #15

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    4

    Re: Intersections

    wy125,

    X = (b - a)/2 * sec(alpha)
    Y = -(a + b)/2 * csc(alpha)

    Seems to do the trick, very pleased indeed! jemidiah, thanks for checking it out as well.

    opus, I do have the discrete arrival times to all four sensors - I started out with two sensors, and hence two path times two opposite ends of a baseline using the following to get X,Y: (hope it's right!)

    D=baseline
    A2=path1*path1
    B2=path2*path2
    X=(D*D-B2+A2)/(2*D)
    Y=SQRT(A2-(X*X))
    X=X-(D/2)


    Then I wanted to go full 3D by adding another pair like the first, but the geometry of the space available didn't allow for the second pair to be set at 90 deg and on the same baseline - so I had the idea to use them at a cross angle.

    I have an application in which I want to create a 3D space above a midi keyboard (wide but not very deep) for gesture control.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width