Hi David,
I had to ask again and got an updated result.
Code: Select alltype
TPoint3D = record
X, Y, Z: Double;
end;
function TorusKnotPoints(r1, r2: Double; numPoints, p, q: Integer): TArray<TPoint3D>;
var
t, theta: Double;
i: Integer;
begin
SetLength(Result, numPoints);
for i := 0 to numPoints-1 do
begin
t := 2 * Pi * i / numPoints;
theta := t * p;
Result[i].X := (r1 + r2 * Cos(q * theta)) * Cos(theta);
Result[i].Y := (r1 + r2 * Cos(q * theta)) * Sin(theta);
Result[i].Z := r2 * Sin(q * theta);
end;
end;
procedure GeneratePoints();
var
i: Integer;
Knot: TArray<TPoint3D>
begin
for i := 0 to Length(Knot) - 1 do begin
pt.x := Knot[i].X;
pt.y := Knot[i].Y;
pt.z := Knot[i].Z;
ent_init(ent, entmrk);
ent.mrkpnt := pt;
ent.Non_Printing := 0; // Make points printable
ent_add(ent); // current color, line type, etc.
//ent.color := RandomRange(1, 255);
ent.mrktyp := 1; // RandomRange(1, 8); { 1-square, 2-'x', 3-diamond, 4-dot, ... }
// ent.mrksiz := RandomRange(16, 64); { size in pixels }
ent_update(ent); // update entity properties
ent_draw(ent, drmode_white); { draw entity on the screen }
end;
end;
The first result was incomplete.
Here's the Knot of points around the Torus.
Torus Knot
TorusKnot.jpg (103.08 KiB) Viewed 27478 times