RiptideRiptide
Download Riptide SDKInstall Riptorch
Menu
Raya docs · Exact and higher mathematics

Knot theory

Link diagrams and Reidemeister moves, exact Jones, Alexander, Conway and HOMFLY-PT polynomials, and a table of small knots and links.

import 'package:riptide_knots/riptide_knots.ray';
12 classes124 functions and methods105 of 183 documented99 runnable examples

Overview

Knot theory. Exact integer arithmetic.

AreaAPI
DiagramsLinkDiagram.pd (Knot Atlas / KnotTheory X[i,j,k,l]), .dt (Dowker–Thistlethwaite; the planar embedding is found by Euler's formula), .braid (closures, \sigma_{i} = \pm i), .unlink; orientation, signs, writhe, components, linkingNumbers, faces, isPlanar, isAlternating, isReduced, mirror, reversed, reverseComponent, normalized
Reidemeister movesaddKink / removeKink / removeAllKinks (R_{1}), addPoke / removeBigon (R_{2}), triangleMove (R_{3}) with kinks, r2Pokes, r2Bigons, r3Triangles listing where each applies; smoothed (oriented smoothing)
InvariantskauffmanBracket (planar sweep over open-edge matchings; kauffmanBracketStateSum is the 2^{n} reference), jonesHalf / jones, alexander (Fox calculus, Bareiss determinant over \mathbb{Z}[t, t^{-1}], Conway-normalised), conway, determinant, homfly (skein recursion to a descending diagram, memoised), signature (Gordon–Litherland), crossingNumberBounds
PolynomialsLaurent (\mathbb{Z}[x, x^{-1}]) and Laurent2 (\mathbb{Z}[a\wedge \pm, z\wedge \pm ]) with exact division and specialisation; to be swapped for the CAS polynomials when they land
TableknotTable: 3_{1}, 4_{1}, 5_{1}, 5_{2}, 6_{1}–6_{3}, 7_{1}–7_{7}, 8_{19}–8_{21}, 10_{124}, L2a1 (Hopf), L4a1 (Solomon), L5a1 (Whitehead), L6a4 (Borromean)
3-DKnotCurves.torusKnot, .torusLink, .figureEight, .lissajous, .circle, .hopfLink, .borromeanRings; diagramFromCurves (PD code of a projected polyline), projectedCrossings, gaussLinkingNumber (exact per-segment solid angles), curveWrithe
RenderingtubeMesh(points, radius, sides, closed, uScale:) → TubeMesh (positions, normals, uvs, tangents, indices; interleaved is riptide_render's 12-float Geometry layout); rotation-minimising frames with closed-loop twist correction
final k = LinkDiagram.pd(knotTable['4_1']!.pd);
k.jones();      // t^2 - t + 1 - t^-1 + t^-2
k.alexander();  // -t + 3 - t^-1
k.homfly();     // a^2 - z^2 - 1 + a^-2
final tube = tubeMesh(KnotCurves.torusKnot(2, 3), radius: 0.12, sides: 24);
final geometry = Geometry(vertices: tube.interleaved(), indices: tube.indices); // riptide_render

Validation (raya test, 189 tests)

  • Every table entry: Jones, HOMFLY-PT, Alexander, Conway, determinant, signature and linking numbers computed from the Knot Atlas PD code equal the Knot Atlas values; the planar sweep equals the 2^{n} state sum; HOMFLY-PT specialises to Jones and Conway; mirror images give V(\frac{1}{t}), P(\frac{1}{a}, -z), -\sigma; DT codes give the same knots up to mirror image.
  • Random sequences of 60 Reidemeister moves (R1, R2, R3 both ways) on 3_{1}, 4_{1}, 5_{2}, 6_{3}, 8_{19} and the three links keep the diagram planar and every invariant unchanged; R1 multiplies the bracket by -A^{\pm3}, R3 keeps it.
  • Torus knots T(2, 3\cdots9), T(3, 4), T(3, 5), T(3, 7), T(4, 5) from braids match the closed-form Jones and Alexander polynomials.
  • Diagrams read off 3-D curves (torus knots, figure-eight, a Lissajous 7_{4}, Hopf, Solomon, Borromean) have the expected invariants from several projection directions, and the Gauss linking integral equals the diagrammatic linking number.

Data and licences

The table's values (PD codes, DT codes, polynomials, determinants, signatures, unknotting numbers) are published mathematical facts read from the Knot Atlas (D. Bar-Natan, S. Morrison et al. https://katlas.org) and agree with KnotInfo (C. Livingston and A. H. Moore, https://knotinfo.math.indiana.edu). No code was taken from SnapPy, Regina, SageMath (GPL) or KnotTheory\`; the algorithms follow the published papers cited in the doc comments.

Functions and constants

Functions

List<ProjectedCrossing> projectedCrossings(List<SpaceCurve> curves, [Projection? projection])

The crossings of closed polylines curves seen through projection (the viewer is on the +w side; the larger w passes over). Adjacent segments of one curve are not compared.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final xs = projectedCrossings([KnotCurves.torusKnot(2, 3)]);
  print('${xs.length} crossings in the projection of the (2,3) torus knot');
}
Output
3 crossings in the projection of the (2,3) torus knot
LinkDiagram diagramFromCurves(List<SpaceCurve> curves, [Projection? projection])

The link diagram of closed polylines curves seen through projection: a PD code with labels running 1, 2, … along each curve in its sampling direction. Curves with no crossing become free loops.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final d = diagramFromCurves([KnotCurves.torusKnot(2, 3)]);
  print('${d.crossingCount} crossings, Jones ${d.jones().format('t')}');
}
Output
3 crossings, Jones -t^4 + t^3 + t
double gaussLinkingNumber(SpaceCurve a, SpaceCurve b)

