The DataCAD Developer Network (DDN) is an online resource for information and support for DCAL® (DataCAD Applications Language) developers as well as anyone interested in creating fonts, toolbars, hatch patterns, or linetypes for use in DataCAD.
#76967 by dhs
Fri Sep 13, 2019 6:16 pm
Note: this was my mistake: the dis_from_seg and dis_from_line functions work correctly (see next post)
Hi,
In the scenario I outline below it appears that dis_from_seg is returning an incorrect distance:

Pnt1.x = 28416, Pnt1.y = 10240
Pnt2.x = 24576, Pnt2.y = 11392
TstPnt.x = 25600, TestPnt.y = 11136
(values are in DataCADs 1/32" units, z value of all points is zero)

dis_from_seg (Pnt1, Pnt2, TstPnt) is returning a value of 2404.99 (about 6' 3 5/8"). I have tried the dis_from_line function and it also returns this same result.

My own calculations give a result that the point is 49.0407058 (DataCad units ... about 1 17/32") from the line.
Using Measures/PointToPoint function in DataCAD (and clicking on the perpendicular point on the line as near as I can) shows the test point is 1 17/32" from the line (which agrees with my calculations).

Attached below is a screen shot from my debugging of this problem in Delphi. The DisFromPolyvert function on line 1238 is my own function, but it simply calls dis_from_seg for straight sides. I have checked this as you can see from the Evaluate/Modify window whereI have evaluated dis_from_seg with the same result. Values are shown in the Watch List window.

I can't see anything wrong with my logic, and it appears to me that dis_from_seg is returning an incorrect value. Perhaps I am missing something, so if anybody has any comments or suggestions I would be grateful of your input!
Attachments
DisFromSeg.png
DisFromSeg.png (65.58 KiB) Viewed 6311 times
Last edited by dhs on Sat Sep 14, 2019 2:26 pm, edited 1 time in total.
#76968 by dhs
Fri Sep 13, 2019 9:18 pm
ok. problem sorted ...

there is not a bug with dis_from_seg, it was just that I had forgotten that this function returns the square of the distance (and not the actual distance).

In my example, dis_from_seg was returning 2404.99 ... which is extremely close to the square of the distance that I calculated.

Who is online

Users browsing this forum: No registered users and 7 guests

About DataCAD Forum

The DataCAD Forum is a FREE online community we provide to enhance your experience with DataCAD.

We hope you'll visit often to get answers, share ideas, and interact with other DataCAD users around the world.

DataCAD

Software for Architects Since 1984