Re: Solving Triangles
- From: "Steve Gerrard" <mynamehere@xxxxxxxxxxx>
- Date: Sat, 28 Jan 2006 20:52:00 -0800
"Rick Rothstein [MVP - Visual Basic]" <rickNOSPAMnews@xxxxxxxxxxxxxxxxx> wrote
in message news:A_CdnTueb8q_2kHeRVn-hA@xxxxxxxxxxxxxx
>
> It is not advisable to test the contents of a Double variable for equality
> to zero. Here is an example why...
> ...
> If Abs(Dx) < 1e-13 Then
Always worth it to raise that point.
In fact, the OP's code will throw a "divide by zero" error if Dx is 0:
> If Dx > 0 Then Bearing = (Atn(Dy / Dx) * DegConv) + 90
> If Dx < 0 Then Bearing = (Atn(Dy / Dx) * DegConv) + 270
>
> If Dx = 0 Then
So it would be better to rewrite the code
If Dx > 1E-13 then
Bearing =(Atn(Dy / Dx) * DegConv) + 90
ElseIf Dx < 1E-13 Then
Bearing = (Atn(Dy / Dx) * DegConv) + 270
ElseIf Dy < 1E-13
Then Bearing = 0
ElseIf Dy > 1E-13
Then Bearing = 180
Else
' not moving...
Bearing = 999.999
End If
.
- Follow-Ups:
- Re: Solving Triangles
- From: Rick Rothstein [MVP - Visual Basic]
- Re: Solving Triangles
- References:
- Solving Triangles
- From: Desertphile
- Re: Solving Triangles
- From: Rick Rothstein [MVP - Visual Basic]
- Re: Solving Triangles
- From: Desertphile
- Re: Solving Triangles
- From: Steve Gerrard
- Re: Solving Triangles
- From: Desertphile
- Re: Solving Triangles
- From: Desertphile
- Re: Solving Triangles
- From: Rick Rothstein [MVP - Visual Basic]
- Solving Triangles
- Prev by Date: Re: Baffled or Buffered?
- Next by Date: Re: Using the printer object
- Previous by thread: Re: Solving Triangles
- Next by thread: Re: Solving Triangles
- Index(es):
Relevant Pages
|