Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating knots procedurally (and visualizing them)

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).

like image 628
rano Avatar asked Aug 22 '14 09:08

rano


People also ask

What are the basic principles of knot tying?

They illustrate the fundamental principles of knot tying. Many are also components of other knots or they provide the underlying structure. The Square Knot (Reef Knot) and Sheet Bend are the two basic methods of joining two ropes; and the Figure 8 underlies many other important knots.

What are the different types of knots?

Many are also components of other knots or they provide the underlying structure. The Square Knot (Reef Knot) and Sheet Bend are the two basic methods of joining two ropes; and the Figure 8 underlies many other important knots.

What are the two basic methods of joining two ropes?

The Square Knot (Reef Knot) and Sheet Bend are the two basic methods of joining two ropes; and the Figure 8 underlies many other important knots. The terms Overhand Knot, Half Hitch, and Half Knot are often confused and frequently used as though they are interchangeable.

How do you use a stopper knot?

Non-binding, quick and convenient stopper knot. Used to tie rope around an object and back to itself. Simple binding knot: first step of the Square (Reef) Knot. Creates a loop that tightens when pulled. Simple loop in rope's end - loosens when tail end is pulled. Simple way to join two ropes made up of two Half Knots. No results found.


1 Answers

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;
}
like image 62
v.k. Avatar answered Nov 03 '22 06:11

v.k.