A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: [RESOLVED] How do you get a unique ID from two numbers w/o ordering them?

Hybrid View

  1. #1
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    I think this needs some special kind of space filling curve to solve this, if it's even possible at all.
    who is this? a word of friendly advice: FFS stop using AS2

  2. #2
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136

    Question

    this gave me an idea... since I'm only looking at one quadrant, what if I took the radius of the circle needed to touch both (x,y) and (y,x)...I mean, just the hypotenuse of a right triangle touching either point... plus the sine times cosine of the vector... wouldn't that give a unique identifier?

    like...

    (x^2+y^2)+( SIN(ATAN(x/y)) * COS(ATAN(x/y)) )

    everything right of the decimal point would be descriptive of the vector, unique because of the phase difference and because we're only dealing with one quadrant... everything left of the decimal point would be a whole integer hypotenuse^2...

  3. #3
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    [edit: plotted it, and it looks like it should work...?]
    Last edited by joshstrike; 11-26-2009 at 07:44 PM.

  4. #4
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    (x^2+y^2)+( SIN(ATAN(x/y)) * COS(ATAN(x/y)) )
    unfortunately no, it does not depend on how much of full plane you use, as long as there's infinite amount of numbers. take a look at the graph, and especially contour plot of your function below - every curve on contour plot represents a set of (x,y) points that evaluate in the same value.
    Attached Images Attached Images
    who is this? a word of friendly advice: FFS stop using AS2

  5. #5
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    yes... I know they're circular... but is there ever more than one pair of whole integers described? I mean, could any two integers produce the same result as any other two integers, so that
    [ f(x1,y1) , f(y1,x1) ] == [ f(x2,y2) , f(y2,x2) ] ?
    If not... then this would satisfy to give a unique identifier of two ID's combined...

  6. #6
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    aah, integers - I kinda thought of any real numbers. it might work with integers, indeed, maybe run 100000x100000 check loop? if you have a couple of hours to waste
    who is this? a word of friendly advice: FFS stop using AS2

  7. #7
    Senior Member joshstrike's Avatar
    Join Date
    Jan 2001
    Location
    Alhama de Granada, España
    Posts
    1,136
    It works, at least to 1000 x 1000...and I don't see why it wouldn't work infinitely =)

    It also works to produce unique identifiers for reversible combinations of more than two integers, like this:

    [unique floating id from a set of three integers]
    (a^2+b^2+c^2)+( sin(atan(a/b))*cos(atan(a/b))*sin(atan(a/c))*cos(atan(a/c))*sin(atan(b/c))*cos(atan(b/c)) )

    Solved!

  8. #8
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    btw,


    which means, SIN(ATAN(x/y)) * COS(ATAN(x/y)) = TAN (ATAN (x/y)) / (1 + TAN^2 (ATAN(x/y))) = (x/y) / (1 + (x/y)^2) = (x * y) / (x^2 + y^2), right?
    Last edited by realMakc; 11-27-2009 at 03:51 PM.
    who is this? a word of friendly advice: FFS stop using AS2

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

HTML5 Development Center