The Gauss linking integral of two closed polylines, evaluated exactly per segment pair as a signed solid angle (Klenin and Langowski, Biopolymers 54, 2000). An integer (up to rounding) equal to the linking number.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final h = KnotCurves.hopfLink();
  print('Hopf link: ${f4(gaussLinkingNumber(h[0], h[1]))}');
}
Output
Hopf link: -1.0000
curveWrithefunction
double curveWrithe(SpaceCurve a)

The writhe of a closed polyline (the Gauss double integral over the curve with itself); by Călugăreanu–White Lk = Tw + Wr for a ribbon along it. Not an integer in general.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('writhe of the (2,3) torus knot curve: ${f4(curveWrithe(KnotCurves.torusKnot(2, 3)))}');
}
Output
writhe of the (2,3) torus knot curve: 3.3368
Map<String, Object?> knotDiagramScene(List<SpaceCurve> curves, {required String id, required String title, Projection? projection, double gap = 0.18, int maxSegments = 160})

Pure data, so this package needs no Evelyn; the explainer draws it in light and dark mode with its own palette.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(knotDiagramScene([KnotCurves.torusKnot(2, 3, samples: 60)], id: 'trefoil', title: 'Trefoil').keys.toList());
}
Output
[id, title, view, objects, steps]
tubeMeshfunction
TubeMesh tubeMesh(Float64List points, {double radius = 0.1, int sides = 16, bool closed = true, double uScale = 8})

A tube of radius with sides facets around the polyline points (xyz per point). For a closed curve the last point joins the first.

Frames are rotation-minimising (the double-reflection method of Wang, Jüttler, Zheng and Liu, "Computation of rotation minimizing frames", ACM TOG 27, 2008), so the tube does not twist on its own; on a closed curve the holonomy left after one lap is spread evenly along it, so the last ring meets the first exactly. uScale sets how many texture repeats run along the tube.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final m = tubeMesh(KnotCurves.torusKnot(2, 3, samples: 40), radius: 0.2, sides: 6);
  print('${m.interleaved().length} floats');
}
Output
3444 floats

Constants and variables

knotTablevariable
final Map<String, KnotTableEntry> knotTable

The table, by name.

Typedefs

SpaceCurvetypedef
typedef SpaceCurve = Float64List

A closed space curve sampled as a polyline: x, y, z per point; the last point joins back to the first (it is not repeated).

Classes

abstract final class KnotCurves

Parametric knots and links in \mathbb{R}^{3}.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final k = KnotCurves.torusKnot(3, 5);
  print('${k.length ~/ 3} samples; diagram: ${diagramFromCurves([k]).crossingCount} crossings');
}
Output
360 samples; diagram: 10 crossings

Static

torusKnotstaticmethod
static SpaceCurve torusKnot(int p, int q, {double major = 2, double minor = 0.8, int samples = 360})

The (p, q) torus knot on a torus of radii major and minor: p turns around the axis, q around the tube, x = (R + r cos qt) cos pt, y = (R + r cos qt) sin pt, z = -r sin qt. Projected on the xy-plane it has q(p - 1) crossings, all positive for p, q > 0: T(2, 3) is the right-handed trefoil (the mirror of the Knot Atlas 3_{1}), T(3, 4) is 8_{19} and T(3, 5) is 10_{124}.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final d = diagramFromCurves([KnotCurves.torusKnot(2, 5)]);
  print('(2,5) torus knot: determinant ${d.determinant()}, signature ${d.signature()}');
}
Output
(2,5) torus knot: determinant 5, signature 4
figureEightstaticmethod
static SpaceCurve figureEight({int samples = 360})

The figure-eight knot 4_{1}: x = (2 + \cos 2t) \cos 3t, y = (2 + \cos 2t) \sin 3t, z = \sin 4t.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('Jones ${diagramFromCurves([KnotCurves.figureEight()]).jones().format('t')}');
}
Output
Jones t^2 - t + 1 - t^-1 + t^-2
lissajousstaticmethod
static SpaceCurve lissajous(int nx, int ny, int nz, {double phx = 0.1, double phy = 0.7, double phz = 0, double scale = 2, int samples = 600})

A Lissajous knot x = \cos(n_{x}t + \varphi_{x}), y = \cos(n_{y} t + \varphi_{y}), z = \cos(n_{z} t + \varphi_{z}) (frequencies pairwise coprime; with the default phases (3, 2, 7) is a 7-crossing diagram of the mirror of 7_{4}, as the tests check).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final k = KnotCurves.lissajous(3, 2, 7);
  print('Lissajous knot: ${diagramFromCurves([k]).crossingCount} crossings');
}
Output
Lissajous knot: 7 crossings
circlestaticmethod
static SpaceCurve circle((double, double, double) center, (double, double, double) u, (double, double, double) v, {double radius = 1, int samples = 200})

A circle of radius around center in the plane spanned by unit vectors u and v.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final c = KnotCurves.circle((0, 0, 0), (1, 0, 0), (0, 1, 0));
  print('writhe of a flat circle: ${f4(curveWrithe(c))}');
}
Output
writhe of a flat circle: 0.0000
borromeanRingsstaticmethod
static List<SpaceCurve> borromeanRings({int samples = 240})

The Borromean rings as three mutually perpendicular ellipses (semi-axes 2 and 1).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final b = KnotCurves.borromeanRings();
  final d = diagramFromCurves(b);
  print('pairwise linking ${d.linkingNumbers} (all zero), yet Jones ${d.jonesHalf().format('s')}');
}
Output
pairwise linking [0, 0, 0] (all zero), yet Jones -s^6 + 3s^4 - 2s^2 + 4 - 2s^-2 + 3s^-4 - s^-6
final class Projection

An orthonormal projection frame: the screen axes u, v and the direction w toward the viewer.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final p = Projection((1, 0.02, 0.03));
  print(diagramFromCurves([KnotCurves.torusKnot(2, 3)], p).crossingCount);
}
Output
8

Constructors

Projectionfactory
factory Projection([(double, double, double) view = (0.0123, 0.0217, 1)])

Looking along −view (default a slightly tilted z, so a symmetric curve projects generically).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(projectedCrossings([KnotCurves.torusKnot(2, 3)], Projection((0, 0.01, 1))).length);
}
Output
3

Properties

ufield
final (double, double, double) u
vfield
final (double, double, double) v
wfield
final (double, double, double) w

Methods

applymethod
(double, double, double) apply(Float64List c, int i)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final c = KnotCurves.torusKnot(2, 3, samples: 12);
  print(Projection().apply(c, 0));
}
Output
(0.0, 2.7997883176978378, 0.03442929105730846)
final class ProjectedCrossing

One crossing of a projected curve: where it is on screen and which pieces of the curves pass over and under.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final x = projectedCrossings(KnotCurves.hopfLink()).first;
  print('at (${f4(x.x)}, ${f4(x.y)}): component ${x.overComponent} over ${x.underComponent}');
}
Output
at (-0.0217, 0.9996): component 0 over 1

Constructors

const ProjectedCrossing(this.x, this.y, this.overComponent, this.overParam, this.underComponent, this.underParam)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(const ProjectedCrossing(0, 0, 0, 0.1, 1, 0.2).underComponent);
}
Output
1

Properties

xfield
final double x

The screen position.

yfield
final double y

The screen position.

final int overComponent

Component index and position along it (segment index + fraction) of the over- and under-passes.

final int underComponent

Component index and position along it (segment index + fraction) of the over- and under-passes.

final double overParam
final double underParam
final class Crossing

One crossing of a planar diagram in the Knot Atlas / KnotTheory PD convention: X[a, b, c, d] lists the four edge labels counterclockwise, starting with the incoming under-strand, so the under-strand runs a \to c. The over-strand runs d \to b at a positive crossing and b \to d at a negative one (which one is decided by orientation, see LinkDiagram.signs).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('trefoil crossings: ${trefoil.crossings}');
}
Output
trefoil crossings: [X[4,2,5,1], X[2,6,3,5], X[6,4,1,3]]

Constructors

Crossingconstructor
const Crossing(this.a, this.b, this.c, this.d)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Crossing(1, 4, 2, 5).labels);
}
Output
[1, 4, 2, 5]
factory Crossing.fromList(List<int> x)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Crossing.fromList([1, 4, 2, 5]));
}
Output
X[1,4,2,5]

Properties

afield
final int a
bfield
final int b
cfield
final int c
dfield
final int d
labelsgetter
List<int> get labels
hashCodegetter
int get hashCode

Methods

mapmethod
Crossing map(int Function(int) f)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Crossing(1, 4, 2, 5).map((l) => l + 10));
}
Output
X[11,14,12,15]
toStringmethod
String toString()

Operators

operator []operator
int operator [](int p)

The label at counterclockwise position p (0 = incoming under).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final x = Crossing(1, 4, 2, 5);
  print([for (var p = 0; p < 4; p++) x[p]]);
}
Output
[1, 4, 2, 5]
operator ==operator
bool operator ==(Object other)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Crossing(1, 4, 2, 5) == Crossing.fromList([1, 4, 2, 5]));
}
Output
true
final class LinkDiagram

An oriented link diagram: crossings in PD notation plus freeLoops crossingless unknotted components.

Every edge label appears exactly twice among the crossings. The orientation of each edge is propagated from the under-strands (which the PD convention orients), so labels need not be consecutive along a component; a component that only passes over is oriented arbitrarily (from its smallest label).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('trefoil: ${trefoil.crossingCount} crossings, writhe ${trefoil.writhe}, Jones ${trefoil.jones().format('t')}');
}

String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');
Output
trefoil: 3 crossings, writhe 3, Jones -t^4 + t^3 + t

Constructors

LinkDiagramconstructor
LinkDiagram(List<Crossing> crossings, {this.freeLoops = 0, List<int>? overEntries})

overEntries optionally fixes, per crossing, the position (1 or 3) where the over-strand enters; it is needed only for components that never pass under (otherwise the orientation follows from the under-strands). Without it such a component is oriented by KnotTheory's rule for consecutive labels.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final d = LinkDiagram([Crossing(1, 4, 2, 5), Crossing(3, 6, 4, 1), Crossing(5, 2, 6, 3)]);
  print('${d.isPlanar}, Jones ${d.jones().format('t')}');
}
Output
true, Jones t^-1 + t^-3 - t^-4
factory LinkDiagram.pd(List<List<int>> pd, {int freeLoops = 0})

