Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Ask HN: Anyone Have Expertise in Trigonometry?
17 points by clumsycomputer on Sept 19, 2022 | hide | past | favorite | 20 comments
howdy hn

im looking to collaborate with someone who is passionate about trigonometry, computational geometry, or just math in general! im trying to figure out if the white dot in the animation linked below can be computed in constant time, and if not what is the best that can be done? all the code i write these days is open-source, and i believe cracking this nut will go a long way for many!! any takers??

loop anatomy animation:

https://youtube.com/shorts/M83QFzrcnlc?feature=share



Considering that only one of those circles' radius is variable, and the other two circles intersect with the yellow loop, you can determine the equation of the yellow loop, which will give you the position of the white point, at any time, in constant time.


your reply certainly gives me hope that its possible, though i fear i've stared at this diagram for too long and am having difficulty viewing it with a fresh perspective.

some additional context.

im constructing the loop (yellow) with the black dots, which im computing in constant time. the dynamic circle (blue) is being constructed from the two static circles (pink, orange). the white dot is currently being computed by sweeping the already computed loop points from the center of the small circle (pink).

are there any laws or key points that may help me along? are there any similar problems that are well documented that you are aware of?

thanks


Did you make the animation or you found it somewhere in the internet?

Do you have a formula for each of these things?

What do you mean by "constant time"? From your description it seams all the points have a closed formula, there are no iterative steps that may be long? Do you want a simpler direct formula?


hi gus

the animation is something i constructed in order to help facilitate discussion and get help :)

i've outlined the computations more detail in a reply below

by constant time i mean O(1)

computing the white dot currently requires me to sweep the already computed loop points which isn't a big deal in a lot of use cases, but with audio its a show stopper

the white dot is also the key to a much more complex computation that im using


> by constant time i mean O(1)

O(1) in what?


Can you explain the formula or model for the white dot?


i'll do my best

1. define the base circle (orange)

2. define the sub circle (pink)

3. compute the range of the intersection circle's radius (blue)

4. compute the loop points (yellow)

   4A. compute intersection circle along range defined in 3

   4B. compute the intersection angle between base and intersection circles relative to the center of the intersection/sub circle (law of cosines)

   4C. compute the intersection point with intersection angle (green on blue & orange)

   4D. compute sub point with intersection angle (green on pink)

   4E. compute the loop point with the x component from intersection point (4C) and the y component from sub point (4D)
5. compute the trace point at trace angle (white)

   5A. trace the already computed loop points searching for the the two points where the trace angle fits between

   5B. compute the intersection between the line composed of the two matching loop points and the trace line originating at the sub circle's center with an angle of the trace angle
its a generalization of the drawing by Fritz Hügelschäffer linked below

http://www.mathematische-basteleien.de/eggcurves.htm#:~:text....


It sounds like you want a point with argument theta such that a bunch of constraints are satisfied. I don't think you'll easily be able to find a general polar "r(theta)=...", since your curve is defined by a "sweep" of other non-trivial function outputs (i.e. the intersection of two circles), which is another way of saying "solve for x in f(x)=0 where f(x) is complicated".

I would be inclined to use a non-linear solver, which will will almost certainly converage within 2 or 3 iterations especially if you're starting with a good initial estimate from time=t-1. 40khz should not be a problem.

You can start with scipy.optimize, and look into ceres if you need something faster.


thank you for the pointers

i don't have much formal math training, but have used scipy a handful to times successfully for other problems. optimize is new to me, but ill throw some things into and see what comes out


I was going to write that it's almost impossible that there is a closed O(1) formula for this, but after reading that the egg of Fritz Hügelschäffer is a cubic, I think there is hope. If your yellow curve is also a cubic, then it's solvable, but the formula for the exact solution is horrible. https://en.wikipedia.org/wiki/Cubic_equation#Cardano's_formu...

I prefer the lazy approach :) . The only hard step is 5B. How are you computing the intersection? Are you using a linear search in the angle? Can you use binary search? Probably the secant method is faster https://en.wikipedia.org/wiki/Secant_method but binary search is more foolproof.


its at least cubic, but the loop here is generalized farther where the sub circle can be phase. so i don't know???

linear search in angle i believe, though depending on the use case i hold onto the index of the last matched point making the next search O(1)

thanks for introducing me to the secant method. at the very least it will help me think about it differently


Fixup: 5B -> 5A


If you can't figure it out, memoize the results in a table and interpolate.


I'd start by running the table through a curve-fitting program to see if it finds a simple formula like the OP is seeking. I've used this paid app https://www.curveexpert.net/products/curveexpert-professiona... but there are also free curve-fitting web apps out there.


awesome thanks for the recommendation

my only worry about curve fitting is that the recommended function won't generalize to other loop configurations


I'm admittedly hazy on the exact work you're doing, but if you mean the other configurations will change the curve, you could try (1) tweaking your program to output tables of a few examples (2) using curve-fitting app to get a fit for each table (3) looking if it found an equation that matched all of them (making a note, for each example, of which coefficients it plugged into the equation).


that sounds like something i haven't tried and may yield results

gracias


i have an implementation that does something along those lines, which suffices for graphics but doesn't work well for audio applications. think 48 000 samples per second.

the computation i've outlined in the animation is also just a small but very important piece of a much more complex computation

this white dot is my bottle neck


you forgot to mention the pay rate?


haha fair question... i'm hoping to find someone who will donate their time as i am doing myself. its important that improvements to the current solution i have remain in the open and free to use. otherwise said help may be counterproductive and even destructive




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: