Author Topic: Another Step Forward  (Read 70575 times)

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #30 on: January 10, 2009, 02:29:42 PM »
Derek,

The new drawing logic seems to be working well.

By the way, I came up with a fairly straightforward way for FCB to create a .KT3 file which can be loaded into KnotTyer3D.

For this to work, your SPart tile should only be used to indicate the SPart of a rope.  When the user places one or more SPart tiles on the diagram, store the locations (e.g. "fan").  Let's assume that there is one SPart tile on the diagram, and it's the north-pointing tile.

To create the coordinates for KnotTyer3D, simply assign a multiple of 10 to each row and column in the FCB diagram (a=10, b=20, c=30, etc.).

Now, if the SPart tile has a value of "fan" in FCB (i.e. the north-pointing SPart tile is at location "fa"), then the first .KT3 coordinates are:  60, 10, 0 (the third value will always be 0 unless a section of rope is traveling *behind* another section of rope).

Since the SPart tile is pointing north, the next tile in sequence will be at "fb" (i.e. just below the SPart tile).  You'll need to keep track of which direction the rope is traveling at each step.  If the "fb" tile is a vertical strand of rope, for example, then the next tile in sequence is at "fc" (the same is true if the "fb" tile is one of the crossing tiles).  If the "fc" tile curves to the west then the direction has changed, so the next tile is at "ec", and so on.  Using this approach, you can programmatically follow the rope through all of its gyrations, building a sequence of coordinates in the proper order.  The order in which the user placed the FCB tiles makes no difference, because at each step you simply need to scan through FCB's list of coordinates (for each color) looking for the appropriate location (e.g. "ec") in order to find out which tile is at that location.

With the exception of the curved tiles, the .KT3 coordinates are very simple.  The first two values will always be the numeric equivalents for the column and row (e.g. "60, 20" if the tile is at "fb").  The third value in the .KT3 coordinates will always be 0 unless the tile is a crossing tile and the rope is traveling in a direction which will take it *behind* a section of rope, in which case the third value needs to be -1.

For a curved tile, we need to create three .KT3 coordinates based on the direction in which the rope is traveling.  In the following instructions, "c" refers to the numeric column value of the curved tile (e.g. f=60) and "r" refers to the numeric row value.  "Upper right" refers to the curved tile in the FCB pallet which is in the upper right corner of the four curved tiles.

-- For the "upper right" curved tile:
If the rope is traveling north, then the .KT3 coordinates are:
c, r+4, 0
c-2, r+2, 0
c-4, r, 0

If the rope is traveling east, then the .KT3 coordinates are:
c-4, r, 0
c-2, r+2, 0
c, r+4, 0

-- For the "upper left" curved tile:
If the rope is traveling east, then the .KT3 coordinates are:
c+4, r, 0
c+2, r+2, 0
c, r+4, 0

If the rope is traveling north, then the .KT3 coordinates are:
c, r+4, 0
c+2, r+2, 0
c+4, r, 0

-- For the "lower left" curved tile:
If the rope is traveling south, then the .KT3 coordinates are:
c, r-4, 0
c+2, r-2, 0
c+4, r, 0

If the rope is traveling west, then the .KT3 coordinates are:
c+4, r, 0
c+2, r-2, 0
c, r-4, 0

-- For the "lower right" curved tile:
If the rope is traveling east, then the .KT3 coordinates are:
c-4, r, 0
c-2, r-2, 0
c, r-4, 0

If the rope is traveling south, then the .KT3 coordinates are:
c, r-4, 0
c-2, r-2, 0
c-4, r, 0


When there are no more FCB tiles to process then you're done.  If you come to a WEnd tile then write the coordinates for that tile (e.g. "70, 80, 0" if the WEnd tile is at "gh").

That's all there is to it!  Simply provide a button which prompts the user for a filename, then write the KnotTyer3D coordinates to the file using a .KT3 extension, then the file can be loaded into KnotTyer3D (for a single rope, it usually looks best if you use the "Rainbow" option in KnotTyer3D).

If the user placed a second SPart tile then write "C" to the output file to indicate a new rope ("C" stands for "Color").  Then follow the above logic to write the coordinates for the second rope.  This will cause both ropes to be drawn simultaneously in KnotTyer3D.  Use "CF" instead of "C" if you want the first rope to be drawn before the second rope.  Use "CJ" (or "CFJ") if you want the first rope to be a closed loop such as a sling ("J" stands for "Join").

For a spar, first write out the KnotTyer3D coordinates of the spar just as if it were a rope.  Then use "CF" and write out the KnotTyer3D coordinates for the rope.

