Re: Trigonometry problem
- From: "Rick Rothstein \(MVP - VB\)" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx>
- Date: Sat, 25 Nov 2006 10:45:32 -0500
@Rick:
Your Function has a small bug somewhere, using it with
negative arguments. If you paste your Code into my
example form (commenting mine out) you can see this.
Good catch! Here is the revised function that eliminates the bug...
Private Function TriangleWave(ByVal Angle) As Single
Const PI As Double = 3.14159265358979
Const HALFPI As Double = PI / 2
TriangleWave = Sgn(Sin(Angle - HALFPI - (Angle < 0) * PI)) * _
(Abs((1 + 2 * Int((Abs(Angle) + HALFPI) / PI)) * _
HALFPI) - Abs(Angle) - HALFPI) / HALFPI
End Function
Rick
.
- References:
- Trigonometry problem
- From: Larry Serflaten
- Re: Trigonometry problem
- From: Larry Serflaten
- Re: Trigonometry problem
- From: Schmidt
- Re: Trigonometry problem
- From: Larry Serflaten
- Re: Trigonometry problem
- From: Schmidt
- Trigonometry problem
- Prev by Date: Re: .Net = 90MB+, 30 seconds longer+, Internet Explorer IS spyware
- Next by Date: Re: How to read from USB port?
- Previous by thread: Re: Trigonometry problem
- Next by thread: Open file dialog
- Index(es):