Hi,
The issue at hand is simple:
I have two vectors (a1, a2) that define the principal axes of an ellipse like this
Now I have a third vector (v) that somewhere lies within the plane of the ellipse, like this
All right. I need to know if the vector is within the ellipse itself.
So I do the dotproduct a1.v/|a1|/|v| to find cos(theta), because by definition a1.v = |a1||v|cos(theta).
Now here the trouble starts.This cos(theta) can be extracted pretty precise. However I need sin(theta) as well, which I do by sin(acos(cos(theta))). This sin(theta) is disgustingly inaccurate,
even when using long doubles.
I need it because the check I want to perform is |a1|*cos(theta)+|a2|*sin(theta) > |v|, namely that v is within the ellipse.
I get results like for |a1|=|a2|=0.5 that 0.47+0.14 > |v|, which anyone can see is not the correct result for any angle applied to the above formula. So I can only guess that severe rounding errors were made.
The questions are:
-Why is a standard math.h function so poor?
-Is there any other way to perform a cos(theta) to sin(theta) switch?
-Is there any other way in general?