TranslateCoordinates troubles

TranslateCoordinates troubles

Anonymous
Not applicable
236 Views
2 Replies
Message 1 of 3

TranslateCoordinates troubles

Anonymous
Not applicable
I'm trying to translate coordinates that I've picked using GetPoint from WCS coords to the current UCS, so I can then compare the X value for equivalency in the working coordinate system, but, even though OrthoMode is on, I'm getting a difference of 0.00000000001 between the two. I'm trying to test for perfect vertical positioning between the two points, which it should be given that OrthoMode is on, yet this inaccuracy is throwing it out.

Is there any way to kill off this inaccuracy in translation, or should I just round it off to a few less decimal places before comparing the values?

Thanks in advance,
Mick.
0 Likes
237 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Hi Mick, The best way to compare two real values is with code like: If Abs(Var1 - Var2) < 0.0001 (or what ever) Then ' the values are the same. -- Laurie Comerford CADApps www.cadapps.com.au "MickyV" wrote in message news:25750930.1081304976866.JavaMail.jive@jiveforum2.autodesk.com... > I'm trying to translate coordinates that I've picked using GetPoint from WCS coords to the current UCS, so I can then compare the X value for equivalency in the working coordinate system, but, even though OrthoMode is on, I'm getting a difference of 0.00000000001 between the two. I'm trying to test for perfect vertical positioning between the two points, which it should be given that OrthoMode is on, yet this inaccuracy is throwing it out. > > Is there any way to kill off this inaccuracy in translation, or should I just round it off to a few less decimal places before comparing the values? > > Thanks in advance, > Mick.
0 Likes
Message 3 of 3

Anonymous
Not applicable
I agree. I've written substitute functions for using when comparing reals, not only for equality but other comparisons. For example if you only want to do something if one value is greater than another you need to make sure it's *really* greater and not just a rounding discrepancy. Here are a couple of them:

[pre]
Const NEGLIGIBLE As Single = 0.005
'
Private Function Equal(var1 As Variant, var2 As Variant) As Boolean
Equal = Abs(var1 - var2) < NEGLIGIBLE
End Function
'
Private Function FirstIsGreater(FirstVar As Variant, SecondVar As Variant) As Boolean
FirstIsGreater = FirstVar - SecondVar > NEGLIGIBLE
End Function
[/pre]

Regards

Wayne Ivory
IT Analyst Programmer
Wespine Industries Pty Ltd
0 Likes