From a PD code [[i, j, k, l], …], e.g. the Knot Atlas trefoil [[1, 4, 2, 5], [3, 6, 4, 1], [5, 2, 6, 3]].

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  // The Knot Atlas trefoil.
  final d = LinkDiagram.pd([[1, 4, 2, 5], [3, 6, 4, 1], [5, 2, 6, 3]]);
  print('Alexander ${d.alexander().format('t')}');
}
Output
Alexander t - 1 + t^-1
factory LinkDiagram.dt(List<int> code)

From a Dowker–Thistlethwaite code (the even labels paired with 1, 3, 5, …; a negative entry means the strand is over at its even visit). The planar embedding is found by trying each crossing's two local orientations and keeping one whose faces satisfy Euler's formula (F = n + 2), so it is exponential in the crossing number (fine to ~20). DT codes determine a prime knot only up to mirror image.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('DT 4 6 2: Jones ${LinkDiagram.dt([4, 6, 2]).jones().format('t')}');
}
Output
DT 4 6 2: Jones t^-1 + t^-3 - t^-4
factory LinkDiagram.braid(int strands, List<int> word)

The closure of a braid on strands strands; word lists generators as \pm i (1-based): +i is \sigma_{i} (strand i passes over strand i + 1, a positive crossing when both run up), -i is \sigma_{i}^{-1}. \sigma_{1}^{3} is the right-handed trefoil.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  // σ1σ2⁻¹ repeated twice on 3 strands closes to the figure-eight knot.
  final d = LinkDiagram.braid(3, [1, -2, 1, -2]);
  print('Jones ${d.jones().format('t')} = figure-eight: ${d.jones() == fig8.jones()}');
}
Output
Jones t^2 - t + 1 - t^-1 + t^-2 = figure-eight: true

Static

rebuildstaticmethod
static LinkDiagram rebuild(List<Crossing> kept, List<(int, int)> joins, {int freeLoops = 0, List<int>? overEntries})

Rebuilds a diagram from kept crossings after joining edge labels in pairs (joins: each pair becomes one edge). Classes of joined labels that no kept crossing uses any more are closed crossingless loops.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final d = LinkDiagram.rebuild(trefoil.crossings, []);
  print(d.jones() == trefoil.jones());
}
Output
true

Properties

final List<Crossing> crossings
final int freeLoops

Components with no crossings at all (unknotted, unlinked circles).

int get crossingCount
signsfield
late final List<int> signs

The sign of each crossing (+1: the over-strand enters at position 3, i.e. runs d \to b).

writhegetter
int get writhe

The writhe: the sum of the crossing signs.

List<int> get overEntries

Per crossing, the position (1 or 3) where the over-strand enters.

late final List<List<int>> components

The components that have crossings, each as its edge labels in orientation order, starting from the component's smallest label; components are ordered by that label.

int get componentCount

The number of link components, crossingless loops included.

List<int> get linkingNumbers

The pairwise linking numbers (i < j) in the order (0,1), (0,2), …, (1,2), ….

facesfield
late final List<List<(int, int)>> faces

The faces of the diagram as cycles of half-edges (crossing, position), each traversed counterclockwise (the face on the left). A connected diagram with n \ge 1 crossings has n + 2 faces.

int get projectionPieces

The number of connected pieces of the projection (crossingless loops excluded).

isPlanargetter
bool get isPlanar

Whether the crossing data is a planar diagram (Euler's formula, per connected piece of the projection).

bool get isAlternating

Whether over and under alternate along every component.

List<int> get nugatoryCrossings

Crossings that one face touches at two corners (removable by turning a half of the diagram over).

isReducedgetter
bool get isReduced

Reduced: no nugatory crossing.

pdgetter
List<List<int>> get pd

The PD code as lists.

Methods

bool isIncoming(int ci, int p)

Whether the edge at crossing ci, position p points into the crossing.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print([for (var p = 0; p < 4; p++) trefoil.isIncoming(0, p)]);
}
Output
[true, false, false, true]
(int, int) overStrand(int ci)

The crossing ci's over-strand edges, incoming then outgoing.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(trefoil.overStrand(0));
}
Output
(1, 2)
successormethod
(int next, int crossing, bool under) successor(int label)

The edge after label along the orientation, with the crossing it passes through and whether it passed under.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(trefoil.successor(1));
}
Output
(2, 0, false)
int componentOf(int label)

The component (index into components) that edge label belongs to.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
  print([for (final c in hopf.components) hopf.componentOf(c.first)]);
}
Output
[0, 1]
int linkingNumber(int i, int j)

The linking number of components i and j: half the sum of the signs of the crossings between them.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
  print(hopf.linkingNumber(0, 1));
}
Output
-1
mirrormethod
LinkDiagram mirror()

The mirror image: every crossing switched.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('trefoil ${trefoil.jones().format('t')}, mirror ${trefoil.mirror().jones().format('t')}: chiral');
}
Output
trefoil -t^4 + t^3 + t, mirror t^-1 + t^-3 - t^-4: chiral
int switchedOverEntry(int ci)

The over-strand entry position of switched (ci).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('${trefoil.overEntries[0]} → ${trefoil.switchedOverEntry(0)}');
}
Output
3 → 1
switchedmethod
Crossing switched(int ci)

Crossing ci with over and under exchanged (orientations kept).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('${trefoil.crossings[0]} switched: ${trefoil.switched(0)}');
}
Output
X[4,2,5,1] switched: X[1,4,2,5]
reversedmethod
LinkDiagram reversed()

The same link with the orientation of every component reversed.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('trefoil is invertible: ${trefoil.reversed().jones() == trefoil.jones()}');
}
Output
trefoil is invertible: true
LinkDiagram reverseComponent(int k)

