Re: Tough problem...



The solution is not to pass a large argument in the first place,
which can often be achieved if you're dealing with a "physical"
problem (in opposition to "mathematical" problem). The "how" will
depend on the problem, and can range from separating values
(number of rotations + angle instead of an absolute angle) to
transforming the math (using trigonometric formulas, quaternions,
etc.), using a converging series or introducing a well chosen
approximation.

This situation occurs in FFT, when the length of the FFT goes in to
million of points. The sin and cos functions become inaccurate when
the i in sin(i*arg) goes in to millions.

Try something like this:

Angle := 0;
for I := 0 to 100000 do
begin
MySin := Sin(Angle);

Angle := Angle + arg;
while Angle >= 2 * Pi do
Angle := Angle - 2 * Pi;
end;

--
The Fastcode Project: http://www.fastcodeproject.org/
.



Relevant Pages

  • Re: Interpretation of FFT phase
    ... > I am trying to see if the phase of the FFT of a signal I am analizing ... part looks to be numerical junk (eg. if fft has some roundoff error). ... I'm afraid that's what you get when you use computers:( ... When computing the angle, the amplitude is normalized out so eg. ...
    (comp.soft-sys.matlab)
  • Re: Tough problem...
    ... and can range from separating values (number of rotations + angle ... instead of an absolute angle) to transforming the math (using ... This situation occurs in FFT, when the length of the FFT goes in to ...
    (borland.public.delphi.language.basm)
  • Re: dotproduct rotations
    ... The angle returned is the smallest angle between the two vectors, ... need an additional sign check on one of the original vector's axis to decide ... Microsoft DirectX MVP, ... now the rotations around the y axis work perfectly but the rotations ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: How to calculate the angle between two images?
    ... angle of 'twist' between a known reference image and a rotated image was accomplished very reliably even for arbitrary images. ... rotations, such as 45 degrees, where some information is rotated ...
    (comp.soft-sys.matlab)
  • Re: Rotations - why are they not vectors
    ... through an angle in 1 dimension?) ... For that it is not unreasonablke for me to expect ... What is unclear about "1-D rotations about a fixed axis"? ... specified by a 1-tuple x a linear displacement. ...
    (sci.math)