6

I'm looking for an algorithm that provides a way to generate graphical representations of knots (either 2D or 3D, but the former, with vector graphics is preferable).

I've seen many links to knot theory in general, spanning from punctual references to general information.

Before trying to devise something from scratch by myself, I'd like to know about the existence of some existing software that lets you not only represent them (in memory) but visualize in some of their graphical representations (there are many). It could come in the form of a library, or a simple function, or even a pseudocode algorithm that tries to specify how to properly draw a know on screen.

As the previous link suggests, there is a package in Wolfram Mathematica, named KnotTheory that does that (in an almost complete way). However, it is not portable, nor free software and accessing its modules would be very cumbersome for me (a free implementation in Java, just to name a language, but each language is fine, would be be ideal from the portability and openness perspectives).

I've seen that many softwares are available (but most of them are old and not reachable or usable). Do you have some good pointers to share?

UPDATE: Since two votes to close this question have appeared, I am restating it in a more pragmatic and clear way: are there algorithms to draw and generate knots? has something been already implemented

UPDATE 2 (for reopening) The graphical representation could be a 3D rendered object or a 2D svg graphics (I am abstracting from it since I am looking forward a programming language as Processing (or the same Mathematica itself) that provides you the primitives to draw curves (splines, beziers, etc) on screen (and then export them to raster or vector graphics). The algorithm shall take one knot parametrization as input (ie, if we are talking about knots described by their crossing properties, their values is what is needed), returning one of the graphical representation above (ie even a sequence of points in a 2d space). That is, any parametrization is fine, my objective is just to get introspection on how to draw knots so to get ONE algorithm that does that in a particular way, leading to a particular representation, would be fine (Mathematica's lib seems to be able to draw it in so many representations).

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
rano
  • 5,616
  • 4
  • 40
  • 66
  • I did not vote, but the close votes are probably related to the fact that library recommendations are considered as "off topic" on StackOverflow. – Marco13 Aug 26 '14 at 22:36
  • @Marco13 my point is not being recommended a good library, but to get to know wheter or not any piece of public software (so even a library, in the best case) that can do something like that exists. Even the algorithm in pseudocode that tells you how to properly draw them is fine. – rano Aug 28 '14 at 05:05
  • Three "reopen" votes already. I'd also vote for "reopen", but... some more information about the desired functionality would be helpful. Looking over the Wikipedia Page indicates that there are an awful lot of possible representations and notations (considering that this is all about some tangled ropes...). What should be the *input* of such an algorithm? (And what should be the "intermediate" output - the final output should be an SVG or so, but there will to be some spline representation involved...) – Marco13 Aug 28 '14 at 12:30
  • Voted and it's reopened now. Although the description sounded like you're looking for a library, it seems like you're more looking for a concept (algorithm) how how to do this *in general*. I'd really like to see some answers here. (I'm somewhat intimidated by the load of theory that seems to be behind this, otherwise I'd give it a try to at least perform some rudimentary "knot description to splines" conversion...) – Marco13 Aug 30 '14 at 23:01
  • 1
    You might look at the work of Carlo Sequin at UC Berkeley http://www.cs.berkeley.edu/~sequin/PAPERS/2010_G4G9_Knots.pdf – Gene Aug 31 '14 at 00:39
  • After further research, it became less and less clear for me what an acceptable answer could look like. Apart from the vast amount of theoretical information, there seem to be no "simple" toolchains for converting one of the knot notation strings into a diagram (ignoring the *ambiguities* that such a translation would have to cope with). Actually *implementing* such a program could fall into two categories: 1. It could either be an overly simplified proof-of-concept, where a very special, limited subset of one knot notation could be translated into a (simple and ugly) visual representation,... – Marco13 Sep 05 '14 at 15:03
  • which would be of limited use for you. Or 2. it would be a sophisticated library containing an infrastructure that is *very far* beyond the scope of what can be considered as an "answer" here on stackoverflow. The only alternative could be to recommend resources and high-level approaches about how this problem could be tackled. I collected some resources and hints, but am not sure whether (and how) I should/could provide them, because off-site resources should not be answers (As the last resort, if you wish, I could post them here, when the bounty period has expired) – Marco13 Sep 05 '14 at 15:05
  • I've seen there are some alternatives like a lib for Sage that is under development for GSoC14, I will provide more links after this month ends, btw thanks @Marco13 – rano Sep 06 '14 at 07:51
  • This may be the best knot related resource I've found, as a knot nerd myself. http://www.igkt.net/ – Jonathon Anderson Sep 09 '14 at 00:18

2 Answers2

1

Something like this?

void setup() {
  size(300, 300, P3D);
} 


void draw() {
  background(36, 10, 28);
  int f = frameCount%360;
  translate(width/2, height/2);
  if (frameCount >= 360 && frameCount <= 1080 )
    rotateY(radians(f));
  stroke(0); 
  drawKnot(40);

  translate(knotX(f)*40, knotY(f)*40, knotZ(f)*40);
  noStroke();
  fill(180,50,145);
  sphere(10);
}


void drawKnot(float sz) {
  stroke(200);
  for (int i = 0; i < 360; i++) {
    point(knotX(i)*sz, knotY(i)*sz, knotZ(i)*sz);
  }
}


float knotX(int n) {
  return sin(radians(n)) + 2*sin(radians(n*2));
}
float knotY(int n) {
  return cos(radians(n)) - 2*cos(radians(n*2));
}


float knotZ(int n) {
  return sin(radians(n*3))*-1;
}
v.k.
  • 2,826
  • 2
  • 20
  • 29
  • That is a hihgly hard coded way to draw just one particular knot. If I am not mistaken you are not using the general knot theory for planar diagrams but only a 3d curve for the trefoil knot case – rano Sep 04 '14 at 06:35
  • I thought this was to easy to be of help, the question mark in "like this?" is not rhetorical :) – v.k. Sep 05 '14 at 14:21
1

Wolfram Mathematica has basic knot theory, including visualization, built in:

http://reference.wolfram.com/language/ref/KnotData.html

This webpage from the software documentation contains many examples of standard knot-theoretic visualization and computation that can be done with Mathematica.

Kellen Myers
  • 362
  • 1
  • 6
  • I suspect that is what Mathematica uses, no improvement on that side (read the question) – rano Sep 04 '14 at 06:34
  • Actually, I read it. You asked "are there algorithms to draw and generate knots?" The answer is yes, and there it is. Then you specify "The algorithm shall take one knot parametrization as input (... their crossing properties...), returning one of the graphical representation above" which is exactly what it does. This algorithm explicitly takes the Alexander-Briggs or Dowker notation for a knot and returns, deterministically, a drawing. It would be nice if it took other data (Conway notation, Gauss notation, etc.) but I don't think it does. What part of this doesn't answer the question? – Kellen Myers Sep 06 '14 at 16:59
  • For other examples, try: http://knotplot.com/ ; http://mirror.unl.edu/ctan/graphics/pgf/contrib/spath3/knots_doc.pdf ; http://knotilus.math.uwo.ca/doc/features.html ; http://cran.r-project.org/web/packages/Rknots/Rknots.pdf . – Kellen Myers Sep 06 '14 at 17:25