The same link with the orientation of component k (an index into components) reversed.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
  print('${hopf.linkingNumbers} → ${hopf.reverseComponent(1).linkingNumbers}');
}
Output
[-1] → [1]
LinkDiagram normalized()

Labels renumbered 1, 2, … along each component in orientation order (the KnotTheory form).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(LinkDiagram.dt([4, 6, 2]).normalized().pd);
}
Output
[[3, 6, 4, 1], [5, 2, 6, 3], [1, 4, 2, 5]]
toStringmethod
String toString()
extension KnotInvariants on LinkDiagram

Exact polynomial invariants of a LinkDiagram.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  for (final n in ['3_1', '4_1', '5_1', '5_2']) {
    final d = LinkDiagram.pd(knotTable[n]!.pd);
    print('$n: Jones ${d.jones().format('t')}, det ${d.determinant()}');
  }
}
Output
3_1: Jones t^-1 + t^-3 - t^-4, det 3
4_1: Jones t^2 - t + 1 - t^-1 + t^-2, det 5
5_1: Jones t^-2 + t^-4 - t^-5 + t^-6 - t^-7, det 5
5_2: Jones t^-1 - t^-2 + 2t^-3 - t^-4 + t^-5 - t^-6, det 7

Methods

Laurent kauffmanBracket()

The Kauffman bracket ⟨D⟩ in A, normalised so the crossingless unknot is 1 (a regular-isotopy invariant).

Contracted crossing by crossing (a planar-algebra / Temperley–Lieb style sweep): the state is a perfect matching of the edges left open so far, with a polynomial per matching, so the cost grows with the width of the cut rather than 2^{n}. The next crossing is the one sharing the most open edges.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final b = trefoil.kauffmanBracket();
  print('⟨trefoil⟩ = ${b.format('A')}');
}

String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');
Output
⟨trefoil⟩ = -A^5 - A^-3 + A^-7
Laurent kauffmanBracketStateSum()

The plain 2^{n} state sum (a reference for kauffmanBracket; only for small diagrams).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(trefoil.kauffmanBracketStateSum() == trefoil.kauffmanBracket());
}
Output
true
jonesHalfmethod
Laurent jonesHalf()

The Jones polynomial in s = t^{\tfrac{1}{2}} (= q^{\tfrac{1}{2}}): knots have only even powers of s; see jones for t.

V(t) = (-A^{3})^{-w} \langle D\rangle at A = t^{-\tfrac{1}{4}}, i.e. s = A^{-2}. Normalised V(unknot) = 1, skein t^{-1}V(L_{+}) − tV(L₋) = (t^½ − t^(−½))V(L₀), the Knot Atlas convention.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final hopf = LinkDiagram.pd(knotTable['L2a1']!.pd);
  print('Hopf: ${hopf.jonesHalf().format('s')} (s = t^½)');
}
Output
Hopf: -s^-1 - s^-5 (s = t^½)
jonesmethod
Laurent jones()

The Jones polynomial in t for a knot (or any link whose powers are integral); throws otherwise.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(fig8.jones().format('t'));
}

String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');
Output
t^2 - t + 1 - t^-1 + t^-2
alexandermethod
Laurent alexander()

The Alexander polynomial of a knot, Conway-normalised: \Delta(t) = \Delta(t^{-1}), \Delta(1) = 1.

From the Alexander matrix of the Wirtinger presentation (Fox calculus): one row per crossing with 1 - t on the over-arc and t, -1 on the incoming and outgoing under-arcs (t - 1, 1, -t at a negative crossing); the determinant of a first minor, by fraction-free (Bareiss) elimination over \mathbb{Z}[t, t^{-1}].

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('trefoil ${trefoil.alexander().format('t')}, figure-eight ${fig8.alexander().format('t')}');
}

String tx(String s) => s.replaceAllMapped(RegExp(r'\^(-?\d+)'), (m) => '^{${m[1]}}');
Output
trefoil t - 1 + t^-1, figure-eight -t + 3 - t^-1
conwaymethod
Laurent conway()

The Conway polynomial \nabla(z), from HOMFLY-PT at a = 1 (any link); for a knot \Delta(t) = \nabla(t^{\tfrac{1}{2}} - t^{-\tfrac{1}{2}}).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('∇(trefoil) = ${trefoil.conway().format('z')}');
}
Output
∇(trefoil) = z^2 + 1
int determinant()

The determinant |\Delta(-1)| = |V(-1)| of a knot.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print([for (final n in ['3_1', '4_1', '5_1', '5_2', '6_1']) LinkDiagram.pd(knotTable[n]!.pd).determinant()]);
}
Output
[3, 5, 5, 7, 9]
homflymethod
Laurent2 homfly()

The HOMFLY-PT polynomial P(a, z): a \cdot P(L_{+}) - a^{-1} \cdot P(L_{-}) = z \cdot P(L_{0}), P(unknot) = 1 (the Knot Atlas convention; Jones is P(a = t^{-1}, z = t^{\tfrac{1}{2}} - t^{-\tfrac{1}{2}}), Conway is P(1, z)).

Skein recursion toward a descending diagram: walk the components from their base points; at the first crossing met first as an under-pass, P(D) = a^{\mp2} P(D switched) \pm a^{\mp1} z P(D smoothed). A descending diagram is an unlink of c components, P = (\frac{a - a^{-1}}{z})^{c - 1}. Kinks are removed first (P is an isotopy invariant), and sub-diagrams are memoised. Exponential in the worst case; fine for the tables (≤ 12 crossings).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('P(trefoil) = ${trefoil.homfly().format()}');
}
Output
P(trefoil) = a^-2 z^2 + 2a^-2 - a^-4
({int lower, int upper, bool exact}) crossingNumberBounds()

