[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can anyone help me fix my circle math?



PureBytes Links

Trading Reference Links

Gary Fritz wrote:

I am taking the sine of 180* times the index value which is from 0 to
1 instead of taking sine of the angle. This index is a linear
function,
for starters then, note that the sine function is very non-linear, so why involve it in some kind of an index calculation that you want to have linear behavior.

As Gary says below, perhaps if you would better describe what you are trying to accomplish graphically, then others could help with solutions. You don't have to describe your trading methodology if you don't want to, just what the info it is you have available at the time you want to start drawing and what it is you want to see pictorially based on that info.

Rod G.

and 180* this = angle at 0*, 90*, etc. but not in between.
Problem is I don't know how to convert the linear index into the
appropriate angle. Any ideas?

I'm not real clear on what you're doing. Are you saying your index goes from 0 at the point on the right side of the circle, 0.5 at the circle center, and 1 at the left side? So 180* this index gets you the correct angle at 0, 90, and 180?

If so, that's basically just luck. That linear index has no direct relationship to the angle.

Let's see, to map that index to angle... first I would map the index to -1 .. +1, corresponding to the cosine of the angle. So let's say NewIndex = 1-2*OldIndex. Take the arc cosine of the NewIndex and you'll have the angle. Take the sine of that and you have the vertical offset for your circle at that point. (No square roots!!) Actually you divide the sine by 2 because the radius of your circle is 0.5, not 1, since it goes from 0 on one side to 1 on the other.

So:
NewIndex = 1-2*OldIndex { cos of the angle at that x position }
Angle = arccos(NewIndex) { the angle }
Yoffset = sine(Angle)/2
plot1(Centerprice + Yoffset);
plot2(Centerprice - Yoffset);

That gets you a lovely circle. At least in Excel.

Problem: TS doesn't seem to have arccos. Maybe it's just too early on a Sunday morning to think that hard, but I can't see how to calculate arccos using arctan or other available functions. You could approximate it with a Taylor series, but I don't know if you want to work that hard. :-) Maybe somebody else can help on that one.

Gary