I have attached the .CYP file for a Bowline, and a .KT3 file which I made using the above logic (you'll need to rename it from FCB_Bowline.txt to FCB_Bowline.kt3 in order to load it into KnotTyer3D).

Anyway, this will get you started (if you're interested), and the logic can be tweaked later (such as smoothing out the curves).

Dave

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #31 on: January 10, 2009, 05:04:39 PM »
Maybe you can create a "Tools/Options" screen, and provide a way for the user to specify the location of KnotTyer3D.exe on his/her machine (from http://www.abbott.demon.co.uk/knottyer3d.html).  This way, when the user clicks the button to create a .KT3 file, FCB can pop up KnotTyer3D and automatically load the new .KT3 file.

Hmmm, I just tried sending a .KT3 filename to KnotTyer3D.exe, but it didn't load the file automatically.  If you can't get the auto-load to work, then perhaps you can save the .KT3 file to the KnotTyer3D.exe folder, then pop up KnotTyer3D.  The user simply needs to click "File/Load knot," and the new .KT3 file will be right there in the list.

If you create a "Tools/Options" screen, you might consider removing all of the stuff at the bottom of the main screen and putting those things in the "Tools/Options" screen.  This will give the main screen a more clean and streamlined look, and I believe that it will be more intuitive for new users (in other words, new users won't be confronted with features and options which they don't yet know what to do with).

You could add a row of colored boxes in the pallet (blue, red, and maybe black or brown), and when the user left-clicks a color then all of the pallet tiles change to that color.  For crossing tiles, only the "over" part of the crossing changes color.  When the user right-clicks a color, then the "under" part of the crossing tiles changes color.  As a user, I would prefer to have control over the color behavior, but your "Tools/Options" screen could have a checkbox to turn on "Smart Colors" (which is the current FCB behavior).

Dave

DerekSmith

  • IGKT Member
  • Sr. Member
  • *****
  • Posts: 1549
  • Knot Botherer
    • ALbion Alliance
Re: Another Step Forward
« Reply #32 on: January 10, 2009, 07:53:24 PM »
Hi Dave,

I like the way you are thinking.

When FCB was first created, it was to help Frank create knot drawings (he was using a CAD program and placing pre drawn cells onto a grid, much as you did the other day with MS Paint).  The idea was to create a diagram using only a set of tiles and from this create a simple cypher string which could be sent, faxed, or spoken to another tyer and from this cypher, they could faithfully recreate the diagram.  The little utility made placing tiles easy and wrote out the little three character cypher strings as it went, saving the cypher to a tiny text file came next and naturally that was followed by the ability to load one of these text cypher files and recreate the diagram.  But that is all they were, simple text codes and pictures built up from set tiles.  The picture created could be anything from gibberish to a knot, any meaning was formulated by the human mind looking at the picture, there was no essence of knot or cord in the code or the program.

It was only much later, after several revisions, that I faced the challenge of making the utility automatically work out the Overs Index and the Binary Signature for the knot represented by the diagram.  To do this I first had to give the utility the ability to do what you achieved by utilising the picture of the knot you had created in your minds eye so that you could follow the 'path' of an imagined continuous cord.  I did this by adding to each picture tile, information about which face the cord came in and went out by.  This then allowed the utility to 'Trace out' the path of the cord.  I gave the utility the trigger of waiting for a WE tile to be placed for cord 1 and when this trigger happened, 'Trace' worked its way along the tiles and created a representation of the continuous path of the cord.  Naturally, as I was doing this to create the Binary Sig and the OI, each time a crossing was encountered the corresponding 0 or 1 was recorded into the Signature (these correspond to the -1's and 0's of the kt3 'language').

So, I already have the heart of the kt3 interpreter and instead of just recording crossings, I just have to record the other 2D moves as well in order to create a kt3 equivalent of the FCB cypher.  As for creating a kt3 file, that would simply require adding a kt3 'type' to the 'Save As' menu and then writing an appropriately scripted csv file to produce a functional kt3 file.  It is all relatively easily doable because the structure is already there, and I think it will be a potentially useful enhancement, so I will 'set to' on the enhancement (it will take me a little longer than the drawing style mod took, so watch this space).

Unfortunately, the next bit you wanted - Auto execute Knottyer3d.exe and load the newly created kt3 file - cannot be done with Knottyer3d.exe as it presently stands.  If you drag and drop a .cyp file onto FCB4.exe, it will launch the utility and load the file because I have built in the method of inspecting the command line for a file handle and attempting to auto load it (I have yet to build in error handling if the format is bum).  Steve has not built this function into Knottyer3d and if you hand it a file it simply ignores it.  So I am afraid, you will be stuck with having to hand load the converted file.

Your other ideas about clearing up the bottom of the work area are excellent, the cyp fields have long since lost their use, but before I do this, I need to build in copy and paste to allow chunks of diagram to be copied not only around the work area, but also between cords.  I have been toying with floating out a 'Tools' pallet along with the Tile pallet.  I think you have convinced me to do this for the next release, along with the facility to annotate the diagram (haven't found out how to do this yet.)

You have given me a lot to work on here, shame you don't have Delphi (yet?).

Derek
« Last Edit: January 10, 2009, 09:15:45 PM by DerekSmith »

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #33 on: January 11, 2009, 03:27:05 PM »
I believe that there is a team of Delphi developers on my floor at work, which means that there's a chance I can install Delphi through our site license.  Depending on how steep the learning curve is, I might be able to help out with some of the tasks.  Feel free to send me the source code, and I'll see what I can do.

Dave

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #34 on: January 11, 2009, 07:09:09 PM »
I sent a note to Steve Abbott this morning to see if he might modify KnotTyer3D to accept a .KT3 filename as a parameter, and within an hour he had sent me a new version of KnotTyer3D with the modification!

I have asked him if he is planning to update his website (http://www.abbott.demon.co.uk/knottyer3d.html) with the new version, and I sent him a link to this thread.

Dave

DerekSmith

  • IGKT Member
  • Sr. Member
  • *****
  • Posts: 1549
  • Knot Botherer
    • ALbion Alliance
Re: Another Step Forward
« Reply #35 on: January 11, 2009, 11:11:19 PM »
Wow, you really make things happen, and you have access to a whole team of Delphi programmers, I am in deep envy, it is really hard to learn Delphi without access to someone who knows and uses the language.

Of course I will make the source code open to you, I think you can run with it far faster than I have managed thus far.  I will post it onto the KnotCypher wiki http://knotcyphers.pbwiki.com/ and send you a user link when it is up. (could you confirm your email please).

Derek

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #36 on: January 11, 2009, 11:15:29 PM »
LOL, it was Steve who made things happen quickly!

Edit: My email address is: dave <> Layhands . com

Dave
« Last Edit: January 12, 2009, 12:12:28 PM by DaveRoot »

Dan_Lehman

  • Sr. Member
  • *****
  • Posts: 4011
Re: Another Step Forward
« Reply #37 on: January 12, 2009, 07:53:58 AM »
LOL, it was Steve who made things happen quickly!

I love seeing the Net facilitate good growth (in stark contrast to SPAM & scams).

Quote
My email address is:  <omitted!>

Thinking of which, Dave, you might want to delete this piece of text--do SPAMbots
crawl here and collect addresses?  'dave <> Layhands.com' is one way I've put
e-addresses; and 'dave456<>Layhands99.com [remove all numerals!]' is another
and surer way to defeat a bot, I'd think.

Cheers,
--dl*
====

DerekSmith

  • IGKT Member
  • Sr. Member
  • *****
  • Posts: 1549
  • Knot Botherer
    • ALbion Alliance
Re: Another Step Forward
« Reply #38 on: January 12, 2009, 10:58:03 PM »
OK,

The full project source code is now posted to https://knotcyphers.pbwiki.com/FCB-Development so no jokes please about my novice programming, but all contributions to improve the utility gratefully received.

We probably need to agree some protocol for updating the files after change with some sort of date and versioning - being a lone programmer, I have not had to bother with this.

Derek

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #39 on: January 13, 2009, 12:49:02 AM »
Great, I'll download it and have a go at it!

Now that the source code has been made available to more people, let's be sure to comment our changes with our name (and the date) to help with the merging.

I use a file compare and directory compare utility called "Beyond Compare" (http://www.scootersoftware.com/moreinfo.php) every day at work and at home for merging software changes, HTML changes, etc., between the work and home copies of my programs.  It's one piece of software which really lives up to its name!   8)

BTW, I found out that those developers at my work are not Delphi developers, they are PowerBuilder developers....

I received your email.  I'm assuming that I can now upload to the wiki, and that we can discuss the app on the wiki forum, right?

Dave

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #40 on: January 13, 2009, 04:15:36 AM »
Okay, I'm able to run the FCB application in Turbo Delphi now.

In order to avoid too many collisions, what part are you currently working on?

Dave

DerekSmith

  • IGKT Member
  • Sr. Member
  • *****
  • Posts: 1549
  • Knot Botherer
    • ALbion Alliance
Re: Another Step Forward
« Reply #41 on: January 13, 2009, 12:11:55 PM »
Hi Dave,

I am seriously impressed at the speed at which you work, bodes well for the future of FCB I hope.

Yes, you now have full access to the Wiki.  You have Administrator access which means the wiki is fully at your disposal, including invitation of new contributors and full create delete authority.

I agree, we should probably keep the development work over on the Wiki, I doubt the good folks here will be too interested in ---

------------------------------------------

// Converts the full binary signature into the Overs Index
// but do not start until sig is over three characters long


function sigtooi(sig: string): string;
var
c, overs, sat :integer;
j : string;
begin
 result :='';
 if length(sig)>3  then
 begin
   overs :=0;
    for c := 1 to length(sig) do
      if sig[c] = '1' then overs := overs +1; //count over crossings

     sat := overs *2; //assume fully saturated
     j := sig[1];
     for c := 2 to length(sig) do
        begin
          if sig[c] <> '-'  then  //ignore hyphens
            begin
              if j = sig[c] then
                 begin
                 sat := sat-1;  //decrease saturation for every repeat
                 end;
              j:= sig[c];
            end;
        end;
    result := inttostr(overs)+':'+inttostr(sat);
 end;
end;

--------------------------------------------

However, it would be valuable to keep updates of the progress in this thread so that others interested in using the utility can decide if the changes are of interest to them.

At the moment, I am working on tidying up the drawing function to curve the crossings and have the cord paint over the grid lines in the FCBForm.pas unit - procedures drawcella() through to drawcellr().

However, I really do not want to stint your enthusiasm, so please feel free to consider and decide on how you see this project going forward and how it would be best to approach the goals ahead - do you even agree with the ToDo's that have amassed as time has gone by?

I am a hobby programmer with only the FCB utility, a genealogy transcription search utility, and a GPS tracking / verge audit facility to my credit.  I certainly feel that the FCB utility can benefit greatly from the professional rigour you can impose on it so please feel free to take over leadership of the project for us.  It is time for the project to have some renewed vigour, I hope you will be happy to be the initiator.

Derek

DaveRoot

  • Exp. Member
  • ****
  • Posts: 141
    • The Most Useful Rope Knots....
Re: Another Step Forward
« Reply #42 on: January 13, 2009, 12:24:41 PM »
I'm now able to pop up KnotTyer3D and auto-load a .KT3 file, so I'll work on creating a "Tools/Options" form to allow the user to enter the appropriate file paths, and I'll add the logic to create the .KT3 file.  This seems like a discrete piece of functionality which shouldn't impact anything you're doing, plus it will give me the opportunity to learn how to do a number of different things in Delphi.

I'm not sure where to continue this discussion on the Wiki, so I'll let you post a comment there and then post a link to it here.

Dave

DerekSmith

  • IGKT Member
  • Sr. Member
  • *****
  • Posts: 1549
  • Knot Botherer
    • ALbion Alliance
Re: Another Step Forward
« Reply #43 on: January 13, 2009, 01:11:23 PM »
The Wiki does not have its own forum, so we will have to use the pages or the comments for text, ideas, code discussions etc.

I have created a new page linked from here https://knotcyphers.pbwiki.com/FCB-Development

let me know if this will be useful or not.

Meanwhile, anyone wants to download the utility and have a play, the latest version can be downloaded from here https://knotcyphers.pbwiki.com/The+FCB+Cypher  click on the FCB42.b.exe file download link, save the file to your PC.  Right click the file to create a shortcut and put the shortcut onto your desktop (or wherever you keep your shortcuts).  To run the utility simply double click or drag and drop a .cyp file onto it - don't worry about messy installations, it doesn't need any, it just runs.

If you need some help, we are building a user guide over at https://knotcyphers.pbwiki.com/FCB4+User+Guide or just post your questions here.

Just a Note  - You can run multiple copies of FCB at the same time, this can be handy to have one copy open displaying one diagram, while you draw a new diagram in another copy of FCB.

Derek
« Last Edit: January 13, 2009, 02:04:20 PM by DerekSmith »

DerekSmith

  • IGKT Member
  • Sr. Member
  • *****
  • Posts: 1549
  • Knot Botherer
    • ALbion Alliance
Re: Another Step Forward
« Reply #44 on: January 13, 2009, 02:30:55 PM »
Any chance of the Knottyer3D with auto load?

Post it to the Wiki if you like and if Steve agrees.

Derek