Lower and upper bounds for the crossing number of a knot: span V(t) \le c(K) (Kauffman–Murasugi–Thistlethwaite) and the crossings of this diagram once kinks are removed; equal (exact) for a reduced alternating diagram.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(fig8.crossingNumberBounds());
}
Output
(exact: true, lower: 4, upper: 4)
extension

KnotSignature

extension KnotSignature on LinkDiagram

The knot signature by the Gordon–Litherland formula: \sigma = \operatorname{sign}(G) - \mu, with G the Goeritz matrix of a checkerboard colouring (white regions, one deleted) and \mu the correction from the type II crossings (C. McA. Gordon and R. A. Litherland, "On the signature of a link", Invent. Math. 47, 1978). Sign convention: the Knot Atlas's (positive knots have positive signature, e.g. \sigma(7_{3}) = 4).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('trefoil σ = ${trefoil.signature()}, mirror ${trefoil.mirror().signature()}, figure-eight ${fig8.signature()}');
}
Output
trefoil σ = 2, mirror -2, figure-eight 0

Methods

signaturemethod
int signature()
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(LinkDiagram.pd(knotTable['5_1']!.pd).signature());
}
Output
-4
class

Laurent

final class Laurent

A Laurent polynomial \sum c_{k} x^{k} (k \in \mathbb{Z}, c_{k} \in \mathbb{Z}), stored sparse and normalised (no zero coefficients).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final p = Laurent.fromMap({-1: 1, 0: -1, 1: 1});
  print('p = ${p.format('t')}, p² = ${(p * p).format('t')}');
}
Output
p = t - 1 + t^-1, p² = t^2 - 2t + 3 - 2t^-1 + t^-2

Constructors

factory Laurent.fromMap(Map<int, int> terms)

From exponent → coefficient (zeros dropped).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent.fromMap({-2: 3, 1: -1}).format('q'));
}
Output
-q + 3q^-2
factory Laurent.monomial(int exponent, [int coefficient = 1])

c \cdot x^{e}.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent.monomial(-3, 2).format());
}
Output
2x^-3
factory Laurent.constant(int c)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent.constant(5).format());
}
Output
5

Static

zerostaticfield
static final Laurent zero
onestaticfield
static final Laurent one
xstaticfield
static final Laurent x

x itself.

Properties

termsgetter
Map<int, int> get terms

The terms, exponent → coefficient (read only).

isZerogetter
bool get isZero
minDegreegetter
int get minDegree

The smallest and largest exponents (0 for the zero polynomial).

maxDegreegetter
int get maxDegree
spangetter
int get span

maxDegree − minDegree.

absSumgetter
int get absSum

Sum of |c_{k}|.

hashCodegetter
int get hashCode

Methods

scalemethod
Laurent scale(int c)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent.fromMap({1: 1, 2: -1}).scale(-3).format());
}
Output
3x^2 - 3x
shiftmethod
Laurent shift(int k)

Multiplies by x^{k}.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent.fromMap({0: 1, 1: 1}).shift(-1).format());
}
Output
1 + x^-1
powmethod
Laurent pow(int n)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((Laurent.x + Laurent.monomial(-1)).pow(3).format());
}
Output
x^3 + 3x + 3x^-1 + x^-3
Laurent substitutePower(int k)

p(x^{k}): every exponent multiplied by k (k = -1 is the mirror substitution x \to \frac{1}{x}).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('V(1/t) for the trefoil: ${trefoil.jones().substitutePower(-1).format('t')}');
}
Output
V(1/t) for the trefoil: t^-1 + t^-3 - t^-4
Laurent divideExponents(int k)

Exponents all divided by k; throws if one is not a multiple.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent.fromMap({2: 1, -4: 1}).divideExponents(2).format());
}
Output
x + x^-2
exactDivmethod
Laurent exactDiv(Laurent d)

The exact quotient by d; throws StateError if d does not divide this in \mathbb{Z}[x, x^{-1}].

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final a = Laurent.fromMap({0: 1, 1: 1}), b = Laurent.fromMap({0: 1, 1: -1});
  print((a * b).exactDiv(b).format());
}
Output
x + 1
evaluatemethod
num evaluate(num x)

The value at an integer (exact when every exponent is ≥ 0 or x = \pm1).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('V(−1) = ${trefoil.jones().evaluate(-1)}, |Δ(−1)| = ${trefoil.determinant()}');
}
Output
V(−1) = -3, |Δ(−1)| = 3
formatmethod
String format([String variable = 'x'])

Human-readable, highest power first: -q^-4 + q^-3 + q^-1.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(trefoil.jones().format('q'));
}
Output
-q^4 + q^3 + q
toStringmethod
String toString()

Operators

operator []operator
int operator [](int exponent)

The coefficient of x^{e}.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(trefoil.jones()[1]);
}
Output
1
operator +operator
Laurent operator +(Laurent o)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((Laurent.x + Laurent.one).format());
}
Output
x + 1
operator -operator
Laurent operator -(Laurent o)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((Laurent.x - Laurent.x).format());
}
Output
0
operator -operator
Laurent operator -()
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((-Laurent.x).format());
}
Output
-x
operator *operator
Laurent operator *(Laurent o)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((Laurent.fromMap({1: 1, -1: 1}) * Laurent.fromMap({1: 1, -1: -1})).format());
}
Output
x^2 - x^-2
operator ==operator
bool operator ==(Object other)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(fig8.jones() == fig8.jones().substitutePower(-1));
}
Output
true
final class Laurent2

