Results 1 to 6 of 6

Thread: Vector intersecting an arc.

  1. #1

    Vector intersecting an arc.

    I'm calculating a parabola, and need to figure out where a vector would intersect it and at what angle - This is for a lens evaluation program I'm writing and as such I need to know the angle so I can caluclate the reflection (which should be the opposite side of the normal from the intersection on the parabola)

    Anybody got a clue?
    The accessibility of a website from time to time must be refreshed with the blood of designers and owners. It is its natural manure

  2. #2

    Vector intersecting an arc.

    are we talking 3d or 2d?
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  3. #3

    Vector intersecting an arc.

    Quote Originally Posted by JSoftware
    are we talking 3d or 2d?
    2d is sufficient - if I can figure out 2d, 3d is simple.
    The accessibility of a website from time to time must be refreshed with the blood of designers and owners. It is its natural manure

  4. #4

    Vector intersecting an arc.

    Parabola:
    y=ax^2+bx+c
    Ray:
    P=(t*s+x, u*s+y)

    [pascal]function rayIntersect(a,b,c,t,u,x,y: single): single;
    var d,s: single;
    begin
    d := sqrt(power(b*t+2*a*x*t-u,2)-4*a*t*t*(a*x*x+b*x+c-y));
    s := -b*t-2*a*x*t+u;
    result := min(s-d,s+d)/(2*a*t*t);
    end;

    function rayNormalSlope(a,b,x: single): single;
    begin
    result:=1/(2*a*x+b);
    end;
    [/pascal]

    rayIntersect will find the parameter s for the ray which will indicate the nearest intersection point.

    rayNormalSlope will indicate the slope of the normal at a certain x value on the parabola. Knowing all this it should be trivial to calculate the reflection

    Edit: This code is very unsafe, and unoptimized. You should check if values are inside the range of the used functions
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

  5. #5

    Vector intersecting an arc.

    Ok, you've got a few more variables in there than I'm used to seeing... I'm not entirely certain where t, u, b and c come into this.

    right now, I'm calculating my parabola

    y=ax^2

    where A is half the distance between the focus and the directrix...

    with the 'ray' I have the origin (x,y) and the slope (s)... not certain how to plug that in to what you posted as I've no clue what t and u are in your example.

    is u in your example simply 1/t? What are your b and c defined as?

    ... and thanks for the help - I've got a very basic understanding of what I'm trying to do here... A LOT of the formula's in the books on the subject seem to prattle on and on about theory without any examples of actual application. (Yes, I'm an impatient sort who threw away the 'users guide' in the TP releases and dove right for the 'language reference' book)
    The accessibility of a website from time to time must be refreshed with the blood of designers and owners. It is its natural manure

  6. #6

    Vector intersecting an arc.

    You can discard the b and c parameters as they only have something to do with the placement of the parabola.

    t and u is the "velocity" of the point of the ray. You can indeed just set t=1 and u=s
    Peregrinus, expectavi pedes meos in cymbalis
    Nullus norvegicorum sole urinat

Bookmarks

Posting Permissions

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