I do apologise if the problem sounds a bit confusing, it's not a complicated question, I will make it short as possible.
I am trying to archive an ellipse parameterisation, with a reference to SVG implementation notes I met a problem using arc cos
According to the equation of compute angle between two vectors, I have two sets of vectors, which I would like to work out the angle between.
Perhaps it's due to precision loss, I had to solve a weird bug, it turns out that, sometimes, I need to work out the arc sin of for example, -1.0002, which breaks my function and return a value of NaN. I have very limited knowledge about arc sin, quickly I used demos tools, y = arccosx and it turns out arc cos has a domain [-1, 1].
Now I think I only have two ways to go:
- for $f(x) = arcos(x)$, if x is out of range, then assign x to the limit value, either 1 or -1;
- do a few Math.PI*1/2 calculation, convert x into the domain of [-1, 1], work out the arc cos.
Could someone please suggest one way to go, if you can provide me some calculations of work out
- f(x) = arc cos(x), x ∉ [-1, 1]
I will be so grateful for your help.