A Laurent polynomial in two variables \sum c a^{i} z^{j} with integer coefficients (HOMFLY-PT lives here).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final p = trefoil.homfly();
  print('${p.format()}; at a = 1: ${p.atAOne().format('z')}');
}
Output
a^-2 z^2 + 2a^-2 - a^-4; at a = 1: z^2 + 1

Constructors

factory Laurent2.fromMap(Map<(int, int), int> terms)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent2.fromMap({(1, 0): 2, (-1, 1): -1}).format());
}
Output
2a - a^-1 z
factory Laurent2.monomial(int i, int j, [int c = 1])
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent2.monomial(2, -1, 3).format());
}
Output
3a^2 z^-1

Static

zerostaticfield
static final Laurent2 zero
onestaticfield
static final Laurent2 one

Properties

termsgetter
Map<(int, int), int> get terms
isZerogetter
bool get isZero
hashCodegetter
int get hashCode

Methods

shiftmethod
Laurent2 shift(int i, int j)

Multiplies by a^{i} z^{j}.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent2.one.shift(1, 1).format());
}
Output
a z
powmethod
Laurent2 pow(int n)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(Laurent2.fromMap({(1, 0): 1, (0, 1): 1}).pow(2).format());
}
Output
a^2 + 2a z + z^2
Laurent2 substitute({int aPower = 1, int zPower = 1, bool negateZ = false})

P(a^{ka}, z^{kz} \cdot \operatorname{sign}): the mirror image of a link is P(a^{-1}, -z).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('mirror HOMFLY: ${trefoil.homfly().substitute(aPower: -1).format()}');
}
Output
mirror HOMFLY: -a^4 + a^2 z^2 + 2a^2
Laurent specialise({required int aExp, required Laurent z})

Sets a = x^aExp and z = z (a one-variable Laurent polynomial in x), exactly. Negative powers of z are cleared by exact division (they must cancel for a genuine specialisation, e.g. HOMFLY-PT → Jones).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  // a = t⁻¹, z = t^½ − t^(−½) gives Jones; in s = t^½: a = s⁻², z = s − s⁻¹.
  print(trefoil.homfly().specialise(aExp: -2, z: Laurent.fromMap({1: 1, -1: -1})).format('s'));
}
Output
-s^8 + s^6 + s^2
atAOnemethod
Laurent atAOne()

P(a, z) at a fixed a = 1 (the Conway polynomial for HOMFLY-PT), as a polynomial in z.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(fig8.homfly().atAOne().format('z'));
}
Output
-z^2 + 1
formatmethod
String format([String a = 'a', String z = 'z'])
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(trefoil.homfly().format('v', 'z'));
}
Output
v^-2 z^2 + 2v^-2 - v^-4
toStringmethod
String toString()

Operators

operator []operator
int operator [](({int a, int z}) e)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(trefoil.homfly()[(a: -2, z: 0)]);
}
Output
2
operator +operator
Laurent2 operator +(Laurent2 o)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((Laurent2.one + Laurent2.monomial(1, 1)).format());
}
Output
a z + 1
operator -operator
Laurent2 operator -(Laurent2 o)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((Laurent2.one - Laurent2.one).format());
}
Output
0
operator -operator
Laurent2 operator -()
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((-Laurent2.monomial(1, 2)).format());
}
Output
-a z^2
operator *operator
Laurent2 operator *(Laurent2 o)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print((Laurent2.monomial(1, 0) * Laurent2.monomial(-1, 2)).format());
}
Output
z^2
operator ==operator
bool operator ==(Object other)
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(fig8.homfly() == fig8.mirror().homfly());
}
Output
true
extension ReidemeisterMoves on LinkDiagram

Reidemeister moves and the other local operations on a LinkDiagram (all keep the planar PD consistent; new edges get labels above the largest one in use).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  // Add two kinks to the unknot, then remove them again.
  final one = LinkDiagram.unlink().addKink(null);
  final k = one.addKink(one.crossings.first.a, positive: false);
  print('${k.crossingCount} crossings, Jones ${k.jones().format('t')}; after R1⁻¹: ${k.removeAllKinks().crossingCount}');
}
Output
2 crossings, Jones 1; after R1⁻¹: 0

Properties

kinksgetter
List<int> get kinks

Crossings that are R1 kinks (an edge from the crossing straight back to it, at adjacent positions).

r2Pokesgetter
List<(int, int, int)> get r2Pokes

The R2 moves available as (face, raya i, raya j): two different edges on one face that a finger can push across.

r2Bigonsgetter
List<(int, int)> get r2Bigons

Bigon faces whose two crossings an R_{2}^{-1} can remove (one strand over at both), as crossing pairs.

List<(int, int)> get r3Triangles

Triangular faces where R3 applies, as (face, side): the strand along that side is over (or under) at both of its triangle crossings and slides across the third crossing.

Methods

smoothedmethod
LinkDiagram smoothed(int ci)

The oriented (Seifert) smoothing of crossing ci: incoming strands joined to the outgoing ones beside them.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print('trefoil smoothed at crossing 0: ${trefoil.smoothed(0).crossingCount} crossings');
}
Output
trefoil smoothed at crossing 0: 2 crossings
LinkDiagram removeKink(int ci)

