Author Topic: PQ Torus Knot  (Read 4422 times)

0 Members and 1 Guest are viewing this topic.

Offline evobyte

  • ZX 81
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
    • TSRh Team
PQ Torus Knot
« on: September 02, 2010 »
Hi,

I was checking out some torus knot equations at http://en.wikipedia.org/wiki/Torus_knot.  My question is, I've got a per-pixel implementation working based on the formulas given, but I'd like to know how to connect-the-dots, if you will, with triangle strips, to make a solid looking knot.  Right now it just looks like a graph or a pencil drawing, not very 3D at all.

[EDIT] I'd like to add that by "solid", I mean drawn such that I could texture map it and apply lighting, etc.

Thanks for any ideas!
« Last Edit: September 02, 2010 by evobyte »

Offline hellfire

  • Sponsor
  • Pentium
  • *******
  • Posts: 1294
  • Karma: 466
    • View Profile
    • my stuff
Re: PQ Torus Knot
« Reply #1 on: September 02, 2010 »
The pq-function gives the center-point (x,y,z) of the cylinder for a given angle.
Sampling the function a small step before and after the desired angle gives the orientation of the cylinder.
Create circles around the center and along the orientation and connect neighbouring circles by polygons.
Have a look at Blackpawn's page.
Challenge Trophies Won:

Offline evobyte

  • ZX 81
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
    • TSRh Team
Re: PQ Torus Knot
« Reply #2 on: September 02, 2010 »
Alright, it appears that answer is indeed to use a Frenet frame while following along the curve.  Thanks for your answer.  Time to crack open the old math books...  ::)

Offline relsoft

  • DBF Aficionado
  • ******
  • Posts: 3303
  • Karma: 47
    • View Profile
Re: PQ Torus Knot
« Reply #3 on: September 03, 2010 »
Code here:

http://rel.betterwebber.com/junk.php?id=41


Very old. Needs SDL.DLL

Challenge Trophies Won:

Offline evobyte

  • ZX 81
  • *
  • Posts: 7
  • Karma: 0
    • View Profile
    • TSRh Team
Re: PQ Torus Knot
« Reply #4 on: September 03, 2010 »
This is fantastic, Relsoft.  Thanks for sharing your code.

If I knew how to give you karma, I would, haha.

[EDIT] Actually your whole site is just amazing.  Awesome that you provide code for every example.  I bookmarked it, and I will follow along closely with my math book ;-)

Thank you SO much.

-evobyte
« Last Edit: September 03, 2010 by evobyte »

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: PQ Torus Knot
« Reply #5 on: September 03, 2010 »
Cool stuff!

btw, You can give karma once you hit 25 posts.

Jim
Challenge Trophies Won: