Inside Hatches, more than meets the eye

Discussion forum for contributors and developers who are using the QCAD ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

CVH
Premier Member
Posts: 672
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Inside Hatches, more than meets the eye

Post by CVH » Tue Jan 14, 2020 4:22 pm

Hi all,
I was working at a scaled output for Tile2Hatch. 8)
An add-on to turn anything you like in a hatch.
One day we will all create a hatch pattern in a few clicks.
(Like me and John do nowadays)

We used a common 6/8 decimal digit scheme with rather good looking patterns in inch.
For metric users the patterns are scaled by 25.4 and then the problems start to rise.
Something times 25.4 will always take more space to write down with the same accuracy.
The patterns are limited to 80 characters per definition line. :(
In short these are arraged as: Angle, startX, startY, dXshift, dXoffset, dash1, dash2, ... dash6

So I investigated many different strategies.
At a point I wondered if we could reduce the angle accuracy, but no, on the contrary.
Later on I looked over the hedge: :wink:
https://www.hatchkit.com.au/faq.php

In the first section one can read what a less good defined hatch pattern will do far away from the origin.
These guys say this is related to the accuracy of dXoffset and dash2. e_ugeek
What they leave out is that this is also true for the Angle.
Their example with Angle = 0 is not revealing that on purpose, protectionism. :twisted:
By luck a pattern sourced online is made by hatchkit: YUKONRUBBLE
https://qcad.org/rsforum/viewtopic.php? ... 610#p25610 and further.

Learned some more from it but I am not very pleased with the heavy reduction in accuracy for the position and dash1.
With 3 or less decimal digits we are back where we started. :|

At some points I came accross only some segments that failed casted far away even with rather good accuracy. :shock:
Included is a dxf with the Qcad Logo by John. Don't ask me what revision, it doesn't care.
TryoutImperial.dxf
(231.77 KiB) Downloaded 68 times

At 10000 units away from the origin it still looks ok apart from one single segment.
All other segments are also shifted somewhat but that is hardly noticeable.

Also notice the boundary crossings!! :oops:
Don't know what is going on here, that is for Andrew's to worry about.
PainterPaths is something that sits deep inside the Qcad forrest. :roll:

Why that 1 segment stands out is that it has a quite large dxshift at line 101, almost maxed out.
Instead of shifting the definition 48.79548753 one way we equally could shift it -1.41407331 the other way.
In se, that and using the endpoint is the only difference between the two pattern files apart from the name.
Included both pat files.

I will have to spend more research on that, if I can spare the time.
CVH
Attachments
QCAD-LOGOr.pat
(6.72 KiB) Downloaded 68 times
QCAD-LOGO.pat
(6.71 KiB) Downloaded 63 times
QCADpro 3.24.3.0 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

CVH
Premier Member
Posts: 672
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Re: Inside Hatches, more than meets the eye

Post by CVH » Tue Jan 14, 2020 8:44 pm

Confirmed:
Using -180-0-180 does not solves this.
Saw that the guys of hatchkit used positive and negative 180 degrees.

The trick is still reversing the definition with an opposed shift.
When? When not?

"-180" : that are 4 digits!! 360 is one less...to use elsewhere.
Caught them on a loose stitch.
Leading zero's is a second one.

From initial state Tile2Hatch used getNormalizedAngle => 0-359,99999 degrees

Regards
CVH
QCADpro 3.24.3.0 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Wed Jan 15, 2020 12:17 am

Hi CVH
I see you're still busy on this...
I don't know much about the maths involved
But I'm wandering why the AC tools work in a grid snap when creating the tile, could it be the answer?
The only drawback on this is you are limited by snap points...the lisp file you sent me works the same way.
What do you think?
Your tool produces really nice patterns but maybe we need to stick with simpler patterns because of this drawback..
Did you try my original pattern shipped with Qcad 3.24?
Does this have the same errors!
As far as the maths goes unfortunately I'm not much help.. it's way beyond me..
Hopefully you'll solve this soon.. it's a very promising addition to Qcad..

Cheers
John
PS the qcadlogo Andrew has is the original, the ones I have sent to you were modified to try out your tool..I have not reposted this one..
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Wed Jan 15, 2020 12:35 am

See Images Below:
Attachments
QCAD-LOGO-NEW - Generated with Tile2Hatch.jpg
QCAD-LOGO-NEW - Generated with Tile2Hatch.jpg (229.95 KiB) Viewed 2341 times
QCAD-LOGO - Generated with AC Tool.jpg
QCAD-LOGO - Generated with AC Tool.jpg (213.21 KiB) Viewed 2343 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Wed Jan 15, 2020 1:05 am

Hi CVH

See Below:
Hatch Patterns That Need to be Redone:-
Bubbles-01 ( not included in qcad build ) disaster at 100000,100000
Bubbles-02 ( not included in qcad build ) disaster at 100000,100000
Leaf-01 ( not included in qcad build ) disaster at 100000,100000
Leaf-02 ( not included in qcad build ) disaster at 100000,100000
Leaf-03 ( not included in qcad build ) disaster at 100000,100000
QCAD-LOGO ( Included in qcad build ) 1 line out of position at 100000,100000 ( but in AutoCAD is Okay? )
Squiggle-01 ( Included in qcad build ) disaster at 100000,100000
Squiggle-02 ( Included in qcad build ) disaster at 100000,100000
Weaving ( not included in qcad build )

I will fix these up in the next few days using grid method, I'll repost in the Hatch Patterns Section
All the other patterns seem ok, ones that have straight lines and not curvy looking, the current
QCAD-LOGO seems ok, it was created using a snap to grid pattern .. ( but when shifted 100000, 100000 , 1 line on the pencil seems to shift?)
All the QCAD-LOGOS that I used for testing were only meant for CVH ( private emails ! ) not to be shared publicly same as his program is used
for testing, I have never at any time updated the QCAD_LOGO and CVH the dig you have at me about
Revisions is not nice at all, typically through AutoCad History they have changed patterns and Never marked
revisions on them, Drawings yes..should Qcad put revisions also on line command if it changes Line-R1, LINE-R2 ..I don't think so..
Please also try and not be so condescending, I don't say anything when you
make mistakes in your Tile2Hatch program as you have done!

Sorry to all users for the inconvenience ..
Cheers
John
Attachments
AutoCAD-QCAD-LOGO Original Created by Lisp File Closeup.jpg
AutoCAD-QCAD-LOGO Original Created by Lisp File Closeup.jpg (140.99 KiB) Viewed 2310 times
QCAD-LOGO - in AutoCAD.jpg
QCAD-LOGO - in AutoCAD.jpg (249.34 KiB) Viewed 2312 times
Current QCAD-LOGO.jpg
Current QCAD-LOGO.jpg (199.2 KiB) Viewed 2326 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

CVH
Premier Member
Posts: 672
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Re: Inside Hatches, more than meets the eye

Post by CVH » Wed Jan 15, 2020 8:24 am

Jhon,
hold your horses.

It is not a flaw in any of the generators.

It has nothing to do with using a grid like structure.
In fact, you can't avoid using a grid or you get an endless system.
Numbers will grow exponetional and are no longer handled correct.
Together with increasing numbers, the accuracy has to drops.
There is no room for several long numbers in 80 chars.
Another tradeoff to make.

Allready one thing sticks out:
John Hyslop wrote:
Wed Jan 15, 2020 1:05 am
but in AutoCAD is Okay?
Why they get faster out of sync is not clear.
That they do is only just discovered.
Eventually they all get out of sync if your stretch it to absurd limits.
We need examples, thrashing them won't solve anything.

It seems that the solution is simple.
And you can spot them at the instant there are defined.
A rathter large dXshift compared with the sum of the absolute dashes.
I even have a better parameter but that will say less to an outsider.
Its angle related...

I will PM or mail you the work around.
Simple summing, addition and subtraction and picking the endpoint.
I will have to check the 'sticking out' type for that first.

If that solves it in these cases I can integrate the solution.....
+
In the end we will have to abandon the 6/8 scheme.

Work in progress,
cheers,
CVH
QCADpro 3.24.3.0 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

CVH
Premier Member
Posts: 672
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Re: Inside Hatches, more than meets the eye

Post by CVH » Wed Jan 15, 2020 2:11 pm

dXshift Fix.dxf
(221.06 KiB) Downloaded 68 times
This explains a lot about the shifting of line 101 of that specific QCAD-LOGO. :!:
But not why it works with a reversed dXshift....
Nor that it works plain in AC.
That could be Qcad related.... :?:

A: We need a far better accuracy for very small dYoffsets. e_geek
What counts here are the significant digits, not the decimal digits.
How small dYoffset gets is related to how many cloned rays go through one and the same tile.
And this is related to the specifics of the orientation.
Altering the Angle a tiny bit may have a large influence.
(E.g. At 315° instead of 315.8... there is only one clone crossing not 71)

B: We need a far better accuracy for the Angle. e_geek
C: We need a far better accuracy for the repetition, what is the sum of the dashes. e_geek
One of two will do: dash1 or dash2.
Best is to reduce the accuracy of dash1 (Segment length) and increase that of dash2.
D: We need the same accuracy as in C for the dXshift.
Why the Hatckit guys get away with less, I can't tell yet. :?
That is what I think that the difference is between Qcad and AC. :(

Downer: We will have to take these digits from startX & startY.

Just thinking: .... What is the purpose of a 1EE-8 accuracy of endpoints inside a 1 by 1 unit Tile.
On top of that comes that the absolute fault is not multplied here.
I think an accuracy of 1EE-4% should be sufficient.
At least it is 100 times better then the AC generators have. :wink:
They work in a 0,01 cartesian grid. Resolution = 1EE-2.

Regards,
CVH
QCADpro 3.24.3.0 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

CVH
Premier Member
Posts: 672
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Re: Inside Hatches, more than meets the eye

Post by CVH » Thu Jan 16, 2020 11:32 am

CVH wrote:
Tue Jan 14, 2020 4:22 pm
At some points I came accross only some segments that failed casted far away even with rather good accuracy.
Included is a dxf with the Qcad Logo by John. Don't ask me what revision, it doesn't care.
From John Hyslop posts I understand he is greatly offended with the fact that I used an example provide by him.
It wasn't meant as criticism on the pattern, the creator nor the engine.
It was to point out something very peculiar.

Which happens to occur also in some of his novel and unique pieces.
I could have used a non-coherent bunch of lines instead.
Where nobody could see the cumulative error but me.

I presented him my profound apologies in private.
And by this I redo that in public.
I should not have used that. I am very sorry.

Testing involves tryouts.
Tryouts or revisions.
I have a ton of those. About 30 Logos's.
There were not enough letters in the alphabet as index.
Can't tell anymore which is which.
It might I had overwritten a few by accident.
In the end it did not care. “ It did not matter “
It is the peculiarity that matters.

There is nothing wrong with revisions.
We revise things to do them better.
Revisions are the second nature of open source.

But in the end:
I should not have used anything that is another man's work.
Not the pattern, not Qcad, not my PC nor the electricity it runs on.

Regards,
CVH
QCADpro 3.24.3.0 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Fri Jan 17, 2020 7:17 am

Hi CVH

I just downloaded your example dxf and QCAD-LOGOr.PAT
It has just as many errors as the original at that origin e_confused .. see
screen shot.... out of 45 patterns I've made I've removed 9 from my posts
Mainly the ones that simulate curves 8 made with Tile2Hatch and yes the AC tool is no better
in Qcad anyway QCAD-LOGO was made with this.. the rest of my patterns seem ok
Maybe dxftiles are a good idea after all, and keep patterns for basic shapes
Funny if you google about entities far away from the origin point there are lots of
problems rendering in AC etc ....Well onward and upward :-) hopefully you can work out
what is going on with the large shifts etc...
Most people wouldn't work so far away from Origin but I see your point :o
Attachments
QCAD-LOGOr.jpg
QCAD-LOGOr.jpg (236.81 KiB) Viewed 2166 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Fri Jan 17, 2020 7:49 am

Even AR-CONC Fails at this origin and that's a standard pattern e_surprised
Attachments
AR-CONC.jpg
AR-CONC.jpg (142.25 KiB) Viewed 2159 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Fri Jan 17, 2020 8:07 am

Hi CVH

You may of stumbled across a bug e_surprised see AR-CONC at 1000000,1000000 in AutoCAD 2020
Attachments
AR-CONC - AutoCAD 2020.jpg
AR-CONC - AutoCAD 2020.jpg (157.31 KiB) Viewed 2157 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Fri Jan 17, 2020 8:34 am

Hi CVH

Just doing some more investigations on PAT files... see the differences between the AC one and Qcad
AC have more decimal places and also as I've said before they store all there hatch patterns in one file called acadiso.pat
Cannot upload this as it has a big copyright notice at the beginning of the file ... I'll try cutting and pasting a test file to see
if Qcad renders it properly at 1000000,1000000 ...keep up the good work :)
Attachments
AC - PAT v Qcad PAT.jpg
AC - PAT v Qcad PAT.jpg (144.02 KiB) Viewed 2152 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Fri Jan 17, 2020 8:43 am

Hi CVH

Here is an example using the AutoCad Hatch I renamed it AR-CONC2 sorry can't upload .. copyrights
Qcad still has trouble with the Triangles Yet in AC it's Perfect? e_confused

I'll keep testing :-)
Attachments
Errors Connecting Triangles.jpg
Errors Connecting Triangles.jpg (30.66 KiB) Viewed 2152 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

John Hyslop
Premier Member
Posts: 173
Joined: Mon Sep 30, 2019 6:21 am
Location: Melbourne - Australia

Re: Inside Hatches, more than meets the eye

Post by John Hyslop » Fri Jan 17, 2020 9:06 am

Hi CVH

You have a lot of reading to catch up on lol see above.... I couldn't resist opening your dxf file in autocad
look at the patterns !! what's going on here... e_confused original QCAD-LOGO and AR-CONC at 1000000,1000000
PERFECT
Attachments
QCAD_LOGO in AutoCAD 2020.jpg
QCAD_LOGO in AutoCAD 2020.jpg (240.74 KiB) Viewed 2143 times
QCAD-LOGO and AR-CONC in AC.jpg
QCAD-LOGO and AR-CONC in AC.jpg (254.13 KiB) Viewed 2148 times
IF IT IS TO BE IT IS UP TO ME [ Ten most powerful 2 letter words ]

CVH
Premier Member
Posts: 672
Joined: Wed Sep 27, 2017 4:17 pm
Location: Belgium; Antwerp

Re: Inside Hatches, more than meets the eye

Post by CVH » Fri Jan 17, 2020 10:25 am

John, all,

Or one uses a cartesian grid to draw in, lets say 0.01 x 0.01 units.
Or one uses a Tile-grid, equally lets say 100x100 Tiles.
In a unit square the first option is also a 100x100 grid.
In the second option there is no limit on the accuracy of the reference...
(Except the decimal digits that can be stored, see lower)

In the limit there can run 99 parallel clones through the same Tile.
Because of the endless repetive nature that counts for any Tile, anywhere.

In a unit square dYoffset is then something 1...1.4142 divided by 99.
With 12 digits : 0.01xxxxxxxxxy
1000000 tiles away that is at max 99000000 clones.
It becomes 1xxxxx.xxxxy
Times the repetitions what is more vage because that relies on the segment data.
Its kind of a tradeof depending the angle.
But even with 100000 we already get 1xxxxxxxxxy.000
Or meaning that the error gets larger as a Tile.

Its kind of obvious that we are hitting limits.
- for the integer part we go to infinity.
- for the accuracy we go to zero or much more.

The Hatctkit guys increase the decimal digits in those cases only.
it seems AC handles the 14 decimal digits.
for Qcad the question was out:
https://qcad.org/rsforum/viewtopic.php?f=33&t=6893
The answer is just in.

It is 15(.95) significant digits....
....puzzled but I think it fits

CVH
QCADpro 3.24.3.0 / win7pro 32 bit / 4GB / 1e generation i7 2.6Ghz / HDD GeForce GT 520

Post Reply

Return to “QCAD Developers and Contributors”