R_{1}^{-1}: removes kink ci.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final k = LinkDiagram.unlink().addKink(null);
  print(k.removeKink(k.kinks.first).crossingCount);
}
Output
0
LinkDiagram removeAllKinks()

Removes kinks until none is left.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final k = trefoil.addKink(trefoil.crossings.first.a).addKink(trefoil.crossings.first.b);
  print('${k.crossingCount} → ${k.removeAllKinks().crossingCount}');
}
Output
5 → 3
addKinkmethod
LinkDiagram addKink(int? edge, {bool positive = true, bool overFirst = false})

R1: adds a kink on edge edge (or, with edge null, on a crossingless loop). positive picks the sign, overFirst whether the strand meets the kink crossing first as the over-strand.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final k = trefoil.addKink(trefoil.crossings.first.a);
  print('writhe ${trefoil.writhe} → ${k.writhe}; Jones unchanged: ${k.jones() == trefoil.jones()}');
}
Output
writhe 3 → 4; Jones unchanged: true
addPokemethod
LinkDiagram addPoke(int face, int i, int j, {bool over = true})

R2: pushes a finger of the edge on raya i of face face across the edge on raya j of the same face, creating two crossings; over says whether the pushed strand goes over (true) or under.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final (f, i, j) = trefoil.r2Pokes.first;
  final p = trefoil.addPoke(f, i, j);
  print('${p.crossingCount} crossings, Jones unchanged: ${p.jones() == trefoil.jones()}');
}
Output
5 crossings, Jones unchanged: true
LinkDiagram removeBigon(int c1, int c2)

R_{2}^{-1}: removes the bigon between crossings c1 and c2 (see r2Bigons).

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final (f, i, j) = trefoil.r2Pokes.first;
  final p = trefoil.addPoke(f, i, j);
  final (c1, c2) = p.r2Bigons.first;
  print(p.removeBigon(c1, c2).crossingCount);
}
Output
3
LinkDiagram triangleMove(int face, int side)

R3 on triangle face, sliding the strand along side side (see r3Triangles) across the opposite crossing.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final d = LinkDiagram.braid(3, [1, 2, 1]);
  if (d.r3Triangles.isNotEmpty) {
    final (f, s) = d.r3Triangles.first;
    print('R3 keeps Jones: ${d.triangleMove(f, s).jonesHalf() == d.jonesHalf()}');
  } else {
    print('no triangle face');
  }
}
Output
R3 keeps Jones: true
final class KnotTableEntry

One knot or link of the table. jonesHalf is the Jones polynomial in q^{\tfrac{1}{2}} (exponents doubled), homfly maps (power of a, power of z) to the coefficient.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  final e = knotTable['5_2']!;
  print('${e.name}: ${e.title}, ${e.crossings} crossings');
}
Output
5_2: Three-twist, 5 crossings

Constructors

KnotTableEntryconstructor
const KnotTableEntry({required this.name, required this.title, required this.crossings, required this.components, required this.alternating, required this.pd, required this.jonesHalf, required this.homfly, required this.signature, this.dt, this.alexander, this.conway, this.determinant, this.unknotting, this.linking})
Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(knotTable.keys.toList());
}
Output
[3_1, 4_1, 5_1, 5_2, 6_1, 6_2, 6_3, 7_1, 7_2, 7_3, 7_4, 7_5, 7_6, 7_7, 8_19, 8_20, 8_21, 10_124, L2a1, L4a1, L5a1, L6a4]

Properties

namefield
final String name
titlefield
final String title
final int crossings
final int components
final bool alternating
pdfield
final List<List<int>> pd
dtfield
final List<int>? dt
final Map<int, int> jonesHalf
final Map<int, int>? alexander
conwayfield
final Map<int, int>? conway
homflyfield
final Map<(int, int), int> homfly
final int? determinant
final int signature
final int? unknotting
linkingfield
final List<int>? linking
Laurent get jonesHalfPoly
Laurent? get alexanderPoly
Laurent? get conwayPoly
Laurent2 get homflyPoly
final class TubeMesh

A triangle mesh of a tube around a curve: per-vertex positions and unit normals (xyz), uvs (u along the curve, v around it), tangents (the curve direction, xyz) and counter-clockwise (outward-facing) indices.

Properties

final Float32List positions
normalsfield
final Float32List normals
uvsfield
final Float32List uvs
final Float32List tangents
indicesfield
final Uint32List indices
ringsfield
final int rings

Rings along the curve (the last repeats the first for a closed curve, so the texture seam has its own vertices) and vertices per ring minus one (the seam around the tube is duplicated too).

sidesfield
final int sides

Rings along the curve (the last repeats the first for a closed curve, so the texture seam has its own vertices) and vertices per ring minus one (the seam around the tube is duplicated too).

int get vertexCount

Methods

Float32List interleaved()

The riptide_render interleaved layout (Geometry(vertices: …, indices: …)): position 3, normal 3, uv 2, tangent 4 (xyz + handedness 1) = 12 floats per vertex.

Example
import 'package:riptide_knots/riptide_knots.ray';
import 'raya:convert';
import 'raya:typed_data';

String f4(num x) => x.toStringAsFixed(4);

void main() {
  final trefoil = LinkDiagram.braid(2, [1, 1, 1]);
  final fig8 = LinkDiagram.pd(knotTable['4_1']!.pd);
  print(tubeMesh(KnotCurves.circle((0, 0, 0), (1, 0, 0), (0, 1, 0), samples: 8), sides: 4).interleaved().length);
}
Output
540