Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Graphics math.

by Limbic~Region (Chancellor)
on Jun 04, 2015 at 14:55 UTC ( [id://1129063] : note . print w/replies, xml ) Need Help??


in reply to Graphics math.

BrowserUk,
Is what you are asking:

Given two equations for ellipses, is there a way to construct a third equation that only represents the intersection/overlap of the two ellipses?

I know in your real problem you are dealing with more than two ellipses but I want to make sure I understand the question before I invest any additional effort.

Cheers - L~R

Replies are listed 'Best First'.
Re^2: Graphics math.
by BrowserUk (Patriarch) on Jun 04, 2015 at 15:48 UTC
    Is what you are asking: Given two equations for ellipses, is there a way to construct a third equation that only represents the intersection/overlap of the two ellipses?

    No. Not the intersection; but rather the entire combined area. Without the first notion of how that might be possible.

    I'm a mathematician in the same way that I'm a plumber or electrician or car mechanic; I generally have the ability to lookup enough information to allow me to solve my immediate problem; but ask me about it a month or so from now and I probably can't explain how I did it.

    Years ago I was asked to give a financial type help with a spreadsheet he was developing for shares. He wanted to isolate the intersections/overlaps between 3 or more spot price curves. He had an line-fitting algorithm that approximated a given curve by producing some kind of multi-term polynomial. The first term approximated the line crudely; the second term refined it; the third refined the results of the second and so on. His task was to combine the polynomials from the 3 or more spot-price curves into a single polynomial, and then iterate it between predefined limits. It was complex stuff that I won't pretend to understand.

    However, what I was able to do was help him redefine his formulae, extracting common sub-terms and the like, that resulted in a 8 times reduction in his spreadsheet run times (measured in hours). Then, when he'd proven that what he was doing had some merit, I coded up a program in C to do the same calculations, that cut that time by almost another order of magnitude. I didn't have to understand the formulae; just be able to code up the parts and execute them in the right order to produce the same output for the given inputs.

    From 4+ hours to just over 3 minutes. Still too slow to inform spot price dealers; but with today's hardware they are probably doing the same stuff millisecond by millisecond in automated traders.

    And it was with that in mind that I thought that there might be some way to pre-process the equations of a bunch of ellipses into a polynomial whereby the first term would put (say)90% of points in or out; then the second term 90% of what's left; and so on. With short circuiting, that might be faster than testing every point against every ellipse individually.

    I still think there is some possibility of deriving the polynomial; but I am simply not equipped with the tuits to see how to even begin such a thing.

    Similarly for the two ancillary questions at the bottom of the OP.

    I can, by projection of stuff I've seen done in other fields (maps and the like), see that both are probably feasible -- if a blind mathematician can turn a sphere inside-out without breaking the surface (topologically speaking); then mapping a multi-segment curve to a straight line is probably child's play. If you're the right child. I'm not. (Either a child or the right one :)


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
    In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked
      BrowserUk,
      I think I understand now. The financial stuff you were talking about was probably some form of regression analysis using the least squares method. I don't think that would work for your problem because your lines curve back under themselves though you might treat them as a few lines and have it work.

      My apologies for not providing anything more concrete but a post to one of the math related reddits may provide insight (/r/math, /r/learnmath, /r/matheducation, /r/EngineeringStudents, /r/AskEngineers

      Cheers - L~R

        I don't think that would work for your problem because your lines curve back under themselves

        You're probably right -- certainly about attempting to line fit -- but another bulb in my brain makes me think of Lissajous curve; whereby the formulae for sin() and cos() are combined to produce curves that loop back on themselves; often many times depending upon the frequency differential.


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I'm with torvalds on this
        In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked